add new check to find NSError init invocation
authorYan Zhang <ynzhang@google.com>
Thu, 30 Nov 2017 19:05:08 +0000 (19:05 +0000)
committerYan Zhang <ynzhang@google.com>
Thu, 30 Nov 2017 19:05:08 +0000 (19:05 +0000)
commit8c348b33385e5d1c39d2b8e0af956d889bac65a1
treee7b6275529612c69038bb4b1a12e05249254df69
parent59e3d198136da55656c67d67aa0d0d3695054373
add new check to find NSError init invocation

Summary:
This check will find out improper initialization of NSError objects.

According to Apple developer document, we should always use factory method errorWithDomain:code:userInfo: to create new NSError objects instead of [NSError alloc] init]. Otherwise it will lead to a warning message during runtime in Xcode.

The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html

Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D40528

llvm-svn: 319459
clang-tools-extra/clang-tidy/objc/AvoidNserrorInitCheck.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/objc/AvoidNserrorInitCheck.h [new file with mode: 0644]
clang-tools-extra/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/objc-avoid-nserror-init.rst [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/objc-avoid-nserror-init.m [new file with mode: 0644]