diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-14 06:05:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-14 06:05:49 +0000 |
commit | 732cf2d598b4c9ca47e9c32fbd2e7732d971bda6 (patch) | |
tree | 84eaf12c0c6c9d689050b548eee0d9147effd5a4 /lib/MC/MCSymbol.cpp | |
parent | fd57284d021d594ebbf358456d40c4f72e515cca (diff) | |
download | external_llvm-732cf2d598b4c9ca47e9c32fbd2e7732d971bda6.zip external_llvm-732cf2d598b4c9ca47e9c32fbd2e7732d971bda6.tar.gz external_llvm-732cf2d598b4c9ca47e9c32fbd2e7732d971bda6.tar.bz2 |
Don't mangle \n and "
There is nothing special about quotes and newlines from the object
file point of view, only the assembler has to worry about expanding
the \n and \".
This patch then removes the special handling from the Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194667 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCSymbol.cpp')
-rw-r--r-- | lib/MC/MCSymbol.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/MC/MCSymbol.cpp b/lib/MC/MCSymbol.cpp index b973c57..2416525 100644 --- a/lib/MC/MCSymbol.cpp +++ b/lib/MC/MCSymbol.cpp @@ -68,12 +68,23 @@ void MCSymbol::print(raw_ostream &OS) const { // The name for this MCSymbol is required to be a valid target name. However, // some targets support quoting names with funny characters. If the name // contains a funny character, then print it quoted. - if (!NameNeedsQuoting(getName())) { - OS << getName(); + StringRef Name = getName(); + if (!NameNeedsQuoting(Name)) { + OS << Name; return; } - OS << '"' << getName() << '"'; + OS << '"'; + for (unsigned I = 0, E = Name.size(); I != E; ++I) { + char C = Name[I]; + if (C == '\n') + OS << "\\n"; + else if (C == '"') + OS << "\\\""; + else + OS << C; + } + OS << '"'; } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |