summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCSymbol.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-11-14 06:05:49 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-11-14 06:05:49 +0000
commitfe4e088dfb6747f614ff5d48107d04e9976b9be4 (patch)
tree61dbef5755f6fd0e66a471ea82a3651abfb6dedb /llvm/lib/MC/MCSymbol.cpp
parent404e97c3a2559bc943109b770c239e2bacd08117 (diff)
downloadbcm5719-llvm-fe4e088dfb6747f614ff5d48107d04e9976b9be4.tar.gz
bcm5719-llvm-fe4e088dfb6747f614ff5d48107d04e9976b9be4.zip
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. llvm-svn: 194667
Diffstat (limited to 'llvm/lib/MC/MCSymbol.cpp')
-rw-r--r--llvm/lib/MC/MCSymbol.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp
index b973c57f7b8..24165254e56 100644
--- a/llvm/lib/MC/MCSymbol.cpp
+++ b/llvm/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)
OpenPOWER on IntegriCloud