summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-10-01 20:33:58 +0000
committerAnna Zaks <ganna@apple.com>2012-10-01 20:33:58 +0000
commitbfacf17b8b99f2c6d51bf570a11d6e6a5d3a2a39 (patch)
tree25f88d14966c2e0fc3f702f2dc4c2e1f2b88dc72 /clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
parent99a241fa2c12a375bbd03dd27cb515be2a02f977 (diff)
downloadbcm5719-llvm-bfacf17b8b99f2c6d51bf570a11d6e6a5d3a2a39.tar.gz
bcm5719-llvm-bfacf17b8b99f2c6d51bf570a11d6e6a5d3a2a39.zip
[analyzer] Address Jordan's review for r164868.
llvm-svn: 164965
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
index e269f464222..5f944038242 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
@@ -111,7 +111,9 @@ class IvarInvalidationChecker :
/// The invalidation method being currently processed.
const ObjCMethodDecl *InvalidationMethod;
- /// Peel off parents, casts, OpaqueValueExpr, and PseudoObjectExpr.
+ ASTContext &Ctx;
+
+ /// Peel off parens, casts, OpaqueValueExpr, and PseudoObjectExpr.
const Expr *peel(const Expr *E) const;
/// Does this expression represent zero: '0'?
@@ -141,14 +143,16 @@ class IvarInvalidationChecker :
bool &InCalledAnotherInvalidationMethod,
const MethToIvarMapTy &InPropertySetterToIvarMap,
const MethToIvarMapTy &InPropertyGetterToIvarMap,
- const PropToIvarMapTy &InPropertyToIvarMap)
+ const PropToIvarMapTy &InPropertyToIvarMap,
+ ASTContext &InCtx)
: EnclosingMethod(InMeth),
IVars(InIVars),
CalledAnotherInvalidationMethod(InCalledAnotherInvalidationMethod),
PropertySetterToIvarMap(InPropertySetterToIvarMap),
PropertyGetterToIvarMap(InPropertyGetterToIvarMap),
PropertyToIvarMap(InPropertyToIvarMap),
- InvalidationMethod(0) {}
+ InvalidationMethod(0),
+ Ctx(InCtx) {}
void VisitStmt(const Stmt *S) { VisitChildren(S); }
@@ -363,7 +367,8 @@ void IvarInvalidationChecker::checkASTDecl(const ObjCMethodDecl *D,
CalledAnotherInvalidationMethod,
PropSetterToIvarMap,
PropGetterToIvarMap,
- PropertyToIvarMap).VisitStmt(D->getBody());
+ PropertyToIvarMap,
+ BR.getContext()).VisitStmt(D->getBody());
if (CalledAnotherInvalidationMethod)
return;
@@ -467,21 +472,14 @@ void IvarInvalidationChecker::MethodCrawler::checkObjCPropertyRefExpr(
bool IvarInvalidationChecker::MethodCrawler::isZero(const Expr *E) const {
E = peel(E);
- if (const IntegerLiteral *IL = dyn_cast<IntegerLiteral>(E))
- return IL->getValue() == 0;
-
- if (const CastExpr *ICE = dyn_cast<CastExpr>(E))
- return ICE->getCastKind() == CK_NullToPointer;
- return false;
+ return (E->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNotNull)
+ != Expr::NPCK_NotNull);
}
void IvarInvalidationChecker::MethodCrawler::check(const Expr *E) {
E = peel(E);
- if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E))
- E = OVE->getSourceExpr();
-
if (const ObjCIvarRefExpr *IvarRef = dyn_cast<ObjCIvarRefExpr>(E)) {
checkObjCIvarRefExpr(IvarRef);
return;
@@ -500,7 +498,9 @@ void IvarInvalidationChecker::MethodCrawler::check(const Expr *E) {
void IvarInvalidationChecker::MethodCrawler::VisitBinaryOperator(
const BinaryOperator *BO) {
- if (!BO->isAssignmentOp())
+ VisitStmt(BO);
+
+ if (BO->getOpcode() != BO_Assign)
return;
// Do we assign zero?
@@ -509,8 +509,6 @@ void IvarInvalidationChecker::MethodCrawler::VisitBinaryOperator(
// Check the variable we are assigning to.
check(BO->getLHS());
-
- VisitStmt(BO);
}
void IvarInvalidationChecker::MethodCrawler::VisitObjCMessageExpr(
OpenPOWER on IntegriCloud