]> granicus.if.org Git - clang/commitdiff
Expanded ValueState pretty-printing to use an optional "CheckerStatePrinter"
authorTed Kremenek <kremenek@apple.com>
Tue, 11 Mar 2008 18:57:24 +0000 (18:57 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 11 Mar 2008 18:57:24 +0000 (18:57 +0000)
object to pretty-print the component of a state that is specific to a checker.

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

Analysis/ValueState.cpp
include/clang/Analysis/PathSensitive/GRTransferFuncs.h
include/clang/Analysis/PathSensitive/ValueState.h

index 1d428f199b21f32aa78aaa4fc33c172c37cbd143..1fc4df9128e2d341973ca02ec93d9c99986f88e3 100644 (file)
@@ -476,13 +476,16 @@ ValueState* ValueStateManager::getPersistentState(ValueState& State) {
   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 @@ void ValueState::print(std::ostream& Out,
       }
     }
   }
+  
+  // Print checker-specific data.
+  
+  if (P && CheckerState)
+    P->PrintCheckerState(Out, CheckerState, nl, sep);
 }
index 4e020ba71bb75ea5bcff3c42c476047ee1f58c3a..256cadd945c6f71b0046518adf5ccc7b577c0416 100644 (file)
@@ -30,27 +30,31 @@ public:
   
   // 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.
   
index 8cd8f511e82b326ec9d78c00093d18a9624477b0..1a6ad38a9e1c65af0701ba8842a98b4b882e77e1 100644 (file)
@@ -137,13 +137,20 @@ public:
   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 @@ template<> struct GRTrait<ValueState*> {
     // add the pointer.
     profile.AddPointer(St);
   }
-};    
+};
+  
   
 class ValueStateManager {
 private: