diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-02-15 18:56:05 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-02-15 18:56:05 +0000 |
| commit | 318c41f9e8a4bb4aad9d48e1386881c73b872d17 (patch) | |
| tree | 45a7a4e966bf9479e11fb1b4a0ad337ee7e313b2 | |
| parent | 536ddedea34eb0b56c7ac85a66da898f910a67dc (diff) | |
| download | bcm5719-llvm-318c41f9e8a4bb4aad9d48e1386881c73b872d17.tar.gz bcm5719-llvm-318c41f9e8a4bb4aad9d48e1386881c73b872d17.zip | |
If the llvm name contains an unprintable character, don't print it in
the global comment. This prevents printing things like:
... # foo
bar
when the name is "foo\nbar".
llvm-svn: 47170
| -rw-r--r-- | llvm/lib/Target/X86/X86AsmPrinter.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index 727707b45da..e23dd0d5870 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -138,6 +138,15 @@ bool X86SharedAsmPrinter::doInitialization(Module &M) { return Result; } +/// PrintUnamedNameSafely - Print out the printable characters in the name. +/// Don't print things like \n or \0. +static void PrintUnamedNameSafely(const Value *V, std::ostream &OS) { + for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen(); + Name != E; ++Name) + if (isprint(*Name)) + OS << *Name; +} + bool X86SharedAsmPrinter::doFinalization(Module &M) { // Note: this code is not shared by the Intel printer as it is too different // from how MASM does things. When making changes here don't forget to look @@ -218,7 +227,9 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { if (TAI->getCOMMDirectiveTakesAlignment()) O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } - O << "\t\t" << TAI->getCommentString() << " " << I->getName() << "\n"; + O << "\t\t" << TAI->getCommentString() << " "; + PrintUnamedNameSafely(I, O); + O << "\n"; continue; } } @@ -319,8 +330,9 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { } EmitAlignment(Align, I); - O << name << ":\t\t\t\t" << TAI->getCommentString() << " " << I->getName() - << "\n"; + O << name << ":\t\t\t\t" << TAI->getCommentString() << " "; + PrintUnamedNameSafely(I, O); + O << "\n"; if (TAI->hasDotTypeDotSizeDirective()) O << "\t.size\t" << name << ", " << Size << "\n"; // If the initializer is a extern weak symbol, remember to emit the weak |

