Add an isNodeHidden to the graph traits, to support definition of
authorDan Gohman <gohman@apple.com>
Fri, 14 May 2010 15:29:31 +0000 (15:29 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 14 May 2010 15:29:31 +0000 (15:29 +0000)
subgraph views.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103772 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/DOTGraphTraits.h
include/llvm/Support/GraphWriter.h

index ebbcf7c400e965cd330c9eadcca9ef55fd38c9a1..c16aa3a76d6f9ceefc5d4f267ea097cc4ad4c1f3 100644 (file)
@@ -59,6 +59,12 @@ public:
     return false;
   }
 
+  /// isNodeHidden - If thie function returns true, the given node is not
+  /// displayed in the graph.
+  static bool isNodeHidden(const void *Node) {
+    return false;
+  }
+
   /// getNodeLabel - Given a node and a pointer to the top level graph, return
   /// the label to print in the node.
   template<typename GraphType>
index 13e6682ebfd67373c3b582e5efccf931ee440fcd..559f0040c2d9dc099e9b9b97ca4c3d728a75029c 100644 (file)
@@ -122,7 +122,20 @@ public:
     // Loop over the graph, printing it out...
     for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G);
          I != E; ++I)
-      writeNode(*I);
+      if (!isNodeHidden(*I))
+        writeNode(*I);
+  }
+
+  bool isNodeHidden(NodeType &Node) {
+    return isNodeHidden(&Node);
+  }
+
+  bool isNodeHidden(NodeType *const *Node) {
+    return isNodeHidden(*Node);
+  }
+
+  bool isNodeHidden(NodeType *Node) {
+    return DTraits.isNodeHidden(Node);
   }
 
   void writeNode(NodeType& Node) {
@@ -189,9 +202,11 @@ public:
     child_iterator EI = GTraits::child_begin(Node);
     child_iterator EE = GTraits::child_end(Node);
     for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i)
-      writeEdge(Node, i, EI);
+      if (!DTraits.isNodeHidden(*EI))
+        writeEdge(Node, i, EI);
     for (; EI != EE; ++EI)
-      writeEdge(Node, 64, EI);
+      if (!DTraits.isNodeHidden(*EI))
+        writeEdge(Node, 64, EI);
   }
 
   void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) {