[analyzer] Dump a reproducible, deterministic ID of program state to exploded graph

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341600 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
George Karpenkov 2018-09-06 23:07:26 +00:00
parent cdacbfee79
commit cc7b7584b5
3 changed files with 11 additions and 1 deletions

View File

@ -107,6 +107,8 @@ public:
~ProgramState();
int64_t getID() const;
/// Return the ProgramStateManager associated with this state.
ProgramStateManager &getStateManager() const {
return *stateMgr;

View File

@ -3141,7 +3141,8 @@ struct DOTGraphTraits<ExplodedNode*> : public DefaultDOTGraphTraits {
}
ProgramStateRef state = N->getState();
Out << "\\|StateID: " << (const void*) state.get()
Out << "\\|StateID: " << state->getID() << " ("
<< (const void*) state.get() << ")"
<< " NodeID: " << (const void*) N << "\\|";
state->printDOT(Out, N->getLocationContext());

View File

@ -69,6 +69,13 @@ ProgramState::~ProgramState() {
stateMgr->getStoreManager().decrementReferenceCount(store);
}
int64_t ProgramState::getID() const {
Optional<int64_t> Out = getStateManager().Alloc.identifyObject(this);
assert(Out && "Wrong allocator used");
assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
return *Out / alignof(ProgramState);
}
ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
StoreManagerCreator CreateSMgr,
ConstraintManagerCreator CreateCMgr,