[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Printer.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Oct 13 14:33:01 PDT 2002
Changes in directory llvm/lib/Analysis/DataStructure:
Printer.cpp updated: 1.12 -> 1.13
---
Log message:
Halfway conversion from custom printing to GraphWriter printing
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/Printer.cpp
diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.12 llvm/lib/Analysis/DataStructure/Printer.cpp:1.13
--- llvm/lib/Analysis/DataStructure/Printer.cpp:1.12 Thu Oct 3 16:55:13 2002
+++ llvm/lib/Analysis/DataStructure/Printer.cpp Sun Oct 13 14:31:57 2002
@@ -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 @@
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 @@
std::ofstream F(Filename.c_str());
if (F.good()) {
+ WriteGraph(F, this);
print(F);
O << " [" << getGraphSize() << "+" << getFunctionCalls().size() << "]\n";
} else {
More information about the llvm-commits
mailing list