mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 13:41:04 +01:00
Remove the SemIRLoc typedef (#5299)
Replace SemIRLoc typedef uses with explicitly SemIR::LocId, loc -> loc_id for consistency.
This commit is contained in:
@@ -54,7 +54,7 @@ static auto MergeClassRedecl(Context& context, Parse::AnyClassDeclId node_id,
|
||||
SemIR::ClassId prev_class_id,
|
||||
SemIR::ImportIRId prev_import_ir_id) -> bool {
|
||||
auto& prev_class = context.classes().Get(prev_class_id);
|
||||
SemIRLoc prev_loc = prev_class.latest_decl_id();
|
||||
SemIR::LocId prev_loc_id = prev_class.latest_decl_id();
|
||||
|
||||
// Check the generic parameters match, if they were specified.
|
||||
if (!CheckRedeclParamsMatch(context, DeclParams(new_class),
|
||||
@@ -65,7 +65,7 @@ static auto MergeClassRedecl(Context& context, Parse::AnyClassDeclId node_id,
|
||||
DiagnoseIfInvalidRedecl(
|
||||
context, Lex::TokenKind::Class, prev_class.name_id,
|
||||
RedeclInfo(new_class, node_id, new_is_definition),
|
||||
RedeclInfo(prev_class, prev_loc, prev_class.has_definition_started()),
|
||||
RedeclInfo(prev_class, prev_loc_id, prev_class.has_definition_started()),
|
||||
prev_import_ir_id);
|
||||
|
||||
if (new_is_definition && prev_class.has_definition_started()) {
|
||||
@@ -301,22 +301,23 @@ auto HandleParseNode(Context& context, Parse::ClassDefinitionStartId node_id)
|
||||
|
||||
// Diagnoses a class-specific declaration appearing outside a class.
|
||||
static auto DiagnoseClassSpecificDeclOutsideClass(Context& context,
|
||||
SemIRLoc loc,
|
||||
SemIR::LocId loc_id,
|
||||
Lex::TokenKind tok) -> void {
|
||||
CARBON_DIAGNOSTIC(ClassSpecificDeclOutsideClass, Error,
|
||||
"`{0}` declaration outside class", Lex::TokenKind);
|
||||
context.emitter().Emit(loc, ClassSpecificDeclOutsideClass, tok);
|
||||
context.emitter().Emit(loc_id, ClassSpecificDeclOutsideClass, tok);
|
||||
}
|
||||
|
||||
// Returns the current scope's class declaration, or diagnoses if it isn't a
|
||||
// class.
|
||||
static auto GetCurrentScopeAsClassOrDiagnose(Context& context, SemIRLoc loc,
|
||||
static auto GetCurrentScopeAsClassOrDiagnose(Context& context,
|
||||
SemIR::LocId loc_id,
|
||||
Lex::TokenKind tok)
|
||||
-> std::optional<SemIR::ClassDecl> {
|
||||
auto class_scope =
|
||||
context.scope_stack().GetCurrentScopeAs<SemIR::ClassDecl>();
|
||||
if (!class_scope) {
|
||||
DiagnoseClassSpecificDeclOutsideClass(context, loc, tok);
|
||||
DiagnoseClassSpecificDeclOutsideClass(context, loc_id, tok);
|
||||
}
|
||||
return class_scope;
|
||||
}
|
||||
@@ -324,8 +325,8 @@ static auto GetCurrentScopeAsClassOrDiagnose(Context& context, SemIRLoc loc,
|
||||
// Diagnoses a class-specific declaration that is repeated within a class, but
|
||||
// is not permitted to be repeated.
|
||||
static auto DiagnoseClassSpecificDeclRepeated(Context& context,
|
||||
SemIRLoc new_loc,
|
||||
SemIRLoc prev_loc,
|
||||
SemIR::LocId new_loc_id,
|
||||
SemIR::LocId prev_loc_id,
|
||||
Lex::TokenKind tok) -> void {
|
||||
CARBON_DIAGNOSTIC(AdaptDeclRepeated, Error,
|
||||
"multiple `adapt` declarations in class");
|
||||
@@ -336,9 +337,9 @@ static auto DiagnoseClassSpecificDeclRepeated(Context& context,
|
||||
"previous `{0}` declaration is here", Lex::TokenKind);
|
||||
CARBON_CHECK(tok == Lex::TokenKind::Adapt || tok == Lex::TokenKind::Base);
|
||||
context.emitter()
|
||||
.Build(new_loc, tok == Lex::TokenKind::Adapt ? AdaptDeclRepeated
|
||||
: BaseDeclRepeated)
|
||||
.Note(prev_loc, ClassSpecificDeclPrevious, tok)
|
||||
.Build(new_loc_id, tok == Lex::TokenKind::Adapt ? AdaptDeclRepeated
|
||||
: BaseDeclRepeated)
|
||||
.Note(prev_loc_id, ClassSpecificDeclPrevious, tok)
|
||||
.Emit();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user