Expanded ValueState pretty-printing to use an optional "CheckerStatePrinter"

object to pretty-print the component of a state that is specific to a checker.

llvm-svn: 48237
This commit is contained in:
Ted Kremenek 2008-03-11 18:57:24 +00:00
parent a7178c7429
commit 827d0fcd57
3 changed files with 41 additions and 21 deletions

View 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);
}

View 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.

View File

@ -138,12 +138,19 @@ public:
ce_iterator ce_begin() const { return ConstEq.begin(); }
ce_iterator ce_end() const { return ConstEq.end(); }
void print(std::ostream& Out,
const char* nl = "\n",
const char* sep = "") const;
class CheckerStatePrinter {
public:
virtual ~CheckerStatePrinter() {}
virtual void PrintCheckerState(std::ostream& Out, void* State,
const char* nl, const char* sep) = 0;
};
void printStdErr() const { print(*llvm::cerr); }
void printDOT(std::ostream& Out) const;
void print(std::ostream& Out, CheckerStatePrinter* P = NULL,
const char* nl = "\n", const char* sep = "") const;
void printStdErr(CheckerStatePrinter* P = NULL) const;
void printDOT(std::ostream& Out, CheckerStatePrinter*P = NULL) const;
};
template<> struct GRTrait<ValueState*> {
@ -156,6 +163,7 @@ template<> struct GRTrait<ValueState*> {
}
};
class ValueStateManager {
private:
ValueState::IntSetTy::Factory ISetFactory;