diff --git a/clang/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/clang/include/clang/Analysis/PathSensitive/ExplodedGraph.h index c85d1e9107a8..3406d178dd7d 100644 --- a/clang/include/clang/Analysis/PathSensitive/ExplodedGraph.h +++ b/clang/include/clang/Analysis/PathSensitive/ExplodedGraph.h @@ -123,7 +123,19 @@ public: bool pred_empty() const { return Preds.empty(); } 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); }; diff --git a/clang/lib/Analysis/ExplodedGraph.cpp b/clang/lib/Analysis/ExplodedGraph.cpp index 0835944250fd..945416b1b56e 100644 --- a/clang/lib/Analysis/ExplodedGraph.cpp +++ b/clang/lib/Analysis/ExplodedGraph.cpp @@ -22,6 +22,26 @@ 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& getVector(void* P) { return *reinterpret_cast*>(P); @@ -31,6 +51,9 @@ void ExplodedNodeImpl::addPredecessor(ExplodedNodeImpl* V) { assert (!V->isSink()); Preds.addNode(V); V->Succs.addNode(this); +#ifndef NDEBUG + if (NodeAuditor) NodeAuditor->AddEdge(V, this); +#endif } void ExplodedNodeImpl::NodeGroup::addNode(ExplodedNodeImpl* N) {