@@ -479,7 +479,7 @@ auto ImportCppFiles(Context& context,
479
479
480
480
SemIR::NameScope& name_scope = context.name_scopes ().Get (name_scope_id);
481
481
name_scope.set_is_closed_import (true );
482
- name_scope.set_clang_decl_context_id (context.sem_ir (). clang_decls ().Add (
482
+ name_scope.set_clang_decl_context_id (context.clang_decls ().Add (
483
483
{.decl = generated_ast->getASTContext ().getTranslationUnitDecl (),
484
484
.inst_id = name_scope.inst_id ()}));
485
485
@@ -500,7 +500,7 @@ static auto GetDeclContext(Context& context, SemIR::NameScopeId scope_id)
500
500
auto scope_clang_decl_context_id =
501
501
context.name_scopes ().Get (scope_id).clang_decl_context_id ();
502
502
return dyn_cast<clang::DeclContext>(
503
- context.sem_ir (). clang_decls ().Get (scope_clang_decl_context_id).decl );
503
+ context.clang_decls ().Get (scope_clang_decl_context_id).decl );
504
504
}
505
505
506
506
static auto ClangLookup (Context& context, SemIR::NameScopeId scope_id,
@@ -563,20 +563,20 @@ static auto ClangLookupDeclarationName(Context& context, SemIR::LocId loc_id,
563
563
}
564
564
565
565
// Looks up for constructors in the class scope and returns the lookup result.
566
- static auto ClangConstructorLookup (const Context& context,
566
+ static auto ClangConstructorLookup (Context& context,
567
567
SemIR::NameScopeId scope_id)
568
568
-> clang::DeclContextLookupResult {
569
569
const SemIR::NameScope& scope = context.sem_ir ().name_scopes ().Get (scope_id);
570
570
571
571
clang::Sema& sema = context.sem_ir ().clang_ast_unit ()->getSema ();
572
572
clang::Decl* decl =
573
- context.sem_ir (). clang_decls ().Get (scope.clang_decl_context_id ()).decl ;
573
+ context.clang_decls ().Get (scope.clang_decl_context_id ()).decl ;
574
574
return sema.LookupConstructors (cast<clang::CXXRecordDecl>(decl));
575
575
}
576
576
577
577
// Returns true if the given Clang declaration is the implicit injected class
578
578
// name within the class.
579
- static auto IsDeclInjectedClassName (const Context& context,
579
+ static auto IsDeclInjectedClassName (Context& context,
580
580
SemIR::NameScopeId scope_id,
581
581
SemIR::NameId name_id,
582
582
const clang::NamedDecl* named_decl)
@@ -590,7 +590,7 @@ static auto IsDeclInjectedClassName(const Context& context,
590
590
return false ;
591
591
}
592
592
593
- const SemIR::ClangDecl& clang_decl = context.sem_ir (). clang_decls ().Get (
593
+ const SemIR::ClangDecl& clang_decl = context.clang_decls ().Get (
594
594
context.sem_ir ().name_scopes ().Get (scope_id).clang_decl_context_id ());
595
595
const auto * scope_record_decl = cast<clang::CXXRecordDecl>(clang_decl.decl );
596
596
@@ -647,9 +647,9 @@ static auto IsClangDeclImported(const Context& context, clang::Decl* decl)
647
647
648
648
// If `decl` already mapped to an instruction, returns that instruction.
649
649
// Otherwise returns `None`.
650
- static auto LookupClangDeclInstId (const Context& context, clang::Decl* decl)
650
+ static auto LookupClangDeclInstId (Context& context, clang::Decl* decl)
651
651
-> SemIR::InstId {
652
- const auto & clang_decls = context.sem_ir (). clang_decls ();
652
+ const auto & clang_decls = context.clang_decls ();
653
653
if (auto context_clang_decl_id = clang_decls.Lookup (decl->getCanonicalDecl ());
654
654
context_clang_decl_id.has_value ()) {
655
655
return clang_decls.Get (context_clang_decl_id).inst_id ;
@@ -710,7 +710,7 @@ static auto ImportNamespaceDecl(Context& context,
710
710
/* import_id=*/ SemIR::InstId::None);
711
711
context.name_scopes ()
712
712
.Get (result.name_scope_id )
713
- .set_clang_decl_context_id (context.sem_ir (). clang_decls ().Add (
713
+ .set_clang_decl_context_id (context.clang_decls ().Add (
714
714
{.decl = clang_decl->getCanonicalDecl (), .inst_id = result.inst_id }));
715
715
return result.inst_id ;
716
716
}
@@ -776,7 +776,7 @@ static auto ImportTagDecl(Context& context, clang::TagDecl* clang_decl)
776
776
AddIdentifierName (context, clang_decl->getName ()));
777
777
778
778
// TODO: The caller does the same lookup. Avoid doing it twice.
779
- auto clang_decl_id = context.sem_ir (). clang_decls ().Add (
779
+ auto clang_decl_id = context.clang_decls ().Add (
780
780
{.decl = clang_decl->getCanonicalDecl (), .inst_id = class_inst_id});
781
781
782
782
// Name lookup into the Carbon class looks in the C++ class definition.
@@ -954,7 +954,7 @@ static auto ImportClassObjectRepr(Context& context, SemIR::ClassId class_id,
954
954
context, class_type_inst_id, field_type_inst_id),
955
955
.name_id = field_name_id,
956
956
.index = SemIR::ElementIndex (fields.size ())}));
957
- context.sem_ir (). clang_decls ().Add (
957
+ context.clang_decls ().Add (
958
958
{.decl = decl->getCanonicalDecl (), .inst_id = field_decl_id});
959
959
960
960
// Compute the offset to the field that appears directly in the class.
@@ -1085,15 +1085,15 @@ static auto ImportEnumConstantDecl(Context& context,
1085
1085
auto inst_id = AddInstInNoBlock<SemIR::IntValue>(
1086
1086
context, loc_id, {.type_id = type_id, .int_id = int_id});
1087
1087
context.imports ().push_back (inst_id);
1088
- context.sem_ir (). clang_decls ().Add (
1088
+ context.clang_decls ().Add (
1089
1089
{.decl = enumerator_decl->getCanonicalDecl (), .inst_id = inst_id});
1090
1090
return inst_id;
1091
1091
}
1092
1092
1093
1093
// Mark the given `Decl` as failed in `clang_decls`.
1094
1094
static auto MarkFailedDecl (Context& context, clang::Decl* clang_decl) {
1095
- context.sem_ir (). clang_decls ().Add ({.decl = clang_decl->getCanonicalDecl (),
1096
- .inst_id = SemIR::ErrorInst::InstId});
1095
+ context.clang_decls ().Add ({.decl = clang_decl->getCanonicalDecl (),
1096
+ .inst_id = SemIR::ErrorInst::InstId});
1097
1097
}
1098
1098
1099
1099
// Creates an integer type of the given size.
@@ -1193,7 +1193,7 @@ static auto MapTagType(Context& context, const clang::TagType& type)
1193
1193
if (auto * record_decl = dyn_cast<clang::CXXRecordDecl>(tag_decl)) {
1194
1194
auto custom_type = LookupCustomRecordType (context, record_decl);
1195
1195
if (custom_type.inst_id .has_value ()) {
1196
- context.sem_ir (). clang_decls ().Add (
1196
+ context.clang_decls ().Add (
1197
1197
{.decl = record_decl, .inst_id = custom_type.inst_id });
1198
1198
return custom_type;
1199
1199
}
@@ -1485,7 +1485,7 @@ static auto GetReturnTypeExpr(Context& context, SemIR::LocId loc_id,
1485
1485
SemIR::TypeInstId record_type_inst_id = context.types ().GetAsTypeInstId (
1486
1486
context.sem_ir ()
1487
1487
.clang_decls ()
1488
- .Get (context.sem_ir (). clang_decls ().Lookup (
1488
+ .Get (context.clang_decls ().Lookup (
1489
1489
cast<clang::Decl>(clang_decl->getParent ())))
1490
1490
.inst_id );
1491
1491
return {
@@ -1659,7 +1659,7 @@ static auto ImportFunction(Context& context, SemIR::LocId loc_id,
1659
1659
.virtual_index = virtual_index,
1660
1660
.self_param_id = FindSelfPattern (
1661
1661
context, function_params_insts->implicit_param_patterns_id ),
1662
- .clang_decl_id = context.sem_ir (). clang_decls ().Add (
1662
+ .clang_decl_id = context.clang_decls ().Add (
1663
1663
{.decl = clang_decl, .inst_id = decl_id})}};
1664
1664
1665
1665
function_decl.function_id = context.functions ().Add (function_info);
@@ -1815,7 +1815,7 @@ static auto ImportVarDecl(Context& context, SemIR::LocId loc_id,
1815
1815
SemIR::InstId var_storage_inst_id =
1816
1816
AddPlaceholderInstInNoBlock (context, {loc_id, var_storage});
1817
1817
1818
- auto clang_decl_id = context.sem_ir (). clang_decls ().Add (
1818
+ auto clang_decl_id = context.clang_decls ().Add (
1819
1819
{.decl = var_decl, .inst_id = var_storage_inst_id});
1820
1820
1821
1821
// Entity name referring to a Clang decl for mangling.
@@ -1865,8 +1865,7 @@ static auto ImportDeclAfterDependencies(Context& context, SemIR::LocId loc_id,
1865
1865
type.getAsString ()));
1866
1866
return SemIR::ErrorInst::InstId;
1867
1867
}
1868
- context.sem_ir ().clang_decls ().Add (
1869
- {.decl = clang_decl, .inst_id = type_inst_id});
1868
+ context.clang_decls ().Add ({.decl = clang_decl, .inst_id = type_inst_id});
1870
1869
return type_inst_id;
1871
1870
}
1872
1871
if (isa<clang::FieldDecl, clang::IndirectFieldDecl>(clang_decl)) {
@@ -2402,8 +2401,8 @@ auto ImportClassDefinitionForClangDecl(Context& context, SemIR::LocId loc_id,
2402
2401
clang::ASTUnit* ast = context.sem_ir ().clang_ast_unit ();
2403
2402
CARBON_CHECK (ast);
2404
2403
2405
- auto * clang_decl = cast<clang::TagDecl>(
2406
- context. sem_ir () .clang_decls ().Get (clang_decl_id).decl );
2404
+ auto * clang_decl =
2405
+ cast<clang::TagDecl>(context .clang_decls ().Get (clang_decl_id).decl );
2407
2406
auto class_inst_id = context.types ().GetAsTypeInstId (
2408
2407
context.classes ().Get (class_id).first_owning_decl_id );
2409
2408
0 commit comments