[llvm-commits] [llvm] r162298 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/macros.s

Rafael Espindola rafael.espindola at gmail.com
Tue Aug 21 11:29:31 PDT 2012


Author: rafael
Date: Tue Aug 21 13:29:30 2012
New Revision: 162298

URL: http://llvm.org/viewvc/llvm-project?rev=162298&view=rev
Log:
Fix macros arguments with an underscore, dot or dollar in them. This is based
on a patch by Andy/PaX. I added the support for dot and dollar.

Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp
    llvm/trunk/test/MC/AsmParser/macros.s

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=162298&r1=162297&r2=162298&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Aug 21 13:29:30 2012
@@ -1454,6 +1454,14 @@
     NewDiag.print(0, OS);
 }
 
+// FIXME: This is mostly duplicated from the function in AsmLexer.cpp. The
+// difference being that that function accepts '@' as part of identifiers and
+// we can't do that. AsmLexer.cpp should probably be changed to handle
+// '@' as a special case when needed.
+static bool isIdentifierChar(char c) {
+  return isalnum(c) || c == '_' || c == '$' || c == '.';
+}
+
 bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body,
                             const MacroParameters &Parameters,
                             const MacroArguments &A,
@@ -1518,7 +1526,7 @@
       Pos += 2;
     } else {
       unsigned I = Pos + 1;
-      while (isalnum(Body[I]) && I + 1 != End)
+      while (isIdentifierChar(Body[I]) && I + 1 != End)
         ++I;
 
       const char *Begin = Body.data() + Pos +1;

Modified: llvm/trunk/test/MC/AsmParser/macros.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/macros.s?rev=162298&r1=162297&r2=162298&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/macros.s (original)
+++ llvm/trunk/test/MC/AsmParser/macros.s Tue Aug 21 13:29:30 2012
@@ -37,3 +37,24 @@
 
 // CHECK: .globl	"ab)(,) -- (cd)"
 test4 a b)(,),(cd)
+
+.macro test5 _a
+.globl "\_a"
+.endm
+
+test5 zed1
+// CHECK: .globl zed1
+
+.macro test6 $a
+.globl "\$a"
+.endm
+
+test6 zed2
+// CHECK: .globl zed2
+
+.macro test7 .a
+.globl "\.a"
+.endm
+
+test7 zed3
+// CHECK: .globl zed3





More information about the llvm-commits mailing list