[llvm] 812f9e8 - [MCParser] .altmacro: ignore & after a token
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 14:00:32 PDT 2024
Author: Fangrui Song
Date: 2024-07-05T14:00:26-07:00
New Revision: 812f9e81d2f75c874301a8f5df25d3de7616a9c5
URL: https://github.com/llvm/llvm-project/commit/812f9e81d2f75c874301a8f5df25d3de7616a9c5
DIFF: https://github.com/llvm/llvm-project/commit/812f9e81d2f75c874301a8f5df25d3de7616a9c5.diff
LOG: [MCParser] .altmacro: ignore & after a token
Added:
Modified:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/AsmParser/altmacro_expression.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 4b7c7f07fed990..bf3061ad541e34 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -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)
diff --git a/llvm/test/MC/AsmParser/altmacro_expression.s b/llvm/test/MC/AsmParser/altmacro_expression.s
index 58d8b486cf85dd..cee0a6872541a9 100644
--- a/llvm/test/MC/AsmParser/altmacro_expression.s
+++ b/llvm/test/MC/AsmParser/altmacro_expression.s
@@ -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)
More information about the llvm-commits
mailing list