diff --git a/include/Support/DOTGraphTraits.h b/include/Support/DOTGraphTraits.h index ca7c463f1c7..42f9af24c61 100644 --- a/include/Support/DOTGraphTraits.h +++ b/include/Support/DOTGraphTraits.h @@ -60,6 +60,15 @@ struct DefaultDOTGraphTraits { /// edge. template static EdgeIter getEdgeTarget(void *Node, EdgeIter I) { return I; } + + /// addCustomGraphFeatures - If a graph is made up of more than just + /// straight-forward nodes and edges, this is the place to put all of the + /// custom stuff neccesary. The GraphWriter object, instantiated with your + /// GraphType is passed in as an argument. You may call arbitrary methods on + /// it to add things to the output graph. + /// + template + static void addCustomGraphFeatures(void *Graph, GraphWriter &GW) {} }; diff --git a/include/Support/GraphWriter.h b/include/Support/GraphWriter.h index 0a7576cd7c5..7783b468087 100644 --- a/include/Support/GraphWriter.h +++ b/include/Support/GraphWriter.h @@ -72,7 +72,11 @@ public: O << DOTTraits::getGraphProperties(G); O << "\n"; + // Emit all of the nodes in the graph... writeNodes(); + + // Output any customizations on the graph + DOTTraits::addCustomGraphFeatures(G, *this); } ~GraphWriter() { diff --git a/include/llvm/Support/DOTGraphTraits.h b/include/llvm/Support/DOTGraphTraits.h index ca7c463f1c7..42f9af24c61 100644 --- a/include/llvm/Support/DOTGraphTraits.h +++ b/include/llvm/Support/DOTGraphTraits.h @@ -60,6 +60,15 @@ struct DefaultDOTGraphTraits { /// edge. template static EdgeIter getEdgeTarget(void *Node, EdgeIter I) { return I; } + + /// addCustomGraphFeatures - If a graph is made up of more than just + /// straight-forward nodes and edges, this is the place to put all of the + /// custom stuff neccesary. The GraphWriter object, instantiated with your + /// GraphType is passed in as an argument. You may call arbitrary methods on + /// it to add things to the output graph. + /// + template + static void addCustomGraphFeatures(void *Graph, GraphWriter &GW) {} }; diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index 0a7576cd7c5..7783b468087 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -72,7 +72,11 @@ public: O << DOTTraits::getGraphProperties(G); O << "\n"; + // Emit all of the nodes in the graph... writeNodes(); + + // Output any customizations on the graph + DOTTraits::addCustomGraphFeatures(G, *this); } ~GraphWriter() {