Skip to content

Commit b181f66

Browse files
[X86] Use StringRef::consume_back (NFC) (#139417)
This patch uses consume_back while changing the type of TrailingDot to bool, indicating whether we have consumed "." or not.
1 parent 7ca4079 commit b181f66

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,7 @@ bool X86AsmParser::ParseIntelDotOperator(IntelExprStateMachine &SM,
23782378
// Drop the optional '.'.
23792379
StringRef DotDispStr = Tok.getString();
23802380
DotDispStr.consume_front(".");
2381-
StringRef TrailingDot;
2381+
bool TrailingDot = false;
23822382

23832383
// .Imm gets lexed as a real.
23842384
if (Tok.is(AsmToken::Real)) {
@@ -2388,10 +2388,7 @@ bool X86AsmParser::ParseIntelDotOperator(IntelExprStateMachine &SM,
23882388
Info.Offset = DotDisp.getZExtValue();
23892389
} else if ((isParsingMSInlineAsm() || getParser().isParsingMasm()) &&
23902390
Tok.is(AsmToken::Identifier)) {
2391-
if (DotDispStr.ends_with(".")) {
2392-
TrailingDot = DotDispStr.substr(DotDispStr.size() - 1);
2393-
DotDispStr = DotDispStr.drop_back(1);
2394-
}
2391+
TrailingDot = DotDispStr.consume_back(".");
23952392
const std::pair<StringRef, StringRef> BaseMember = DotDispStr.split('.');
23962393
const StringRef Base = BaseMember.first, Member = BaseMember.second;
23972394
if (getParser().lookUpField(SM.getType(), DotDispStr, Info) &&
@@ -2409,8 +2406,8 @@ bool X86AsmParser::ParseIntelDotOperator(IntelExprStateMachine &SM,
24092406
const char *DotExprEndLoc = DotDispStr.data() + DotDispStr.size();
24102407
while (Tok.getLoc().getPointer() < DotExprEndLoc)
24112408
Lex();
2412-
if (!TrailingDot.empty())
2413-
getLexer().UnLex(AsmToken(AsmToken::Dot, TrailingDot));
2409+
if (TrailingDot)
2410+
getLexer().UnLex(AsmToken(AsmToken::Dot, "."));
24142411
SM.addImm(Info.Offset);
24152412
SM.setTypeInfo(Info.Type);
24162413
return false;

0 commit comments

Comments
 (0)