aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/ProgramState.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-12-05 18:58:08 +0000
committerAnna Zaks <ganna@apple.com>2011-12-05 18:58:08 +0000
commitd0167853f46cc78787b06255a44f9dcedd04a8ec (patch)
treeb13fbc4f94bbf397eeacfdb91bf83441131e6fd7 /lib/StaticAnalyzer/Core/ProgramState.cpp
parenta50b7ab5af79690855af68f1fff7897291ba9535 (diff)
[analyzer] Add ability to do a simple ProgramState dump() without
requiring CFG. Adding more ugly code; the evnvironment printing should be moved to envirnment at some point. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145828 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ProgramState.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/ProgramState.cpp94
1 files changed, 58 insertions, 36 deletions
diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp
index 07f76c585f..a93b5bfd64 100644
--- a/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ b/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -385,53 +385,71 @@ static bool IsEnvLoc(const Stmt *S) {
return (bool) (((uintptr_t) S) & 0x1);
}
-void ProgramState::print(raw_ostream &Out, CFG &C,
+void ProgramState::print(raw_ostream &Out, CFG *C,
const char *NL, const char *Sep) const {
// Print the store.
ProgramStateManager &Mgr = getStateManager();
Mgr.getStoreManager().print(getStore(), Out, NL, Sep);
-
- // Print Subexpression bindings.
bool isFirst = true;
// FIXME: All environment printing should be moved inside Environment.
- for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
- if (C.isBlkExpr(I.getKey()) || IsEnvLoc(I.getKey()))
- continue;
+ if (C) {
+ // Print Subexpression bindings.
+ for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
+ if (C->isBlkExpr(I.getKey()) || IsEnvLoc(I.getKey()))
+ continue;
+
+ if (isFirst) {
+ Out << NL << NL << "Sub-Expressions:" << NL;
+ isFirst = false;
+ } else {
+ Out << NL;
+ }
- if (isFirst) {
- Out << NL << NL << "Sub-Expressions:" << NL;
- isFirst = false;
- } else {
- Out << NL;
+ Out << " (" << (void*) I.getKey() << ") ";
+ LangOptions LO; // FIXME.
+ I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
+ Out << " : " << I.getData();
}
- Out << " (" << (void*) I.getKey() << ") ";
- LangOptions LO; // FIXME.
- I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
- Out << " : " << I.getData();
- }
-
- // Print block-expression bindings.
- isFirst = true;
-
- for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
- if (!C.isBlkExpr(I.getKey()))
- continue;
+ // Print block-expression bindings.
+ isFirst = true;
+ for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
+ if (!C->isBlkExpr(I.getKey()))
+ continue;
+
+ if (isFirst) {
+ Out << NL << NL << "Block-level Expressions:" << NL;
+ isFirst = false;
+ } else {
+ Out << NL;
+ }
- if (isFirst) {
- Out << NL << NL << "Block-level Expressions:" << NL;
- isFirst = false;
- } else {
- Out << NL;
+ Out << " (" << (void*) I.getKey() << ") ";
+ LangOptions LO; // FIXME.
+ I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
+ Out << " : " << I.getData();
}
+ } else {
+ // Print All bindings - no info to differentiate block from subexpressions.
+ for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
+ if (IsEnvLoc(I.getKey()))
+ continue;
+
+ if (isFirst) {
+ Out << NL << NL << "Expressions:" << NL;
+ isFirst = false;
+ } else {
+ Out << NL;
+ }
- Out << " (" << (void*) I.getKey() << ") ";
- LangOptions LO; // FIXME.
- I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
- Out << " : " << I.getData();
+ Out << " (" << (void*) I.getKey() << ") ";
+ LangOptions LO; // FIXME.
+ I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
+ Out << " : " << I.getData();
+ }
}
-
+
// Print locations.
isFirst = true;
@@ -461,11 +479,15 @@ void ProgramState::print(raw_ostream &Out, CFG &C,
}
void ProgramState::printDOT(raw_ostream &Out, CFG &C) const {
- print(Out, C, "\\l", "\\|");
+ print(Out, &C, "\\l", "\\|");
+}
+
+void ProgramState::dump(CFG &C) const {
+ print(llvm::errs(), &C);
}
-void ProgramState::printStdErr(CFG &C) const {
- print(llvm::errs(), C);
+void ProgramState::dump() const {
+ print(llvm::errs(), 0);
}
//===----------------------------------------------------------------------===//