mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 19:51:09 +01:00
adds a field to SemIR::Interface to indicate whether it is a core interface (#7091)
The existing `GetCoreInterface` has linear-time complexity and adds more than the search criteria to the `CoreInterfaceCache`. Adding a new field to `Interface` changes this operation when building packages other than `Core`, as this should only be set for the core library.
This commit is contained in:
@@ -87,6 +87,18 @@ static auto BuildInterfaceDecl(Context& context,
|
||||
} else {
|
||||
// Create a new interface if this isn't a valid redeclaration.
|
||||
interface_info.generic_id = BuildGenericDecl(context, decl_inst_id);
|
||||
|
||||
if (context.sem_ir().package_id() == PackageNameId::Core) {
|
||||
auto name = context.names().GetIRBaseName(interface_info.name_id);
|
||||
interface_info.core_interface =
|
||||
llvm::StringSwitch<SemIR::CoreInterface>(name)
|
||||
.Case("Copy", SemIR::CoreInterface::Copy)
|
||||
.Case("CppUnsafeDeref", SemIR::CoreInterface::CppUnsafeDeref)
|
||||
.Case("Default", SemIR::CoreInterface::Default)
|
||||
.Case("Destroy", SemIR::CoreInterface::Destroy)
|
||||
.Case("IntFitsIn", SemIR::CoreInterface::IntFitsIn)
|
||||
.Default(SemIR::CoreInterface::Unknown);
|
||||
}
|
||||
interface_decl.interface_id = context.interfaces().Add(interface_info);
|
||||
if (interface_info.has_parameters()) {
|
||||
interface_decl.type_id =
|
||||
|
||||
Reference in New Issue
Block a user