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 | 9714644a38213d059f3ddced08cfc119ca8a0ab7 (patch) | |
tree | 8c2ae1939ffac03ce89d84f8da72415a1ad4a2e2 /lib | |
parent | ba1f580f338e12c47a600050f7a77fae579acf93 (diff) | |
download | llvm-9714644a38213d059f3ddced08cfc119ca8a0ab7.tar.gz llvm-9714644a38213d059f3ddced08cfc119ca8a0ab7.tar.bz2 llvm-9714644a38213d059f3ddced08cfc119ca8a0ab7.tar.xz |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 2daad0a851..4985bd5125 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/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; |