Add new method
authorChris Lattner <sabre@nondot.org>
Mon, 30 Jun 2003 05:57:30 +0000 (05:57 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 30 Jun 2003 05:57:30 +0000 (05:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7007 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c08d404cea9c10598128673352ccd8f20b47444f..81979cf74ec28216c5165d19cdf6e49c15aaeaec 100644 (file)
@@ -80,6 +80,10 @@ public:
   const std::vector<DSNode*> &getNodes() const { return Nodes; }
         std::vector<DSNode*> &getNodes()       { return Nodes; }
 
+  /// getFunctionNames - Return a space separated list of the name of the
+  /// functions in this graph (if any)
+  std::string getFunctionNames() const;
+
   /// addNode - Add a new node to the graph.
   ///
   void addNode(DSNode *N) { Nodes.push_back(N); }
index c08d404cea9c10598128673352ccd8f20b47444f..81979cf74ec28216c5165d19cdf6e49c15aaeaec 100644 (file)
@@ -80,6 +80,10 @@ public:
   const std::vector<DSNode*> &getNodes() const { return Nodes; }
         std::vector<DSNode*> &getNodes()       { return Nodes; }
 
+  /// getFunctionNames - Return a space separated list of the name of the
+  /// functions in this graph (if any)
+  std::string getFunctionNames() const;
+
   /// addNode - Add a new node to the graph.
   ///
   void addNode(DSNode *N) { Nodes.push_back(N); }
index fbd223f71b0afab339ede831ea9766aea275df96..cd73acbc7c796f1a5bfadc784c66166151fb161e 100644 (file)
@@ -703,6 +703,23 @@ Function &DSCallSite::getCaller() const {
 // DSGraph Implementation
 //===----------------------------------------------------------------------===//
 
+/// getFunctionNames - Return a space separated list of the name of the
+/// functions in this graph (if any)
+std::string DSGraph::getFunctionNames() const {
+  switch (getReturnNodes().size()) {
+  case 0: return "Globals graph";
+  case 1: return getReturnNodes().begin()->first->getName();
+  default:
+    std::string Return;
+    for (DSGraph::ReturnNodesTy::const_iterator I = getReturnNodes().begin();
+         I != getReturnNodes().end(); ++I)
+      Return += I->first->getName() + " ";
+    Return.erase(Return.end()-1, Return.end());   // Remove last space character
+    return Return;
+  }
+}
+
+
 DSGraph::DSGraph(const DSGraph &G) : GlobalsGraph(0) {
   PrintAuxCalls = false;
   NodeMapTy NodeMap;