[llvm] [MCParser] Share identifier character set with isMacroArgChar (PR #219084)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 21:55:15 PDT 2026
================
@@ -2459,13 +2459,12 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
Parser->getContext().diagnose(NewDiag);
}
-// FIXME: This is mostly duplicated from the function in AsmLexer.cpp. The
-// difference being that that function accepts '@' as part of identifiers and
-// we can't do that. AsmLexer.cpp should probably be changed to handle
-// '@' as a special case when needed.
-static bool isIdentifierChar(char c) {
- return isalnum(static_cast<unsigned char>(c)) || c == '_' || c == '$' ||
- c == '.';
+// A macro argument name ends at '@', '#' and '?', which may be identifier
+// characters.
+static bool isMacroArgChar(char C) {
+ return AsmLexer::isIdentifierChar(C, /*AllowAt=*/false,
+ /*AllowHash=*/false) &&
+ C != '?';
}
----------------
zhangweize9-cyber wrote:
That’s a great takeaway! My initial thought was just to rename the `isIdentifierChar` function.
https://github.com/llvm/llvm-project/pull/219084
More information about the llvm-commits
mailing list