diff options
author | Anna Zaks <ganna@apple.com> | 2013-01-17 23:24:58 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-01-17 23:24:58 +0000 |
commit | 0e9c94199cbb814f3f8b88eef951e8880c0da9cc (patch) | |
tree | 81c0e8706e8d131dc8ef12c79d34649c34b5d470 /clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp | |
parent | d33f5201b5f413d0985338a6e5baf403b0e8167b (diff) | |
download | bcm5719-llvm-0e9c94199cbb814f3f8b88eef951e8880c0da9cc.tar.gz bcm5719-llvm-0e9c94199cbb814f3f8b88eef951e8880c0da9cc.zip |
[analyzer] DirectIvarAssignment: allow suppression annotation on Ivars.
llvm-svn: 172766
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp b/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp index 2cb511cbeae..6d3dd1e42f0 100644 --- a/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp @@ -7,9 +7,17 @@ // //===----------------------------------------------------------------------===// // -// Check that Objective C properties follow the following rules: -// - The property should be set with the setter, not though a direct -// assignment. +// Check that Objective C properties are set with the setter, not though a +// direct assignment. +// +// Two versions of a checker exist: one that checks all methods and the other +// that only checks the methods annotated with +// __attribute__((annotate("objc_no_direct_instance_variable_assignment"))) +// +// The checker does not warn about assignments to Ivars, annotated with +// __attribute__((objc_allow_direct_instance_variable_assignment"))). This +// annotation serves as a false positive suppression mechanism for the +// checker. The annotation is allowed on properties and Ivars. // //===----------------------------------------------------------------------===// @@ -155,7 +163,7 @@ void DirectIvarAssignment::checkASTDecl(const ObjCImplementationDecl *D, } } -static bool isAnnotatedToAllowDirectAssignment(const ObjCPropertyDecl *D) { +static bool isAnnotatedToAllowDirectAssignment(const Decl *D) { for (specific_attr_iterator<AnnotateAttr> AI = D->specific_attr_begin<AnnotateAttr>(), AE = D->specific_attr_end<AnnotateAttr>(); AI != AE; ++AI) { @@ -183,10 +191,12 @@ void DirectIvarAssignment::MethodCrawler::VisitBinaryOperator( if (I != IvarToPropMap.end()) { const ObjCPropertyDecl *PD = I->second; - // Skip warnings on Ivars that correspond to properties, annotated with + // Skip warnings on Ivars, annotated with // objc_allow_direct_instance_variable_assignment. This annotation serves - // as a false positive suppression mechanism for the checker. - if (isAnnotatedToAllowDirectAssignment(PD)) + // as a false positive suppression mechanism for the checker. The + // annotation is allowed on properties and ivars. + if (isAnnotatedToAllowDirectAssignment(PD) || + isAnnotatedToAllowDirectAssignment(D)) return; ObjCMethodDecl *GetterMethod = |