Tweak the MCExternalSymbolizer to print references to C string literals
authorKevin Enderby <enderby@apple.com>
Thu, 16 Jan 2014 18:43:56 +0000 (18:43 +0000)
committerKevin Enderby <enderby@apple.com>
Thu, 16 Jan 2014 18:43:56 +0000 (18:43 +0000)
with raw_ostream's write_escaped() method.

For example darwin's otool(1) program that uses the llvm
disassembler now produces disassembly like this:

leaq 0x7b(%rip), %rdi ## literal pool for: "%f\ntoto\n"

and not print the new lines which messes up the output.

rdar://15145300

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

lib/MC/MCExternalSymbolizer.cpp

index def662777d61b1b704da6f1adb55d03d94a46641..b82229457dba309a8d8c218b1fcf56847a171f5e 100644 (file)
@@ -149,8 +149,11 @@ void MCExternalSymbolizer::tryAddingPcLoadReferenceComment(raw_ostream &cStream,
     if(ReferenceType == LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr)
       cStream << "literal pool symbol address: " << ReferenceName;
     else if(ReferenceType ==
-            LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr)
-      cStream << "literal pool for: \"" << ReferenceName << "\"";
+            LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr) {
+      cStream << "literal pool for: \"";
+      cStream.write_escaped(ReferenceName);
+      cStream << "\"";
+    }
     else if(ReferenceType ==
             LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref)
       cStream << "Objc cfstring ref: @\"" << ReferenceName << "\"";