[llvm-commits] [llvm] r53871 - /llvm/trunk/include/llvm/Support/GraphWriter.h
Dan Gohman
gohman at apple.com
Mon Jul 21 12:57:57 PDT 2008
Author: djg
Date: Mon Jul 21 14:57:57 2008
New Revision: 53871
URL: http://llvm.org/viewvc/llvm-project?rev=53871&view=rev
Log:
Make the GraphWriter be more consistent about the string
used for the graph "title" and the graph "label", as there
are differences in interpretation of these strings
between viewers.
Modified:
llvm/trunk/include/llvm/Support/GraphWriter.h
Modified: llvm/trunk/include/llvm/Support/GraphWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=53871&r1=53870&r2=53871&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/GraphWriter.h (original)
+++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon Jul 21 14:57:57 2008
@@ -85,7 +85,7 @@
std::string GraphName = DOTTraits::getGraphName(G);
if (!Name.empty())
- O << "digraph " << Name << " {\n";
+ O << "digraph \"" << DOT::EscapeString(Name) << "\" {\n";
else if (!GraphName.empty())
O << "digraph \"" << DOT::EscapeString(GraphName) << "\" {\n";
else
@@ -94,7 +94,9 @@
if (DOTTraits::renderGraphFromBottomUp())
O << "\trankdir=\"BT\";\n";
- if (!GraphName.empty())
+ if (!Name.empty())
+ O << "\tlabel=\"" << DOT::EscapeString(Name) << "\";\n";
+ else if (!GraphName.empty())
O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n";
O << DOTTraits::getGraphProperties(G);
O << "\n";
@@ -234,12 +236,13 @@
template<typename GraphType>
std::ostream &WriteGraph(std::ostream &O, const GraphType &G,
- const std::string &Name = "") {
+ const std::string &Name = "",
+ const std::string &Title = "") {
// Start the graph emission process...
GraphWriter<GraphType> W(O, G);
// Output the header for the graph...
- W.writeHeader(Name);
+ W.writeHeader(Title);
// Emit all of the nodes in the graph...
W.writeNodes();
@@ -273,24 +276,10 @@
std::ofstream O(Filename.c_str());
if (O.good()) {
- // Start the graph emission process...
- GraphWriter<GraphType> W(O, G);
-
- // Output the header for the graph...
- W.writeHeader(Title);
-
- // Emit all of the nodes in the graph...
- W.writeNodes();
-
- // Output any customizations on the graph
- DOTGraphTraits<GraphType>::addCustomGraphFeatures(G, W);
-
- // Output the end of the graph
- W.writeFooter();
+ WriteGraph(O, G, Name, Title);
cerr << " done. \n";
O.close();
-
} else {
cerr << "error opening file for writing!\n";
Filename.clear();
More information about the llvm-commits
mailing list