Add sanity check
authorChris Lattner <sabre@nondot.org>
Tue, 4 Feb 2003 00:03:57 +0000 (00:03 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 4 Feb 2003 00:03:57 +0000 (00:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5489 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0126e2d44f8f99e4f806a794d81d1d3d9f11c346..c5e9396a16bc5523036318e21eae676e88f78d0c 100644 (file)
@@ -53,7 +53,10 @@ public:
   ~DSGraph();
 
   bool hasFunction() const { return Func != 0; }
-  Function &getFunction() const { return *Func; }
+  Function &getFunction() const {
+    assert(hasFunction() && "Cannot call getFunction on graph without a fn!");
+    return *Func;
+  }
 
   DSGraph *getGlobalsGraph() const { return GlobalsGraph; }
   void setGlobalsGraph(DSGraph *G) { GlobalsGraph = G; }
index 0126e2d44f8f99e4f806a794d81d1d3d9f11c346..c5e9396a16bc5523036318e21eae676e88f78d0c 100644 (file)
@@ -53,7 +53,10 @@ public:
   ~DSGraph();
 
   bool hasFunction() const { return Func != 0; }
-  Function &getFunction() const { return *Func; }
+  Function &getFunction() const {
+    assert(hasFunction() && "Cannot call getFunction on graph without a fn!");
+    return *Func;
+  }
 
   DSGraph *getGlobalsGraph() const { return GlobalsGraph; }
   void setGlobalsGraph(DSGraph *G) { GlobalsGraph = G; }
index 80c64d126c6cd7d136e3a68ab8e385080d8f7682..badc9c0801391a33e6018b012cd19bf6106d8f9f 100644 (file)
@@ -1029,6 +1029,7 @@ void DSGraph::removeDeadNodes(unsigned Flags) {
     if (AuxFCallsAlive[i])
       AuxFunctionCalls[CurIdx++].swap(AuxFunctionCalls[i]);
   if (!(Flags & DSGraph::RemoveUnreachableGlobals)) {
+    assert(GlobalsGraph && "No globals graph available??");
     // Move the unreachable call nodes to the globals graph...
     GlobalsGraph->AuxFunctionCalls.insert(GlobalsGraph->AuxFunctionCalls.end(),
                                           AuxFunctionCalls.begin()+CurIdx,