Skip to content

MCParser: Move LCurly/RCurly testing into tokenIsStartOfStatement #140101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions llvm/lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1760,15 +1760,6 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
// Treat '.' as a valid identifier in this context.
Lex();
IDVal = ".";
} else if (Lexer.is(AsmToken::LCurly)) {
// Treat '{' as a valid identifier in this context.
Lex();
IDVal = "{";

} else if (Lexer.is(AsmToken::RCurly)) {
// Treat '}' as a valid identifier in this context.
Lex();
IDVal = "}";
} else if (getTargetParser().tokenIsStartOfStatement(ID.getKind())) {
Lex();
IDVal = ID.getString();
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class HexagonAsmParser : public MCTargetAsmParser {

bool equalIsAsmAssignment() override { return false; }
bool isLabel(AsmToken &Token) override;
bool tokenIsStartOfStatement(AsmToken::TokenKind Token) override;

void Warning(SMLoc L, const Twine &Msg) { Parser.Warning(L, Msg); }
bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); }
Expand Down Expand Up @@ -1007,6 +1008,10 @@ bool HexagonAsmParser::isLabel(AsmToken &Token) {
return false;
}

bool HexagonAsmParser::tokenIsStartOfStatement(AsmToken::TokenKind Token) {
return Token == AsmToken::LCurly || Token == AsmToken::RCurly;
}

bool HexagonAsmParser::handleNoncontigiousRegister(bool Contigious,
SMLoc &Loc) {
if (!Contigious && ErrorNoncontigiousRegister) {
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class X86AsmParser : public MCTargetAsmParser {
return Result;
}

bool tokenIsStartOfStatement(AsmToken::TokenKind Token) override {
return Token == AsmToken::LCurly;
}

X86TargetStreamer &getTargetStreamer() {
assert(getParser().getStreamer().getTargetStreamer() &&
"do not have a target streamer");
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/MC/AsmParser/token.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Tested invalid statement start tokens. X86 supports "{". Use a different target.
# REQUIRES: aarch64-registered-target

# RUN: not llvm-mc -triple=aarch64 %s 2>&1 | FileCheck %s

# CHECK: [[#@LINE+1]]:2: error: unexpected token at start of statement
{insn}