From: Ted Kremenek Date: Tue, 4 Mar 2008 18:30:35 +0000 (+0000) Subject: Implemented "print" method for ValueState. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59894f9d4560021b12ff3e0207ae6046bc3b050a;p=clang Implemented "print" method for ValueState. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47894 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/ValueState.cpp b/Analysis/ValueState.cpp index dac9211030..388dba67da 100644 --- a/Analysis/ValueState.cpp +++ b/Analysis/ValueState.cpp @@ -486,16 +486,22 @@ ValueState* ValueStateManager::getPersistentState(ValueState& State) { } void ValueState::printDOT(std::ostream& Out) const { + print(Out, "\\l", "\\|"); +} + +void ValueState::print(std::ostream& Out, + const char* nl, + const char* sep) const { // Print Variable Bindings - Out << "Variables:\\l"; + Out << "Variables:" << nl; bool isFirst = true; for (vb_iterator I = vb_begin(), E = vb_end(); I != E; ++I) { if (isFirst) isFirst = false; - else Out << "\\l"; + else Out << nl; Out << ' ' << I.getKey()->getName() << " : "; I.getData().print(Out); @@ -508,10 +514,10 @@ void ValueState::printDOT(std::ostream& Out) const { for (seb_iterator I = seb_begin(), E = seb_end(); I != E; ++I) { if (isFirst) { - Out << "\\l\\lSub-Expressions:\\l"; + Out << nl << nl << "Sub-Expressions:" << nl; isFirst = false; } - else { Out << "\\l"; } + else { Out << nl; } Out << " (" << (void*) I.getKey() << ") "; I.getKey()->printPretty(Out); @@ -526,10 +532,10 @@ void ValueState::printDOT(std::ostream& Out) const { for (beb_iterator I = beb_begin(), E = beb_end(); I != E; ++I) { if (isFirst) { - Out << "\\l\\lBlock-level Expressions:\\l"; + Out << nl << nl << "Block-level Expressions:" << nl; isFirst = false; } - else { Out << "\\l"; } + else { Out << nl; } Out << " (" << (void*) I.getKey() << ") "; I.getKey()->printPretty(Out); @@ -541,12 +547,12 @@ void ValueState::printDOT(std::ostream& Out) const { if (!ConstEq.isEmpty()) { - Out << "\\l\\|'==' constraints:"; + Out << nl << sep << "'==' constraints:"; for (ConstEqTy::iterator I = ConstEq.begin(), E = ConstEq.end(); I!=E; ++I) { - Out << "\\l $" << I.getKey() + Out << nl << " $" << I.getKey() << " : " << I.getData()->toString(); } } @@ -555,12 +561,12 @@ void ValueState::printDOT(std::ostream& Out) const { if (!ConstNotEq.isEmpty()) { - Out << "\\l\\|'!=' constraints:"; + Out << nl << sep << "'!=' constraints:"; for (ConstNotEqTy::iterator I = ConstNotEq.begin(), EI = ConstNotEq.end(); I != EI; ++I) { - Out << "\\l $" << I.getKey() << " : "; + Out << nl << " $" << I.getKey() << " : "; isFirst = true; IntSetTy::iterator J = I.getData().begin(), EJ = I.getData().end(); diff --git a/include/clang/Analysis/PathSensitive/ValueState.h b/include/clang/Analysis/PathSensitive/ValueState.h index fd0b1ef1b0..73c4706db1 100644 --- a/include/clang/Analysis/PathSensitive/ValueState.h +++ b/include/clang/Analysis/PathSensitive/ValueState.h @@ -133,10 +133,13 @@ public: typedef ConstEqTy::iterator ce_iterator; 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; - void printDOT(std::ostream& Out) const; - void print(std::ostream& Out) const; void printStdErr() const { print(*llvm::cerr); } + void printDOT(std::ostream& Out) const; }; template<> struct GRTrait {