[llvm-commits] [llvm] r154863 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/macro-args.s

Jim Grosbach grosbach at apple.com
Mon Apr 16 14:18:49 PDT 2012


Author: grosbach
Date: Mon Apr 16 16:18:49 2012
New Revision: 154863

URL: http://llvm.org/viewvc/llvm-project?rev=154863&view=rev
Log:
MC assembly parser handling for trailing comma in macro instantiation.

A trailing comma means no argument at all (i.e., as if the comma were not
present), not an empty argument to the invokee.

rdar://11252521

Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp
    llvm/trunk/test/MC/AsmParser/macro-args.s

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=154863&r1=154862&r2=154863&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Apr 16 16:18:49 2012
@@ -1527,11 +1527,11 @@
     }
     Lex();
   }
-  // If there weren't any arguments, erase the token vector so everything
-  // else knows that. Leaving around the vestigal empty token list confuses
-  // things.
-  if (MacroArguments.size() == 1 && MacroArguments.back().empty())
-    MacroArguments.clear();
+  // If the last argument didn't end up with any tokens, it's not a real
+  // argument and we should remove it from the list. This happens with either
+  // a tailing comma or an empty argument list.
+  if (MacroArguments.back().empty())
+    MacroArguments.pop_back();
 
   // Macro instantiation is lexical, unfortunately. We construct a new buffer
   // to hold the macro body with substitutions.

Modified: llvm/trunk/test/MC/AsmParser/macro-args.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/macro-args.s?rev=154863&r1=154862&r2=154863&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/macro-args.s (original)
+++ llvm/trunk/test/MC/AsmParser/macro-args.s Mon Apr 16 16:18:49 2012
@@ -18,3 +18,27 @@
 
 // CHECK: .long 3
 // CHECK: .long 0
+
+
+.macro top
+    middle _$0, $1
+.endm
+.macro middle
+     $0:
+    .if $n > 1
+        bottom $1
+    .endif
+.endm
+.macro bottom
+    .set fred, $0
+.endm
+
+.text
+
+top foo
+top bar, 42
+
+// CHECK: _foo:
+// CHECK-NOT: fred
+// CHECK: _bar
+// CHECK-NEXT: fred = 42





More information about the llvm-commits mailing list