diff --git a/llvm/include/llvm/MC/MCAsmMacro.h b/llvm/include/llvm/MC/MCAsmMacro.h --- a/llvm/include/llvm/MC/MCAsmMacro.h +++ b/llvm/include/llvm/MC/MCAsmMacro.h @@ -46,7 +46,7 @@ Slash, // '/' BackSlash, // '\' LParen, RParen, LBrac, RBrac, LCurly, RCurly, - Star, Dot, Comma, Dollar, Equal, EqualEqual, + Question, Star, Dot, Comma, Dollar, Equal, EqualEqual, Pipe, PipePipe, Caret, Amp, AmpAmp, Exclaim, ExclaimEqual, Percent, Hash, diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp --- a/llvm/lib/MC/MCParser/AsmLexer.cpp +++ b/llvm/lib/MC/MCParser/AsmLexer.cpp @@ -777,8 +777,7 @@ switch (CurChar) { default: // Handle identifier: [a-zA-Z_.?][a-zA-Z0-9_$.@#?]* - if (isalpha(CurChar) || CurChar == '_' || CurChar == '.' || - (MAI.doesAllowQuestionAtStartOfIdentifier() && CurChar == '?')) + if (isalpha(CurChar) || CurChar == '_' || CurChar == '.') return LexIdentifier(); // Unknown character, emit an error. @@ -830,11 +829,18 @@ return LexIdentifier(); return AsmToken(AsmToken::Dollar, StringRef(TokStart, 1)); } - case '@': { + case '@': if (MAI.doesAllowAtAtStartOfIdentifier()) return LexIdentifier(); return AsmToken(AsmToken::At, StringRef(TokStart, 1)); - } + case '?': + if (MAI.doesAllowQuestionAtStartOfIdentifier()) + return LexIdentifier(); + return AsmToken(AsmToken::Question, StringRef(TokStart, 1)); + case '#': + if (MAI.doesAllowHashAtStartOfIdentifier()) + return LexIdentifier(); + return AsmToken(AsmToken::Hash, StringRef(TokStart, 1)); case '\\': return AsmToken(AsmToken::BackSlash, StringRef(TokStart, 1)); case '=': if (*CurPtr == '=') { @@ -914,11 +920,6 @@ case '/': IsAtStartOfStatement = OldIsAtStartOfStatement; return LexSlash(); - case '#': { - if (MAI.doesAllowHashAtStartOfIdentifier()) - return LexIdentifier(); - return AsmToken(AsmToken::Hash, StringRef(TokStart, 1)); - } case '\'': return LexSingleQuote(); case '"': return LexQuote(); case '0': case '1': case '2': case '3': case '4': diff --git a/llvm/lib/MC/MCParser/MCAsmLexer.cpp b/llvm/lib/MC/MCParser/MCAsmLexer.cpp --- a/llvm/lib/MC/MCParser/MCAsmLexer.cpp +++ b/llvm/lib/MC/MCParser/MCAsmLexer.cpp @@ -88,6 +88,7 @@ case AsmToken::Pipe: OS << "Pipe"; break; case AsmToken::PipePipe: OS << "PipePipe"; break; case AsmToken::Plus: OS << "Plus"; break; + case AsmToken::Question: OS << "Question"; break; case AsmToken::RBrac: OS << "RBrac"; break; case AsmToken::RCurly: OS << "RCurly"; break; case AsmToken::RParen: OS << "RParen"; break;