MC asm parser macro argument count was wrong when empty.
authorJim Grosbach <grosbach@apple.com>
Sat, 17 Mar 2012 00:11:42 +0000 (00:11 +0000)
committerJim Grosbach <grosbach@apple.com>
Sat, 17 Mar 2012 00:11:42 +0000 (00:11 +0000)
 evaluated to '1' when the argument list was empty (should be '0').

rdar://11057257

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152967 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/macro-args.s

index bd5956f9b482d8531d11140850440c09878f99c4..41ad1642d28f8c4f45590f6b4474cd02c123bfaf 100644 (file)
@@ -1528,6 +1528,11 @@ bool AsmParser::HandleMacroEntry(StringRef Name, SMLoc NameLoc,
     }
     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();
 
   // Macro instantiation is lexical, unfortunately. We construct a new buffer
   // to hold the macro body with substitutions.
index 808b6eb488035187d36c9f38d4e3ea953fdf8a26..4b878999e42479b34831c83b3871c4d30e301af2 100644 (file)
@@ -8,3 +8,13 @@
 GET    is_sse, %eax
 
 // CHECK: movl is_sse@GOTOFF(%ebx), %eax
+
+.macro bar
+    .long $n
+.endm
+
+bar 1, 2, 3
+bar
+
+// CHECK: .long 3
+// CHECK: .long 0