diff options
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp index e269f46422..5f94403824 100644 --- a/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ b/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( |