[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

@@ -1243,9 +1243,8 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
return false;
}
Identifier name = Context.getIdentifier(Tok.getText());
consumeToken(tok::identifier);
Identifier name;
consumeIdentifier(&name);
auto range = SourceRange(Loc, Tok.getRange().getStart());
@@ -4251,8 +4250,7 @@ static ParameterList *parseOptionalAccessorArgument(SourceLoc SpecifierLoc,
EndLoc = StartLoc;
} else {
// We have a name.
Name = P.Context.getIdentifier(P.Tok.getText());
NameLoc = P.consumeToken();
NameLoc = P.consumeIdentifier(&Name);
auto DiagID =
Kind == AccessorKind::Set ? diag::expected_rparen_set_name :
@@ -6734,15 +6732,17 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
SyntaxParsingContext GroupCtxt(SyntaxContext,
SyntaxKind::IdentifierList);
identifiers.push_back(Context.getIdentifier(Tok.getText()));
identifierLocs.push_back(consumeToken(tok::identifier));
Identifier name;
identifierLocs.push_back(consumeIdentifier(&name));
identifiers.push_back(name);
while (Tok.is(tok::comma)) {
auto comma = consumeToken();
if (Tok.is(tok::identifier)) {
identifiers.push_back(Context.getIdentifier(Tok.getText()));
identifierLocs.push_back(consumeToken(tok::identifier));
Identifier name;
identifierLocs.push_back(consumeIdentifier(&name));
identifiers.push_back(name);
} else {
if (Tok.isNot(tok::eof)) {
auto otherTokLoc = consumeToken();
@@ -7034,8 +7034,9 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
diagnose(Tok, diag::expected_precedencegroup_relation, attrName);
return abortBody();
}
auto name = Context.getIdentifier(Tok.getText());
relations.push_back({consumeToken(), name, nullptr});
Identifier name;
SourceLoc nameLoc = consumeIdentifier(&name);
relations.push_back({nameLoc, name, nullptr});
if (skipUnspacedCodeCompleteToken())
return abortBody(/*hasCodeCompletion*/true);