location -> loc abbreviation (#3826)

This commit is contained in:
Jon Ross-Perkins
2024-03-28 18:15:18 +00:00
committed by GitHub
parent 72564a08d4
commit b5d28f2c4b
48 changed files with 341 additions and 373 deletions
@@ -25,13 +25,13 @@ static auto HandleDeclNameAndParams(Context& context, State after_name)
CARBON_DIAGNOSTIC(ExpectedDeclName, Error,
"`{0}` introducer should be followed by a name.",
Lex::TokenKind);
Lex::TokenIndex location = *context.position();
if (context.tokens().GetKind(location) == Lex::TokenKind::FileEnd) {
// The end of file is often an especially unhelpful location. If that's
// the best we can do here, back up the location to the introducer itself.
location = state.token;
Lex::TokenIndex token = *context.position();
if (context.tokens().GetKind(token) == Lex::TokenKind::FileEnd) {
// The end of file is an unhelpful diagnostic location. Instead, use the
// introducer token.
token = state.token;
}
context.emitter().Emit(location, ExpectedDeclName,
context.emitter().Emit(token, ExpectedDeclName,
context.tokens().GetKind(state.token));
context.ReturnErrorOnState();
context.AddLeafNode(NodeKind::InvalidParse, *context.position(),