aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-08 23:20:50 +0000
committerChris Lattner <sabre@nondot.org>2009-09-08 23:20:50 +0000
commitd50c2b90647cd34092a106a7124529784b133cee (patch)
treeb1038131c905053f908ecaab895d4091b70379ab /lib/MC
parent8429837a94bad081b261091187b7e576b6a48df4 (diff)
downloadexternal_llvm-d50c2b90647cd34092a106a7124529784b133cee.zip
external_llvm-d50c2b90647cd34092a106a7124529784b133cee.tar.gz
external_llvm-d50c2b90647cd34092a106a7124529784b133cee.tar.bz2
parenthesize symbol names that start with $, fixing X86/dollar-name.ll with
the new asmprinter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCExpr.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp
index 3eae6bd..c0ecad0 100644
--- a/lib/MC/MCExpr.cpp
+++ b/lib/MC/MCExpr.cpp
@@ -20,9 +20,20 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
OS << cast<MCConstantExpr>(*this).getValue();
return;
- case MCExpr::SymbolRef:
- cast<MCSymbolRefExpr>(*this).getSymbol().print(OS, MAI);
+ case MCExpr::SymbolRef: {
+ const MCSymbol &Sym = cast<MCSymbolRefExpr>(*this).getSymbol();
+
+ // Parenthesize names that start with $ so that they don't look like
+ // absolute names.
+ if (Sym.getName()[0] == '$') {
+ OS << '(';
+ Sym.print(OS, MAI);
+ OS << ')';
+ } else {
+ Sym.print(OS, MAI);
+ }
return;
+ }
case MCExpr::Unary: {
const MCUnaryExpr &UE = cast<MCUnaryExpr>(*this);