aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-13 19:31:57 +0000
committerChris Lattner <sabre@nondot.org>2002-10-13 19:31:57 +0000
commitf6c52db3715d53e195c5a7429987deba71ed0af7 (patch)
treeaf299db4683012ddffae309121b84fb41189bd75 /lib
parent2576aef32bf3653f053439cdfbd6e9d8e7220fc7 (diff)
downloadexternal_llvm-f6c52db3715d53e195c5a7429987deba71ed0af7.zip
external_llvm-f6c52db3715d53e195c5a7429987deba71ed0af7.tar.gz
external_llvm-f6c52db3715d53e195c5a7429987deba71ed0af7.tar.bz2
Halfway conversion from custom printing to GraphWriter printing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4146 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/DataStructure/Printer.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp
index 51ebe63..b7c2714 100644
--- a/lib/Analysis/DataStructure/Printer.cpp
+++ b/lib/Analysis/DataStructure/Printer.cpp
@@ -6,9 +6,11 @@
#include "llvm/Analysis/DataStructure.h"
#include "llvm/Analysis/DSGraph.h"
+#include "llvm/Analysis/DSGraphTraits.h"
#include "llvm/Module.h"
#include "llvm/Assembly/Writer.h"
#include "Support/CommandLine.h"
+#include "Support/GraphWriter.h"
#include <fstream>
#include <sstream>
using std::string;
@@ -165,6 +167,36 @@ void DSGraph::print(std::ostream &O) const {
O << "}\n";
}
+template<>
+struct DOTGraphTraits<DSGraph*> : public DefaultDOTGraphTraits {
+ static std::string getGraphName(DSGraph *G) {
+ if (G->hasFunction())
+ return "Function " + G->getFunction().getName();
+ else
+ return "Non-function graph";
+ }
+
+ static const char *getGraphProperties(DSGraph *G) {
+ return "\tnode [shape=Mrecord];\n"
+ "\tedge [arrowtail=\"dot\"];\n"
+ "\tsize=\"10,7.5\";\n"
+ "\trotate=\"90\";\n";
+ }
+
+ static std::string getNodeLabel(DSNode *Node, DSGraph *Graph) {
+ return getCaption(Node, Graph);
+ }
+
+ static std::string getNodeAttributes(DSNode *N) {
+ return "";//fontname=Courier";
+ }
+
+ //static int getEdgeSourceLabel(DSNode *Node, node_iterator I) {
+ // return MergeMap[i];
+ // }
+};
+
+
void DSGraph::writeGraphToFile(std::ostream &O, const string &GraphName) {
string Filename = GraphName + ".dot";
@@ -172,6 +204,7 @@ void DSGraph::writeGraphToFile(std::ostream &O, const string &GraphName) {
std::ofstream F(Filename.c_str());
if (F.good()) {
+ WriteGraph(F, this);
print(F);
O << " [" << getGraphSize() << "+" << getFunctionCalls().size() << "]\n";
} else {