]> granicus.if.org Git - clang/commitdiff
Added "EvalAssume" virtual method to GRTransferFuncs; this is for evaluating
authorTed Kremenek <kremenek@apple.com>
Fri, 18 Apr 2008 17:20:23 +0000 (17:20 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 18 Apr 2008 17:20:23 +0000 (17:20 +0000)
the checker-specific logic of symbolic assumptions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49910 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/GRExprEngine.h
include/clang/Analysis/PathSensitive/GRTransferFuncs.h
lib/Analysis/GRExprEngine.cpp

index 0d26d98ad0fa9439ab11792426ad55e8fe419067..46ff661959689e10eedede206528a04c92e03f93 100644 (file)
@@ -447,10 +447,16 @@ protected:
   
   ValueState* Assume(ValueState* St, LVal Cond, bool Assumption,
                      bool& isFeasible);
-  
+                     
+  ValueState* AssumeAux(ValueState* St, LVal Cond, bool Assumption,
+                        bool& isFeasible);
+
   ValueState* Assume(ValueState* St, NonLVal Cond, bool Assumption,
                      bool& isFeasible);
   
+  ValueState* AssumeAux(ValueState* St, NonLVal Cond, bool Assumption,
+                        bool& isFeasible);
+  
   ValueState* AssumeSymNE(ValueState* St, SymbolID sym, const llvm::APSInt& V,
                           bool& isFeasible);
   
index d49144f355d17d663bbf5fb170a82e72bc4cc833..60492b5eeab156e458caef763c96bed0865428e8 100644 (file)
@@ -96,6 +96,16 @@ public:
                           GRStmtNodeBuilder<ValueState>& Builder,
                           ReturnStmt* S,
                           ExplodedNode<ValueState>* Pred) {}
+
+  // Assumptions.
+  
+  virtual ValueState* EvalAssume(ValueState* St, NonLVal Cond, bool Assumption){
+    return St;
+  }
+  
+  virtual ValueState* EvalAssume(ValueState* St, LVal Cond, bool Assumption) {
+    return St;
+  }
 };
   
 } // end clang namespace
index 418129caa927a89dfee1c31329a55aeb2fcfdffa..e3fe2395535c1f89214a99a50adc14c7134698aa 100644 (file)
@@ -1840,13 +1840,20 @@ void GRExprEngine::HandleUndefinedStore(Stmt* S, NodeTy* Pred) {
 //===----------------------------------------------------------------------===//
 
 ValueState* GRExprEngine::Assume(ValueState* St, LVal Cond,
-                                           bool Assumption, 
-                                           bool& isFeasible) {
+                                 bool Assumption, bool& isFeasible) {
+                                             
+  St = AssumeAux(St, Cond, Assumption, isFeasible);
+  return isFeasible ? St : TF->EvalAssume(St, Cond, Assumption);
+}
+
+ValueState* GRExprEngine::AssumeAux(ValueState* St, LVal Cond,
+                                    bool Assumption, bool& isFeasible) {
+                                       
   switch (Cond.getSubKind()) {
     default:
       assert (false && "'Assume' not implemented for this LVal.");
       return St;
-      
+
     case lval::SymbolValKind:
       if (Assumption)
         return AssumeSymNE(St, cast<lval::SymbolVal>(Cond).getSymbol(),
@@ -1854,8 +1861,8 @@ ValueState* GRExprEngine::Assume(ValueState* St, LVal Cond,
       else
         return AssumeSymEQ(St, cast<lval::SymbolVal>(Cond).getSymbol(),
                            BasicVals.getZeroWithPtrWidth(), isFeasible);
-      
-      
+
+
     case lval::DeclValKind:
     case lval::FuncValKind:
     case lval::GotoLabelKind:
@@ -1871,8 +1878,14 @@ ValueState* GRExprEngine::Assume(ValueState* St, LVal Cond,
 }
 
 ValueState* GRExprEngine::Assume(ValueState* St, NonLVal Cond,
-                                         bool Assumption, 
-                                         bool& isFeasible) {  
+                                 bool Assumption, bool& isFeasible) {
+
+  St = AssumeAux(St, Cond, Assumption, isFeasible);
+  return isFeasible ? St : TF->EvalAssume(St, Cond, Assumption);
+}
+
+ValueState* GRExprEngine::AssumeAux(ValueState* St, NonLVal Cond,
+                                    bool Assumption, bool& isFeasible) {  
   switch (Cond.getSubKind()) {
     default:
       assert (false && "'Assume' not implemented for this NonLVal.");