[cfe-commits] r49910 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/GRTransferFuncs.h lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Fri Apr 18 10:20:23 PDT 2008


Author: kremenek
Date: Fri Apr 18 12:20:23 2008
New Revision: 49910

URL: http://llvm.org/viewvc/llvm-project?rev=49910&view=rev
Log:
Added "EvalAssume" virtual method to GRTransferFuncs; this is for evaluating
the checker-specific logic of symbolic assumptions.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=49910&r1=49909&r2=49910&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Fri Apr 18 12:20:23 2008
@@ -447,10 +447,16 @@
   
   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);
   

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=49910&r1=49909&r2=49910&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Fri Apr 18 12:20:23 2008
@@ -96,6 +96,16 @@
                           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

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=49910&r1=49909&r2=49910&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri Apr 18 12:20:23 2008
@@ -1840,13 +1840,20 @@
 //===----------------------------------------------------------------------===//
 
 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 @@
       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, 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.");





More information about the cfe-commits mailing list