Skip to content

Commit

Permalink
[MCParser] .altmacro: ignore & after a token
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Jul 5, 2024
1 parent ac03ae3 commit 812f9e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions llvm/lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,8 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, MCAsmMacro &Macro,
while (I != End && isIdentifierChar(Body[I]))
++I;
StringRef Argument(Body.data() + Pos, I - Pos);
if (AltMacroMode && I != End && Body[I] == '&')
++I;
unsigned Index = 0;
for (; Index < NParameters; ++Index)
if (Parameters[Index].Name == Argument)
Expand Down
4 changes: 3 additions & 1 deletion llvm/test/MC/AsmParser/altmacro_expression.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# Checking that the '%' was evaluated as a string first
# In a fail scenario: The asmprint will print: addl $%(1+4), %eax

# CHECK: addl $5, %eax
# CHECK: addl $5, %eax
# CHECK-NEXT: addl $5, %eax
.altmacro
.macro percent_expr arg
addl $\arg, %eax
addl $\arg&, %eax
.endm

percent_expr %(1+4)
Expand Down

0 comments on commit 812f9e8

Please sign in to comment.