If the basic block has no name, make sure to print the % number of it
authorChris Lattner <sabre@nondot.org>
Wed, 22 Oct 2003 16:22:42 +0000 (16:22 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 22 Oct 2003 16:22:42 +0000 (16:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9375 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFGPrinter.cpp

index bb2912b060e4885bb3ce6315a8cabf23b58e8d19..4d6819d4fa4d67c16cc22a57fab7ab6307e882bd 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Function.h"
 #include "llvm/iTerminators.h"
+#include "llvm/Assembly/Writer.h"
 #include "llvm/Support/CFG.h"
 #include <sstream>
 #include <fstream>
@@ -39,9 +40,14 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
 
   static std::string getNodeLabel(const BasicBlock *Node,
                                   const Function *Graph) {
-    if (CFGOnly) return Node->getName() + ":";
+    if (CFGOnly && !Node->getName().empty()) return Node->getName() + ":";
 
     std::ostringstream Out;
+    if (CFGOnly) {
+      WriteAsOperand(Out, Node, false, true);
+      return Out.str();
+    }
+
     Out << *Node;
     std::string OutStr = Out.str();
     if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());