diff options
author | Anna Zaks <ganna@apple.com> | 2011-12-05 18:58:08 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-12-05 18:58:08 +0000 |
commit | f784d08d25763ec5cf6b419b98697a9b256039d2 (patch) | |
tree | 377ceab5b7e808537112fed7e1fda8aa34cc628b /clang/lib/StaticAnalyzer/Core/ProgramState.cpp | |
parent | 1c215d0a11805f95092bdc9fb5309c5c5b683bff (diff) | |
download | bcm5719-llvm-f784d08d25763ec5cf6b419b98697a9b256039d2.tar.gz bcm5719-llvm-f784d08d25763ec5cf6b419b98697a9b256039d2.zip |
[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.
llvm-svn: 145828
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ProgramState.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ProgramState.cpp | 94 |
1 files changed, 58 insertions, 36 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp index 07f76c585f8..a93b5bfd645 100644 --- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/clang/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); } //===----------------------------------------------------------------------===// |