[PATCH] D51395: [analyzer] Dump a reproducible, deterministic ID of program state to exploded graph
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 28 17:31:34 PDT 2018
george.karpenkov created this revision.
george.karpenkov added reviewers: dcoughlin, NoQ.
Herald added subscribers: Szelethus, mikhail.ramalho, a.sidorin, mgrang, szepet, baloghadamsoftware, xazax.hun.
https://reviews.llvm.org/D51395
Files:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ProgramState.cpp
Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -69,6 +69,17 @@
stateMgr->getStoreManager().decrementReferenceCount(store);
}
+std::pair<size_t, long> ProgramState::getID() const {
+ auto Out = getStateManager().Alloc.identifyObject(this);
+ return *Out;
+}
+
+void ProgramState::dumpID(llvm::raw_ostream &Out) const {
+ auto P = getID();
+ assert(P.second % alignof(ProgramState) == 0 && "Unexpected offset");
+ Out << "(" << P.first << ", " << (P.second / alignof(ProgramState)) << ")";
+}
+
ProgramStateManager::ProgramStateManager(ASTContext &Ctx,
StoreManagerCreator CreateSMgr,
ConstraintManagerCreator CreateCMgr,
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3129,8 +3129,9 @@
}
ProgramStateRef state = N->getState();
- Out << "\\|StateID: " << (const void*) state.get()
- << " NodeID: " << (const void*) N << "\\|";
+ Out << "\\|StateID: ";
+ state->dumpID(Out);
+ Out << " NodeID: " << (const void*) N << "\\|";
state->printDOT(Out, N->getLocationContext());
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -107,6 +107,12 @@
~ProgramState();
+ /// Get a pair of numbers uniquely identifying the state.
+ std::pair<size_t, long> getID() const;
+
+ /// Dump a unique ID to a given stream.
+ void dumpID(llvm::raw_ostream &Out) const;
+
/// Return the ProgramStateManager associated with this state.
ProgramStateManager &getStateManager() const {
return *stateMgr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51395.162996.patch
Type: text/x-patch
Size: 2132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180829/de039296/attachment-0001.bin>
More information about the cfe-commits
mailing list