diff options
author | Anna Zaks <ganna@apple.com> | 2013-01-10 23:34:16 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-01-10 23:34:16 +0000 |
commit | 6503255e4fa0689f427b3b798180fceac29c98c2 (patch) | |
tree | 1c27ff899fb091d9d131e5ddaf6b52d97b14738e /lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp | |
parent | c2316db5decd9cb7f8768ca67fad41fd8cffc110 (diff) |
[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)'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp index fd763d46f9..80cb58d76b 100644 --- a/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ b/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( |