diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-07-30 22:44:17 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-07-30 22:44:17 +0000 |
commit | 20666162e974d3eafb4cb949a3a6c92b031dc435 (patch) | |
tree | 326200b2407164ca4e0e304c719bf64a3d4c2f89 /llvm | |
parent | 0b01261cb070d665fc52b99f6da8b98ed09f55dd (diff) | |
download | bcm5719-llvm-20666162e974d3eafb4cb949a3a6c92b031dc435.tar.gz bcm5719-llvm-20666162e974d3eafb4cb949a3a6c92b031dc435.zip |
Keep empty assembly macro argument values in the middle of the list.
Empty macro arguments at the end of the list should be as-if not specified at
all, but those in the middle of the list need to be kept so as not to screw
up the positional numbering. E.g.:
.macro foo
foo_-bash___:
nop
.endm
foo 1, 2, 3, 4
foo 1, , 3, 4
Should create two labels, "foo_1_2_3_4" and "foo_1__3_4".
rdar://11948769
llvm-svn: 161002
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 10 | ||||
-rw-r--r-- | llvm/test/MC/AsmParser/macro-args.s | 12 |
2 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 2daad0a8513..4985bd51255 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -1597,8 +1597,8 @@ bool AsmParser::ParseMacroArguments(const Macro *M, if (ParseMacroArgument(MA)) return true; - if (!MA.empty()) - A.push_back(MA); + A.push_back(MA); + if (Lexer.is(AsmToken::EndOfStatement)) return false; @@ -1619,6 +1619,12 @@ bool AsmParser::HandleMacroEntry(StringRef Name, SMLoc NameLoc, if (ParseMacroArguments(M, MacroArguments)) return true; + // Remove any trailing empty arguments. Do this after-the-fact as we have + // to keep empty arguments in the middle of the list or positionality + // gets off. e.g., "foo 1, , 2" vs. "foo 1, 2," + while (!MacroArguments.empty() && MacroArguments.back().empty()) + MacroArguments.pop_back(); + // Macro instantiation is lexical, unfortunately. We construct a new buffer // to hold the macro body with substitutions. SmallString<256> Buf; diff --git a/llvm/test/MC/AsmParser/macro-args.s b/llvm/test/MC/AsmParser/macro-args.s index 13b197a55a8..6d084213e40 100644 --- a/llvm/test/MC/AsmParser/macro-args.s +++ b/llvm/test/MC/AsmParser/macro-args.s @@ -42,3 +42,15 @@ top bar, 42 // CHECK-NOT: fred // CHECK: _bar // CHECK-NEXT: fred = 42 + + +.macro foo +foo_$0_$1_$2_$3: + nop +.endm + +foo 1, 2, 3, 4 +foo 1, , 3, 4 + +// CHECK: foo_1_2_3_4: +// CHECK: foo_1__3_4: |