[cfe-commits] r137704 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/StaticAnalyzer/Core/ExprEngine.cpp

Ted Kremenek kremenek at apple.com
Mon Aug 15 18:53:39 PDT 2011


Author: kremenek
Date: Mon Aug 15 20:53:39 2011
New Revision: 137704

URL: http://llvm.org/viewvc/llvm-project?rev=137704&view=rev
Log:
[analyzer] add ExprEngine::getEagerlyAssumedTags() to allow externally querying of "eagerly assumed" expressions.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=137704&r1=137703&r2=137704&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Mon Aug 15 20:53:39 2011
@@ -380,6 +380,9 @@
   ///  with those assumptions.
   void evalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, 
                          const Expr *Ex);
+  
+  std::pair<const ProgramPointTag *, const ProgramPointTag*>
+    getEagerlyAssumeTags();
 
   SVal evalMinus(SVal X) {
     return X.isValid() ? svalBuilder.evalMinus(cast<NonLoc>(X)) : X;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=137704&r1=137703&r2=137704&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Aug 15 20:53:39 2011
@@ -1761,10 +1761,17 @@
 // Transfer function: Objective-C ivar references.
 //===----------------------------------------------------------------------===//
 
+std::pair<const ProgramPointTag *, const ProgramPointTag*>
+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 @@
     const ProgramState *state = Pred->getState();
     SVal V = state->getSVal(Ex);
     if (nonloc::SymExprVal *SEV = dyn_cast<nonloc::SymExprVal>(&V)) {
+      const std::pair<const ProgramPointTag *, const ProgramPointTag*> &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





More information about the cfe-commits mailing list