[cfe-commits] r164965 - /cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
Anna Zaks
ganna at apple.com
Mon Oct 1 13:33:58 PDT 2012
Author: zaks
Date: Mon Oct 1 15:33:58 2012
New Revision: 164965
URL: http://llvm.org/viewvc/llvm-project?rev=164965&view=rev
Log:
[analyzer] Address Jordan's review for r164868.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp?rev=164965&r1=164964&r2=164965&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp Mon Oct 1 15:33:58 2012
@@ -111,7 +111,9 @@
/// 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 @@
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 @@
CalledAnotherInvalidationMethod,
PropSetterToIvarMap,
PropGetterToIvarMap,
- PropertyToIvarMap).VisitStmt(D->getBody());
+ PropertyToIvarMap,
+ BR.getContext()).VisitStmt(D->getBody());
if (CalledAnotherInvalidationMethod)
return;
@@ -467,21 +472,14 @@
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::VisitBinaryOperator(
const BinaryOperator *BO) {
- if (!BO->isAssignmentOp())
+ VisitStmt(BO);
+
+ if (BO->getOpcode() != BO_Assign)
return;
// Do we assign zero?
@@ -509,8 +509,6 @@
// Check the variable we are assigning to.
check(BO->getLHS());
-
- VisitStmt(BO);
}
void IvarInvalidationChecker::MethodCrawler::VisitObjCMessageExpr(
More information about the cfe-commits
mailing list