[llvm-commits] [llvm] r47170 - /llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 15 10:56:05 PST 2008
Author: lattner
Date: Fri Feb 15 12:56:05 2008
New Revision: 47170
URL: http://llvm.org/viewvc/llvm-project?rev=47170&view=rev
Log:
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".
Modified:
llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=47170&r1=47169&r2=47170&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Fri Feb 15 12:56:05 2008
@@ -138,6 +138,15 @@
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 @@
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 @@
}
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
More information about the llvm-commits
mailing list