summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2013-02-09 01:09:27 +0000
committerAnna Zaks <ganna@apple.com>2013-02-09 01:09:27 +0000
commit7811c3efd5f402cb0077c7c1f1d9bd644eef128d (patch)
treee2a3a6138f59d2a39233ada5a9a91b63d12aaf74 /clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
parentf23980aba5f4a184c3f3cdaffcb89f63d4050b5b (diff)
downloadbcm5719-llvm-7811c3efd5f402cb0077c7c1f1d9bd644eef128d.tar.gz
bcm5719-llvm-7811c3efd5f402cb0077c7c1f1d9bd644eef128d.zip
[analyzer] Invalidation checker: move the "missing implementation" check
The missing definition check should be in the same category as the missing ivar validation - in this case, the intent is to invalidate in the given class, as described in the declaration, but the implementation does not perform the invalidation. Whereas the MissingInvalidationMethod checker checks the cases where the method intention is not to invalidate. The second checker has potential to have a much higher false positive rate. llvm-svn: 174787
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
index 6262cb8ef9d..0389cc551b3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
@@ -51,8 +51,7 @@ struct ChecksFilter {
DefaultBool check_InstanceVariableInvalidation;
};
-class IvarInvalidationCheckerImpl :
- public Checker<check::ASTDecl<ObjCImplementationDecl> > {
+class IvarInvalidationCheckerImpl {
typedef llvm::SmallSetVector<const ObjCMethodDecl*, 2> MethodSet;
typedef llvm::DenseMap<const ObjCMethodDecl*,
@@ -471,12 +470,20 @@ visit(const ObjCImplementationDecl *ImplD) const {
containsInvalidationMethod(InterfaceD, Info, /*LookForPartial*/ false);
// Report an error in case none of the invalidation methods are declared.
- if (!Info.needsInvalidation() && Filter.check_MissingInvalidationMethod) {
- reportNoInvalidationMethod(FirstIvarDecl, IvarToPopertyMap, InterfaceD,
- /*MissingDeclaration*/ true);
+ if (!Info.needsInvalidation()) {
+ if (Filter.check_MissingInvalidationMethod)
+ reportNoInvalidationMethod(FirstIvarDecl, IvarToPopertyMap, InterfaceD,
+ /*MissingDeclaration*/ true);
+ // If there are no invalidation methods, there is no ivar validation work
+ // to be done.
return;
}
+ // Only check if Ivars are invalidated when InstanceVariableInvalidation
+ // has been requested.
+ if (!Filter.check_InstanceVariableInvalidation)
+ return;
+
// Check that all ivars are invalidated by the invalidation methods.
bool AtImplementationContainsAtLeastOneInvalidationMethod = false;
for (MethodSet::iterator I = Info.InvalidationMethods.begin(),
@@ -489,11 +496,6 @@ visit(const ObjCImplementationDecl *ImplD) const {
if (D && D->hasBody()) {
AtImplementationContainsAtLeastOneInvalidationMethod = true;
- // Only check if Ivars are invalidated when InstanceVariableInvalidation
- // has been requested.
- if (!Filter.check_InstanceVariableInvalidation)
- break;
-
// Get a copy of ivars needing invalidation.
IvarSet IvarsI = Ivars;
@@ -517,8 +519,7 @@ visit(const ObjCImplementationDecl *ImplD) const {
}
// Report an error in case none of the invalidation methods are implemented.
- if (!AtImplementationContainsAtLeastOneInvalidationMethod &&
- Filter.check_MissingInvalidationMethod)
+ if (!AtImplementationContainsAtLeastOneInvalidationMethod)
reportNoInvalidationMethod(FirstIvarDecl, IvarToPopertyMap, InterfaceD,
/*MissingDeclaration*/ false);
}
OpenPOWER on IntegriCloud