diff options
author | Devin Coughlin <dcoughlin@apple.com> | 2015-08-08 01:31:51 +0000 |
---|---|---|
committer | Devin Coughlin <dcoughlin@apple.com> | 2015-08-08 01:31:51 +0000 |
commit | de2cc01cd40f382ebe54bb4986ff324868c800e3 (patch) | |
tree | def10b65a1e9438a10b5966c6124b1fdcda0f8e7 | |
parent | 68ba18f5756932c5269a712cdd3a67eb8755b010 (diff) | |
download | bcm5719-llvm-de2cc01cd40f382ebe54bb4986ff324868c800e3.tar.gz bcm5719-llvm-de2cc01cd40f382ebe54bb4986ff324868c800e3.zip |
[analyzer] Don't issue alarm in ObjCSuperCallChecker for the super class itself.
The ObjCSuperCallChecker issues alarms for various Objective-C APIs that require
a subclass to call to its superclass's version of a method when overriding it.
So, for example, it raises an alarm when the -viewDidLoad method in a subclass
of UIViewController does not call [super viewDidLoad].
This patch fixes a false alarm where the analyzer erroneously required the
implementation of the superclass itself (e.g., UIViewController) to call
super.
rdar://problem/18416944
Differential Revision: http://reviews.llvm.org/D11842
llvm-svn: 244386
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp | 2 | ||||
-rw-r--r-- | clang/test/Analysis/superclass.m | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp index 016cb146f84..6df1da5eb4d 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp @@ -88,7 +88,7 @@ private: /// \param[out] SuperclassName On return, the found superclass name. bool ObjCSuperCallChecker::isCheckableClass(const ObjCImplementationDecl *D, StringRef &SuperclassName) const { - const ObjCInterfaceDecl *ID = D->getClassInterface(); + const ObjCInterfaceDecl *ID = D->getClassInterface()->getSuperClass(); for ( ; ID ; ID = ID->getSuperClass()) { SuperclassName = ID->getIdentifier()->getName(); diff --git a/clang/test/Analysis/superclass.m b/clang/test/Analysis/superclass.m index d5d3c476407..3102d1f35a7 100644 --- a/clang/test/Analysis/superclass.m +++ b/clang/test/Analysis/superclass.m @@ -30,7 +30,7 @@ typedef enum UIViewAnimationOptions { - (void)didReceiveMemoryWarning; - (void)removeFromParentViewController; - (void)transitionFromViewController:(UIViewController *)fromViewController - toViewController:(UIViewController *)toViewController + toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; @@ -69,6 +69,25 @@ typedef enum UIViewAnimationOptions { - (void)encodeRestorableStateWithCoder:(NSCoder *)coder {} @end +// Do not warn for the implementation in the superclass itself. +@implementation UIViewController +- (void)addChildViewController:(UIViewController *)childController {} +- (void)viewDidAppear:(BOOL)animated {} +- (void)viewDidDisappear:(BOOL)animated {} +- (void)viewDidUnload {} +- (void)viewDidLoad {} +- (void)viewWillUnload {} +- (void)viewWillAppear:(BOOL)animated {} +- (void)viewWillDisappear:(BOOL)animated {} +- (void)didReceiveMemoryWarning {} +- (void)removeFromParentViewController {} +- (void)transitionFromViewController:(UIViewController *)fromViewController + toViewController:(UIViewController *)toViewController + duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options + animations:(void (^)(void))animations + completion:(void (^)(BOOL finished))completion {} +@end + // Warn if UIViewController is our superclass and we do not call super @interface TestB : UIViewController {} @end |