From d50c2b90647cd34092a106a7124529784b133cee Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 8 Sep 2009 23:20:50 +0000 Subject: [PATCH] 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 --- lib/MC/MCExpr.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 3eae6bdf3d3..c0ecad0361a 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(*this).getValue(); return; - case MCExpr::SymbolRef: - cast(*this).getSymbol().print(OS, MAI); + case MCExpr::SymbolRef: { + const MCSymbol &Sym = cast(*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(*this); -- 2.34.1