[Parser] Consistently use consumeIdentifier() for normal identifiers.

consumeIdentifier() provides the general way in which we consume an
identifier token and fill in an Identifier. Use it consistently in the
parser.
This commit is contained in:
Doug Gregor
2019-03-22 14:27:26 -07:00
parent 9c62420809
commit 32b0245187
4 changed files with 31 additions and 20 deletions

View File

@@ -864,7 +864,12 @@ bool Parser::parseSpecificIdentifier(StringRef expected, SourceLoc &loc,
/// its name in Result. Otherwise, emit an error and return true.
bool Parser::parseAnyIdentifier(Identifier &Result, SourceLoc &Loc,
const Diagnostic &D) {
if (Tok.is(tok::identifier) || Tok.isAnyOperator()) {
if (Tok.is(tok::identifier)) {
Loc = consumeIdentifier(&Result);
return false;
}
if (Tok.isAnyOperator()) {
Result = Context.getIdentifier(Tok.getText());
Loc = Tok.getLoc();
consumeToken();