From 2c8e0ac85c89eff01e7a44ce0c0751010cca6c74 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Sat, 17 Mar 2012 00:11:42 +0000 Subject: [PATCH] MC asm parser macro argument count was wrong when empty. evaluated to '1' when the argument list was empty (should be '0'). rdar://11057257 llvm-svn: 152967 --- llvm/lib/MC/MCParser/AsmParser.cpp | 5 +++++ llvm/test/MC/AsmParser/macro-args.s | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index bd5956f9b482..41ad1642d28f 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -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. diff --git a/llvm/test/MC/AsmParser/macro-args.s b/llvm/test/MC/AsmParser/macro-args.s index 808b6eb48803..4b878999e424 100644 --- a/llvm/test/MC/AsmParser/macro-args.s +++ b/llvm/test/MC/AsmParser/macro-args.s @@ -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