Added "Auditor" interface for auditing the construction of ExplodedGraphs.

llvm-svn: 55403
This commit is contained in:
Ted Kremenek 2008-08-27 01:56:11 +00:00
parent 6f7c419308
commit 912c28444f
2 changed files with 36 additions and 1 deletions

View File

@ -124,6 +124,18 @@ public:
bool isSink() const { return Succs.getFlag(); } bool isSink() const { return Succs.getFlag(); }
void markAsSink() { Succs.setFlag(); } void markAsSink() { Succs.setFlag(); }
// For debugging.
public:
class Auditor {
public:
virtual ~Auditor();
virtual void AddEdge(ExplodedNodeImpl* Src, ExplodedNodeImpl* Dst) = 0;
};
static void SetAuditor(Auditor* A);
}; };

View File

@ -22,6 +22,26 @@
using namespace clang; using namespace clang;
//===----------------------------------------------------------------------===//
// Node auditing.
//===----------------------------------------------------------------------===//
// An out of line virtual method to provide a home for the class vtable.
ExplodedNodeImpl::Auditor::~Auditor() {}
#ifndef NDEBUG
static ExplodedNodeImpl::Auditor* NodeAuditor = 0;
#endif
void ExplodedNodeImpl::SetAuditor(ExplodedNodeImpl::Auditor* A) {
#ifndef NDEBUG
NodeAuditor = A;
#endif
}
//===----------------------------------------------------------------------===//
// ExplodedNodeImpl.
//===----------------------------------------------------------------------===//
static inline std::vector<ExplodedNodeImpl*>& getVector(void* P) { static inline std::vector<ExplodedNodeImpl*>& getVector(void* P) {
return *reinterpret_cast<std::vector<ExplodedNodeImpl*>*>(P); return *reinterpret_cast<std::vector<ExplodedNodeImpl*>*>(P);
@ -31,6 +51,9 @@ void ExplodedNodeImpl::addPredecessor(ExplodedNodeImpl* V) {
assert (!V->isSink()); assert (!V->isSink());
Preds.addNode(V); Preds.addNode(V);
V->Succs.addNode(this); V->Succs.addNode(this);
#ifndef NDEBUG
if (NodeAuditor) NodeAuditor->AddEdge(V, this);
#endif
} }
void ExplodedNodeImpl::NodeGroup::addNode(ExplodedNodeImpl* N) { void ExplodedNodeImpl::NodeGroup::addNode(ExplodedNodeImpl* N) {