[cfe-commits] r48237 - in /cfe/trunk: Analysis/ValueState.cpp include/clang/Analysis/PathSensitive/GRTransferFuncs.h include/clang/Analysis/PathSensitive/ValueState.h

Ted Kremenek kremenek at apple.com
Tue Mar 11 11:57:24 PDT 2008


Author: kremenek
Date: Tue Mar 11 13:57:24 2008
New Revision: 48237

URL: http://llvm.org/viewvc/llvm-project?rev=48237&view=rev
Log:
Expanded ValueState pretty-printing to use an optional "CheckerStatePrinter"
object to pretty-print the component of a state that is specific to a checker.

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

Modified: cfe/trunk/Analysis/ValueState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/ValueState.cpp?rev=48237&r1=48236&r2=48237&view=diff

==============================================================================
--- cfe/trunk/Analysis/ValueState.cpp (original)
+++ cfe/trunk/Analysis/ValueState.cpp Tue Mar 11 13:57:24 2008
@@ -476,13 +476,16 @@
   return I;
 }
 
-void ValueState::printDOT(std::ostream& Out) const {
-  print(Out, "\\l", "\\|");
+void ValueState::printDOT(std::ostream& Out, CheckerStatePrinter* P) const {
+  print(Out, P, "\\l", "\\|");
 }
 
-void ValueState::print(std::ostream& Out,
-                       const char* nl,
-                       const char* sep) const {
+void ValueState::printStdErr(CheckerStatePrinter* P) const {
+  print(*llvm::cerr, P);
+}  
+
+void ValueState::print(std::ostream& Out, CheckerStatePrinter* P,
+                       const char* nl, const char* sep) const {
 
   // Print Variable Bindings
   Out << "Variables:" << nl;
@@ -570,4 +573,9 @@
       }
     }
   }
+  
+  // Print checker-specific data.
+  
+  if (P && CheckerState)
+    P->PrintCheckerState(Out, CheckerState, nl, sep);
 }

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=48237&r1=48236&r2=48237&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Tue Mar 11 13:57:24 2008
@@ -30,27 +30,31 @@
   
   // Casts.
   
-  virtual RVal EvalCast(BasicValueFactory& BasicVals, NonLVal V, QualType CastT) =0;
-  virtual RVal EvalCast(BasicValueFactory& BasicVals, LVal V, QualType CastT) = 0;
+  virtual RVal EvalCast(BasicValueFactory& BasicVals, NonLVal V,
+                        QualType CastT) =0;
+  
+  virtual RVal EvalCast(BasicValueFactory& BasicVals, LVal V,
+                        QualType CastT) = 0;
 
   // Unary Operators.
   
-  virtual RVal EvalMinus(BasicValueFactory& BasicVals, UnaryOperator* U, NonLVal X) = 0;
+  virtual RVal EvalMinus(BasicValueFactory& BasicVals, UnaryOperator* U,
+                         NonLVal X) = 0;
 
   virtual RVal EvalComplement(BasicValueFactory& BasicVals, NonLVal X) = 0;
 
   // Binary Operators.
   
-  virtual RVal EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op,
-                         NonLVal L, NonLVal R) = 0;
+  virtual RVal EvalBinOp(BasicValueFactory& BasicVals,
+                         BinaryOperator::Opcode Op, NonLVal L, NonLVal R) = 0;
   
-  virtual RVal EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op,
-                         LVal L, LVal R) = 0;
+  virtual RVal EvalBinOp(BasicValueFactory& BasicVals,
+                         BinaryOperator::Opcode Op, LVal L, LVal R) = 0;
   
   // Pointer arithmetic.
   
-  virtual RVal EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op,
-                         LVal L, NonLVal R) = 0;
+  virtual RVal EvalBinOp(BasicValueFactory& BasicVals,
+                         BinaryOperator::Opcode Op, LVal L, NonLVal R) = 0;
   
   // Calls.
   

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ValueState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ValueState.h Tue Mar 11 13:57:24 2008
@@ -137,13 +137,20 @@
   typedef ConstEqTy::iterator ce_iterator;
   ce_iterator ce_begin() const { return ConstEq.begin(); }
   ce_iterator ce_end() const { return ConstEq.end(); }
+  
+  class CheckerStatePrinter {
+  public:
+    virtual ~CheckerStatePrinter() {}
+    virtual void PrintCheckerState(std::ostream& Out, void* State,
+                                   const char* nl, const char* sep) = 0;
+  };
 
-  void print(std::ostream& Out,
-             const char* nl = "\n",
-             const char* sep = "") const;
+  void print(std::ostream& Out, CheckerStatePrinter* P = NULL,
+             const char* nl = "\n", const char* sep = "") const;
+  
+  void printStdErr(CheckerStatePrinter* P = NULL) const;
   
-  void printStdErr() const { print(*llvm::cerr); }  
-  void printDOT(std::ostream& Out) const;
+  void printDOT(std::ostream& Out, CheckerStatePrinter*P = NULL) const;
 };  
   
 template<> struct GRTrait<ValueState*> {
@@ -154,7 +161,8 @@
     // add the pointer.
     profile.AddPointer(St);
   }
-};    
+};
+  
   
 class ValueStateManager {
 private:





More information about the cfe-commits mailing list