[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Thu Dec 9 21:41:21 PST 2004



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.166 -> 1.167
---
Log message:

Fix writer to properly quote label names when they don't contain
simple characters.


---
Diffs of the changes:  (+7 -3)

Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.166 llvm/lib/VMCore/AsmWriter.cpp:1.167
--- llvm/lib/VMCore/AsmWriter.cpp:1.166	Sun Dec  5 00:44:09 2004
+++ llvm/lib/VMCore/AsmWriter.cpp	Thu Dec  9 23:41:10 2004
@@ -203,7 +203,8 @@
 // getLLVMName - Turn the specified string into an 'LLVM name', which is either
 // prefixed with % (if the string only contains simple characters) or is
 // surrounded with ""'s (if it has special chars in it).
-static std::string getLLVMName(const std::string &Name) {
+static std::string getLLVMName(const std::string &Name,
+                               bool prefixName = true) {
   assert(!Name.empty() && "Cannot get empty name!");
 
   // First character cannot start with a number...
@@ -220,7 +221,10 @@
   }
   
   // If we get here, then the identifier is legal to use as a "VarID".
-  return "%"+Name;
+  if (prefixName)
+    return "%"+Name;
+  else
+    return Name;
 }
 
 
@@ -953,7 +957,7 @@
 ///
 void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
   if (BB->hasName()) {              // Print out the label if it exists...
-    Out << "\n" << BB->getName() << ':';
+    Out << "\n" << getLLVMName(BB->getName(), false) << ':';
   } else if (!BB->use_empty()) {      // Don't print block # of no uses...
     Out << "\n; <label>:";
     int Slot = Machine.getSlot(BB);






More information about the llvm-commits mailing list