From: George Karpenkov Date: Sat, 15 Sep 2018 02:03:17 +0000 (+0000) Subject: [analyzer] Dump reproducible identifiers for statements in exploded graph in store X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d1cca44581e8de3ef829873541bd45c9918b846;p=clang [analyzer] Dump reproducible identifiers for statements in exploded graph in store Differential Revision: https://reviews.llvm.org/D51826 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342313 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h b/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h index 77e3539807..6d498031be 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h @@ -93,6 +93,7 @@ public: } void print(raw_ostream &Out, const char *NL, const char *Sep, + const ASTContext &Context, const LocationContext *WithLC = nullptr) const; }; diff --git a/lib/StaticAnalyzer/Core/Environment.cpp b/lib/StaticAnalyzer/Core/Environment.cpp index eccaee292c..5f1a37c8d6 100644 --- a/lib/StaticAnalyzer/Core/Environment.cpp +++ b/lib/StaticAnalyzer/Core/Environment.cpp @@ -202,7 +202,9 @@ EnvironmentManager::removeDeadBindings(Environment Env, } void Environment::print(raw_ostream &Out, const char *NL, - const char *Sep, const LocationContext *WithLC) const { + const char *Sep, + const ASTContext &Context, + const LocationContext *WithLC) const { if (ExprBindings.isEmpty()) return; @@ -222,8 +224,7 @@ void Environment::print(raw_ostream &Out, const char *NL, assert(WithLC); - LangOptions LO; // FIXME. - PrintingPolicy PP(LO); + PrintingPolicy PP = Context.getPrintingPolicy(); Out << NL << NL << "Expressions by stack frame:" << NL; WithLC->dumpStack(Out, "", NL, Sep, [&](const LocationContext *LC) { @@ -234,8 +235,9 @@ void Environment::print(raw_ostream &Out, const char *NL, const Stmt *S = I.first.getStmt(); assert(S != nullptr && "Expected non-null Stmt"); - Out << "(" << (const void *)LC << ',' << (const void *)S << ") "; - S->printPretty(Out, nullptr, PP); + Out << "(LC" << (const void *)LC << ", S" << S->getID(Context) << " <" + << (const void *)S << "> ) "; + S->printPretty(Out, /*Helper=*/nullptr, PP); Out << " : " << I.second << NL; } }); diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index b8ec06e9b9..a0cb43284d 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -3109,7 +3109,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { assert(S != nullptr && "Expecting non-null Stmt"); Out << S->getStmtClassName() << ' ' - << S->getID(Context) << " (" << (const void *)S << ") "; + << S->getID(Context) << " <" << (const void *)S << "> "; S->printPretty(Out, /*helper=*/nullptr, Context.getPrintingPolicy(), /*Indentation=*/2, /*NewlineSymbol=*/"\\l"); printLocation(Out, S->getBeginLoc()); @@ -3171,9 +3171,9 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { static_cast(State->getStateManager().getOwningEngine()) ->getGraph(); - Out << "StateID: " << State->getID() << " (" << (const void *)State.get() - << ")" - << " NodeID: " << N->getID(&Graph) << " (" << (const void *)N << ")\\|"; + Out << "StateID: " << State->getID() << " <" << (const void *)State.get() + << ">" + << " NodeID: " << N->getID(&Graph) << " <" << (const void *)N << ">\\|"; bool SameAsAllPredecessors = std::all_of(N->pred_begin(), N->pred_end(), [&](const ExplodedNode *P) { diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp index 361255b4b1..01c1c8c618 100644 --- a/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -456,14 +456,16 @@ void ProgramState::setStore(const StoreRef &newStore) { // State pretty-printing. //===----------------------------------------------------------------------===// -void ProgramState::print(raw_ostream &Out, const char *NL, const char *Sep, +void ProgramState::print(raw_ostream &Out, + const char *NL, const char *Sep, const LocationContext *LC) const { // Print the store. ProgramStateManager &Mgr = getStateManager(); + const ASTContext &Context = getStateManager().getContext(); Mgr.getStoreManager().print(getStore(), Out, NL, Sep); // Print out the environment. - Env.print(Out, NL, Sep, LC); + Env.print(Out, NL, Sep, Context, LC); // Print out the constraints. Mgr.getConstraintManager().print(this, Out, NL, Sep); @@ -478,7 +480,8 @@ void ProgramState::print(raw_ostream &Out, const char *NL, const char *Sep, Mgr.getOwningEngine()->printState(Out, this, NL, Sep, LC); } -void ProgramState::printDOT(raw_ostream &Out, const LocationContext *LC) const { +void ProgramState::printDOT(raw_ostream &Out, + const LocationContext *LC) const { print(Out, "\\l", "\\|", LC); }