Fix uninitialized member problem
[oota-llvm.git] / include / llvm / Analysis / DataStructure / DSGraph.h
index 0126e2d44f8f99e4f806a794d81d1d3d9f11c346..eebefa5f5dd6dd451d21e16c20b2d6d1283e1fe9 100644 (file)
@@ -37,7 +37,8 @@ class DSGraph {
 
   void operator=(const DSGraph &); // DO NOT IMPLEMENT
 public:
-  DSGraph() : Func(0), GlobalsGraph(0) {}      // Create a new, empty, DSGraph.
+  // Create a new, empty, DSGraph.
+  DSGraph() : Func(0), GlobalsGraph(0), PrintAuxCalls(false) {}
   DSGraph(Function &F, DSGraph *GlobalsGraph); // Compute the local DSGraph
 
   // Copy ctor - If you want to capture the node mapping between the source and
@@ -53,7 +54,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; }
@@ -115,8 +119,17 @@ public:
     return Nodes.size();
   }
 
+  /// print - Print a dot graph to the specified ostream...
   void print(std::ostream &O) const;
+
+  /// dump - call print(std::cerr), for use from the debugger...
+  ///
   void dump() const;
+
+  /// viewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
+  /// then cleanup.  For use from the debugger.
+  void viewGraph() const;
+
   void writeGraphToFile(std::ostream &O, const std::string &GraphName) const;
 
   /// maskNodeTypes - Apply a mask to all of the node types in the graph.  This
@@ -139,6 +152,7 @@ public:
   //
   enum MarkIncompleteFlags {
     MarkFormalArgs = 1, IgnoreFormalArgs = 0,
+    IgnoreGlobals = 2, MarkGlobalsIncomplete = 0,
   };
   void markIncompleteNodes(unsigned Flags);
 
@@ -181,7 +195,7 @@ public:
   void mergeInGraph(DSCallSite &CS, const DSGraph &Graph, unsigned CloneFlags);
 
   // Methods for checking to make sure graphs are well formed...
-  void AssertNodeInGraph(DSNode *N) const {
+  void AssertNodeInGraph(const DSNode *N) const {
     assert((!N || find(Nodes.begin(), Nodes.end(), N) != Nodes.end()) &&
            "AssertNodeInGraph: Node is not in graph!");
   }
@@ -191,7 +205,8 @@ public:
   }
 
   void AssertCallSiteInGraph(const DSCallSite &CS) const {
-    AssertNodeInGraph(CS.getCallee().getNode());
+    if (CS.isIndirectCall())
+      AssertNodeInGraph(CS.getCalleeNode());
     AssertNodeInGraph(CS.getRetVal().getNode());
     for (unsigned j = 0, e = CS.getNumPtrArgs(); j != e; ++j)
       AssertNodeInGraph(CS.getPtrArg(j).getNode());