[analyzer] Dump reproducible identifiers for statements in exploded graph in store

Differential Revision: https://reviews.llvm.org/D51826

llvm-svn: 342313
This commit is contained in:
George Karpenkov 2018-09-15 02:03:17 +00:00
parent 141b448ee9
commit fc042f95e2
4 changed files with 18 additions and 12 deletions

View File

@ -93,6 +93,7 @@ public:
}
void print(raw_ostream &Out, const char *NL, const char *Sep,
const ASTContext &Context,
const LocationContext *WithLC = nullptr) const;
};

View File

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

View File

@ -3109,7 +3109,7 @@ struct DOTGraphTraits<ExplodedNode*> : 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<ExplodedNode*> : public DefaultDOTGraphTraits {
static_cast<ExprEngine *>(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) {

View File

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