Skip to content

Commit 90fbc5b

Browse files
committed
[MCAsmParser] Simplify. NFC
1 parent e91ea1b commit 90fbc5b

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,8 @@ AsmParser::~AsmParser() {
833833

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

@@ -1510,9 +1507,7 @@ bool AsmParser::parseExpression(const MCExpr *&Res, SMLoc &EndLoc) {
15101507
// As a special case, we support 'a op b @ modifier' by rewriting the
15111508
// expression to include the modifier. This is inefficient, but in general we
15121509
// expect users to use 'a@modifier op b'.
1513-
if (Lexer.getKind() == AsmToken::At) {
1514-
Lex();
1515-
1510+
if (parseOptionalToken(AsmToken::At)) {
15161511
if (Lexer.isNot(AsmToken::Identifier))
15171512
return TokError("unexpected symbol modifier following '@'");
15181513

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

2711-
if (Lexer.is(AsmToken::Space)) {
2706+
if (parseOptionalToken(AsmToken::Space))
27122707
SpaceEaten = true;
2713-
Lexer.Lex(); // Eat spaces
2714-
}
27152708

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

27242717
// Whitespace after an operator can be ignored.
2725-
if (Lexer.is(AsmToken::Space))
2726-
Lexer.Lex();
2727-
2718+
parseOptionalToken(AsmToken::Space);
27282719
continue;
27292720
}
27302721
}
@@ -2865,8 +2856,7 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M,
28652856
return Failure;
28662857
}
28672858

2868-
if (Lexer.is(AsmToken::Comma))
2869-
Lex();
2859+
parseOptionalToken(AsmToken::Comma);
28702860
}
28712861

28722862
return TokError("too many positional arguments");

llvm/lib/MC/MCParser/MCAsmParser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ bool MCAsmParser::TokError(const Twine &Msg, SMRange Range) {
9999
}
100100

101101
bool MCAsmParser::Error(SMLoc L, const Twine &Msg, SMRange Range) {
102-
103102
MCPendingError PErr;
104103
PErr.Loc = L;
105104
Msg.toVector(PErr.Msg);

0 commit comments

Comments
 (0)