diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-16 01:18:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-16 01:18:14 +0000 |
commit | 63a32de77680dd705d3f2788ea60021ecd4ad51e (patch) | |
tree | eeceb34acf0daf774e88c7f608314a75f864f025 /include/llvm/Support/GraphWriter.h | |
parent | d6d8f41699156686869ee3a0c04b4ba4c3081072 (diff) | |
download | external_llvm-63a32de77680dd705d3f2788ea60021ecd4ad51e.zip external_llvm-63a32de77680dd705d3f2788ea60021ecd4ad51e.tar.gz external_llvm-63a32de77680dd705d3f2788ea60021ecd4ad51e.tar.bz2 |
- Generic graph printing infrastructure changes:
* Only print outgoing edges from a cell if the destination isn't null.
This is important for DSGraphs, which have sources with no edges.
* Allow Node attributes to override shape of the node
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/GraphWriter.h')
-rw-r--r-- | include/llvm/Support/GraphWriter.h | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index fadff10..cae7345 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -69,9 +69,9 @@ std::ostream &WriteGraph(std::ostream &O, const GraphType &G) { std::string NodeAttributes = DOTTraits::getNodeAttributes(Node); - O << "\tNode" << (void*)Node << " ["; + O << "\tNode" << (void*)Node << " [shape=record,"; if (!NodeAttributes.empty()) O << NodeAttributes << ","; - O << "shape=record,label=\"{" + O << "label=\"{" << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G)); // Print out the fields of the current node... @@ -94,23 +94,24 @@ std::ostream &WriteGraph(std::ostream &O, const GraphType &G) { // Output all of the edges now EI = GTraits::child_begin(Node); for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { - NodeType *TargetNode = *EI; - O << "\tNode" << (void*)Node << ":g" << i << " -> Node" - << (void*)TargetNode; - if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { - typename GTraits::ChildIteratorType TargetIt = - DOTTraits::getEdgeTarget(Node, EI); - // Figure out which edge this targets... - unsigned Offset = std::distance(GTraits::child_begin(TargetNode), - TargetIt); - if (Offset > 64) Offset = 64; // Targetting the trancated part? - O << ":g" << Offset; + if (NodeType *TargetNode = *EI) { + O << "\tNode" << (void*)Node << ":g" << i << " -> Node" + << (void*)TargetNode; + if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { + typename GTraits::ChildIteratorType TargetIt = + DOTTraits::getEdgeTarget(Node, EI); + // Figure out which edge this targets... + unsigned Offset = std::distance(GTraits::child_begin(TargetNode), + TargetIt); + if (Offset > 64) Offset = 64; // Targetting the trancated part? + O << ":g" << Offset; + } + + std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI); + if (!EdgeAttributes.empty()) + O << "[" << EdgeAttributes << "]"; + O << ";\n"; } - - std::string EdgeAttributes = DOTTraits::getEdgeAttributes(Node, EI); - if (!EdgeAttributes.empty()) - O << "[" << EdgeAttributes << "]"; - O << ";\n"; } } |