Skip to content

Commit

Permalink
[MCAsmParser] Simplify. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed May 16, 2024
1 parent e91ea1b commit 90fbc5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
22 changes: 6 additions & 16 deletions llvm/lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,8 @@ AsmParser::~AsmParser() {

void AsmParser::printMacroInstantiations() {
// Print the active macro instantiation stack.
for (std::vector<MacroInstantiation *>::const_reverse_iterator
it = ActiveMacros.rbegin(),
ie = ActiveMacros.rend();
it != ie; ++it)
printMessage((*it)->InstantiationLoc, SourceMgr::DK_Note,
for (MacroInstantiation *M : reverse(ActiveMacros))
printMessage(M->InstantiationLoc, SourceMgr::DK_Note,
"while in macro instantiation");
}

Expand Down Expand Up @@ -1510,9 +1507,7 @@ bool AsmParser::parseExpression(const MCExpr *&Res, SMLoc &EndLoc) {
// As a special case, we support 'a op b @ modifier' by rewriting the
// expression to include the modifier. This is inefficient, but in general we
// expect users to use 'a@modifier op b'.
if (Lexer.getKind() == AsmToken::At) {
Lex();

if (parseOptionalToken(AsmToken::At)) {
if (Lexer.isNot(AsmToken::Identifier))
return TokError("unexpected symbol modifier following '@'");

Expand Down Expand Up @@ -2708,10 +2703,8 @@ bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA, bool Vararg) {
if (Lexer.is(AsmToken::Comma))
break;

if (Lexer.is(AsmToken::Space)) {
if (parseOptionalToken(AsmToken::Space))
SpaceEaten = true;
Lexer.Lex(); // Eat spaces
}

// Spaces can delimit parameters, but could also be part an expression.
// If the token after a space is an operator, add the token and the next
Expand All @@ -2722,9 +2715,7 @@ bool AsmParser::parseMacroArgument(MCAsmMacroArgument &MA, bool Vararg) {
Lexer.Lex();

// Whitespace after an operator can be ignored.
if (Lexer.is(AsmToken::Space))
Lexer.Lex();

parseOptionalToken(AsmToken::Space);
continue;
}
}
Expand Down Expand Up @@ -2865,8 +2856,7 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M,
return Failure;
}

if (Lexer.is(AsmToken::Comma))
Lex();
parseOptionalToken(AsmToken::Comma);
}

return TokError("too many positional arguments");
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/MC/MCParser/MCAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ bool MCAsmParser::TokError(const Twine &Msg, SMRange Range) {
}

bool MCAsmParser::Error(SMLoc L, const Twine &Msg, SMRange Range) {

MCPendingError PErr;
PErr.Loc = L;
Msg.toVector(PErr.Msg);
Expand Down

0 comments on commit 90fbc5b

Please sign in to comment.