diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index b290ac4bd70b..a7fb5b57095e 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -380,6 +380,9 @@ public: /// with those assumptions. void evalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, const Expr *Ex); + + std::pair + getEagerlyAssumeTags(); SVal evalMinus(SVal X) { return X.isValid() ? svalBuilder.evalMinus(cast(X)) : X; diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index d55bddd0ea8a..1ea90047facb 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1761,10 +1761,17 @@ void ExprEngine::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Ex, // Transfer function: Objective-C ivar references. //===----------------------------------------------------------------------===// +std::pair +ExprEngine::getEagerlyAssumeTags() { + static SimpleProgramPointTag + EagerlyAssumeTrue("ExprEngine : Eagerly Assume True"), + EagerlyAssumeFalse("ExprEngine : Eagerly Assume False"); + return std::make_pair(&EagerlyAssumeTrue, &EagerlyAssumeFalse); +} + void ExprEngine::evalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, const Expr *Ex) { - static SimpleProgramPointTag EagerlyAssumeTag("ExprEngine : Eagerly Assume"); for (ExplodedNodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) { ExplodedNode *Pred = *I; @@ -1781,18 +1788,21 @@ void ExprEngine::evalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, const ProgramState *state = Pred->getState(); SVal V = state->getSVal(Ex); if (nonloc::SymExprVal *SEV = dyn_cast(&V)) { + const std::pair &tags = + getEagerlyAssumeTags(); + // First assume that the condition is true. - if (const ProgramState *stateTrue = state->assume(*SEV, true)) { + if (const ProgramState *StateTrue = state->assume(*SEV, true)) { SVal Val = svalBuilder.makeIntVal(1U, Ex->getType()); - stateTrue = stateTrue->BindExpr(Ex, Val); - Dst.Add(Builder->generateNode(Ex, stateTrue, Pred, &EagerlyAssumeTag)); + StateTrue = StateTrue->BindExpr(Ex, Val); + Dst.Add(Builder->generateNode(Ex, StateTrue, Pred, tags.first)); } // Next, assume that the condition is false. - if (const ProgramState *stateFalse = state->assume(*SEV, false)) { + if (const ProgramState *StateFalse = state->assume(*SEV, false)) { SVal Val = svalBuilder.makeIntVal(0U, Ex->getType()); - stateFalse = stateFalse->BindExpr(Ex, Val); - Dst.Add(Builder->generateNode(Ex, stateFalse, Pred, &EagerlyAssumeTag)); + StateFalse = StateFalse->BindExpr(Ex, Val); + Dst.Add(Builder->generateNode(Ex, StateFalse, Pred, tags.second)); } } else