summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2013-01-10 23:34:16 +0000
committerAnna Zaks <ganna@apple.com>2013-01-10 23:34:16 +0000
commita96a9ef716d2cbf9fd015011c56a3140a47d4792 (patch)
tree4bb13754bf7f96d2e0a18885238ec510eafc2c4b /clang/lib/StaticAnalyzer
parent930f73a0dd42b782d67631164256f76b55a4378b (diff)
downloadbcm5719-llvm-a96a9ef716d2cbf9fd015011c56a3140a47d4792.tar.gz
bcm5719-llvm-a96a9ef716d2cbf9fd015011c56a3140a47d4792.zip
[analyzer] Allow IvarInvalidation checker to suppress warnings via
assertions. To ensure that custom assertions/conditional would also be supported, just check if the ivar that needs to be invalidated or set to nil is compared against 0. Unfortunately, this will not work for code containing 'assert(IvarName)' llvm-svn: 172147
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
index fd763d46f98..80cb58d76b8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
@@ -576,15 +576,23 @@ void IvarInvalidationChecker::MethodCrawler::VisitBinaryOperator(
const BinaryOperator *BO) {
VisitStmt(BO);
- if (BO->getOpcode() != BO_Assign)
+ // Do we assign/compare against zero? If yes, check the variable we are
+ // assigning to.
+ BinaryOperatorKind Opcode = BO->getOpcode();
+ if (Opcode != BO_Assign &&
+ Opcode != BO_EQ &&
+ Opcode != BO_NE)
return;
- // Do we assign zero?
- if (!isZero(BO->getRHS()))
- return;
+ if (isZero(BO->getRHS())) {
+ check(BO->getLHS());
+ return;
+ }
- // Check the variable we are assigning to.
- check(BO->getLHS());
+ if (Opcode != BO_Assign && isZero(BO->getLHS())) {
+ check(BO->getRHS());
+ return;
+ }
}
void IvarInvalidationChecker::MethodCrawler::VisitObjCMessageExpr(
OpenPOWER on IntegriCloud