* Add a bunch of stuff for checking the integrity of the graph
authorChris Lattner <sabre@nondot.org>
Mon, 3 Feb 2003 19:10:24 +0000 (19:10 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 3 Feb 2003 19:10:24 +0000 (19:10 +0000)
* remove the isNodeDead method

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5474 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DSGraph.h
include/llvm/Analysis/DataStructure/DSGraph.h

index daab1195b360d7e934179274d8449c3738182a8e..0126e2d44f8f99e4f806a794d81d1d3d9f11c346 100644 (file)
@@ -180,8 +180,33 @@ public:
   ///
   void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, unsigned CloneFlags);
 
-private:
-  bool isNodeDead(DSNode *N);
+  // Methods for checking to make sure graphs are well formed...
+  void AssertNodeInGraph(DSNode *N) const {
+    assert((!N || find(Nodes.begin(), Nodes.end(), N) != Nodes.end()) &&
+           "AssertNodeInGraph: Node is not in graph!");
+  }
+  void AssertNodeContainsGlobal(const DSNode *N, GlobalValue *GV) const {
+    assert(std::find(N->getGlobals().begin(), N->getGlobals().end(), GV) !=
+           N->getGlobals().end() && "Global value not in node!");
+  }
+
+  void AssertCallSiteInGraph(const DSCallSite &CS) const {
+    AssertNodeInGraph(CS.getCallee().getNode());
+    AssertNodeInGraph(CS.getRetVal().getNode());
+    for (unsigned j = 0, e = CS.getNumPtrArgs(); j != e; ++j)
+      AssertNodeInGraph(CS.getPtrArg(j).getNode());
+  }
+
+  void AssertCallNodesInGraph() const {
+    for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i)
+      AssertCallSiteInGraph(FunctionCalls[i]);
+  }
+  void AssertAuxCallNodesInGraph() const {
+    for (unsigned i = 0, e = AuxFunctionCalls.size(); i != e; ++i)
+      AssertCallSiteInGraph(AuxFunctionCalls[i]);
+  }
+
+  void AssertGraphOK() const;
 
 public:
   // removeTriviallyDeadNodes - After the graph has been constructed, this
index daab1195b360d7e934179274d8449c3738182a8e..0126e2d44f8f99e4f806a794d81d1d3d9f11c346 100644 (file)
@@ -180,8 +180,33 @@ public:
   ///
   void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, unsigned CloneFlags);
 
-private:
-  bool isNodeDead(DSNode *N);
+  // Methods for checking to make sure graphs are well formed...
+  void AssertNodeInGraph(DSNode *N) const {
+    assert((!N || find(Nodes.begin(), Nodes.end(), N) != Nodes.end()) &&
+           "AssertNodeInGraph: Node is not in graph!");
+  }
+  void AssertNodeContainsGlobal(const DSNode *N, GlobalValue *GV) const {
+    assert(std::find(N->getGlobals().begin(), N->getGlobals().end(), GV) !=
+           N->getGlobals().end() && "Global value not in node!");
+  }
+
+  void AssertCallSiteInGraph(const DSCallSite &CS) const {
+    AssertNodeInGraph(CS.getCallee().getNode());
+    AssertNodeInGraph(CS.getRetVal().getNode());
+    for (unsigned j = 0, e = CS.getNumPtrArgs(); j != e; ++j)
+      AssertNodeInGraph(CS.getPtrArg(j).getNode());
+  }
+
+  void AssertCallNodesInGraph() const {
+    for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i)
+      AssertCallSiteInGraph(FunctionCalls[i]);
+  }
+  void AssertAuxCallNodesInGraph() const {
+    for (unsigned i = 0, e = AuxFunctionCalls.size(); i != e; ++i)
+      AssertCallSiteInGraph(AuxFunctionCalls[i]);
+  }
+
+  void AssertGraphOK() const;
 
 public:
   // removeTriviallyDeadNodes - After the graph has been constructed, this