/// 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'?
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); }
CalledAnotherInvalidationMethod,
PropSetterToIvarMap,
PropGetterToIvarMap,
- PropertyToIvarMap).VisitStmt(D->getBody());
+ PropertyToIvarMap,
+ BR.getContext()).VisitStmt(D->getBody());
if (CalledAnotherInvalidationMethod)
return;
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;
void IvarInvalidationChecker::MethodCrawler::VisitBinaryOperator(
const BinaryOperator *BO) {
- if (!BO->isAssignmentOp())
+ VisitStmt(BO);
+
+ if (BO->getOpcode() != BO_Assign)
return;
// Do we assign zero?
// Check the variable we are assigning to.
check(BO->getLHS());
-
- VisitStmt(BO);
}
void IvarInvalidationChecker::MethodCrawler::VisitObjCMessageExpr(