Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions toolchain/check/eval_inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@ auto EvalConstantInst(Context& context, SemIR::Converted inst)
context.constant_values().Get(inst.result_id));
}

// TODO: This should not be necessary since the constant kind is
// WheneverPossible.
auto EvalConstantInst(Context& /*context*/, SemIR::CppOverloadSetValue inst)
-> ConstantEvalResult {
return ConstantEvalResult::NewSamePhase(SemIR::StructValue{
.type_id = inst.type_id, .elements_id = SemIR::InstBlockId::Empty});
}

auto EvalConstantInst(Context& /*context*/, SemIR::Deref /*inst*/)
-> ConstantEvalResult {
// TODO: Handle this.
Expand Down
30 changes: 21 additions & 9 deletions toolchain/check/import_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,24 +1845,33 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver, InstT inst)
resolver, {.type_id = SemIR::TypeType::TypeId, .inner_id = inner_id});
}

static auto TryResolveTypedInst(ImportRefResolver& resolver,
SemIR::CppOverloadSetType inst)
-> ResolveResult {
static auto HandleUnsupportedCppOverloadSet(ImportRefResolver& resolver,
SemIR::CppOverloadSetId id) {
// Supporting C++ overload resolution of imported functions is a large task,
// which might require serializing and deserializing AST for using decl ids,
// using modules and/or linking ASTs.
resolver.local_context().TODO(
SemIR::LocId::None,
llvm::formatv("Unsupported: Importing C++ function `{0}` indirectly",
resolver.import_ir().names().GetAsStringIfIdentifier(
resolver.import_ir()
.cpp_overload_sets()
.Get(inst.overload_set_id)
.name_id)));
llvm::formatv(
"Unsupported: Importing C++ function `{0}` indirectly",
resolver.import_ir().names().GetAsStringIfIdentifier(
resolver.import_ir().cpp_overload_sets().Get(id).name_id)));
return ResolveResult::Done(SemIR::ErrorInst::ConstantId,
SemIR::ErrorInst::InstId);
}

static auto TryResolveTypedInst(ImportRefResolver& resolver,
SemIR::CppOverloadSetType inst)
-> ResolveResult {
return HandleUnsupportedCppOverloadSet(resolver, inst.overload_set_id);
}

static auto TryResolveTypedInst(ImportRefResolver& resolver,
SemIR::CppOverloadSetValue inst)
-> ResolveResult {
return HandleUnsupportedCppOverloadSet(resolver, inst.overload_set_id);
}

static auto TryResolveTypedInst(ImportRefResolver& resolver,
SemIR::ExportDecl inst) -> ResolveResult {
auto value_id = GetLocalConstantId(resolver, inst.value_id);
Expand Down Expand Up @@ -3188,6 +3197,9 @@ static auto TryResolveInstCanonical(ImportRefResolver& resolver,
case CARBON_KIND(SemIR::CppOverloadSetType inst): {
return TryResolveTypedInst(resolver, inst);
}
case CARBON_KIND(SemIR::CppOverloadSetValue inst): {
return TryResolveTypedInst(resolver, inst);
}
case CARBON_KIND(SemIR::ExportDecl inst): {
return TryResolveTypedInst(resolver, inst);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn G(x: Cpp.X) {
// CHECK:STDOUT: inst36: {kind: NameRef, arg0: name0, arg1: inst16, type: type(inst(NamespaceType))}
// CHECK:STDOUT: inst37: {kind: CppOverloadSetType, arg0: cpp_overload_set0, arg1: specific<none>, type: type(TypeType)}
// CHECK:STDOUT: inst38: {kind: CppOverloadSetValue, arg0: cpp_overload_set0, type: type(inst37)}
// CHECK:STDOUT: inst39: {kind: StructValue, arg0: inst_block_empty, type: type(inst37)}
// CHECK:STDOUT: inst39: {kind: CppOverloadSetValue, arg0: cpp_overload_set0, type: type(inst37)}
// CHECK:STDOUT: inst40: {kind: NameRef, arg0: name4, arg1: inst38, type: type(inst37)}
// CHECK:STDOUT: inst41: {kind: FunctionDecl, arg0: function1, arg1: inst_block_empty, type: type(inst42)}
// CHECK:STDOUT: inst42: {kind: FunctionType, arg0: function1, arg1: specific<none>, type: type(TypeType)}
Expand Down
6 changes: 3 additions & 3 deletions toolchain/check/testdata/interop/cpp/builtins.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ fn F() {
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete]
// CHECK:STDOUT: %pattern_type.4a9: type = pattern_type %u32 [concrete]
// CHECK:STDOUT: %.15a: type = cpp_overload_set_type @unsigned_int.foo [concrete]
// CHECK:STDOUT: %empty_struct: %.15a = struct_value () [concrete]
// CHECK:STDOUT: %.afb: %.15a = cpp_overload_set_value @unsigned_int.foo [concrete]
// CHECK:STDOUT: %ptr.d47: type = ptr_type %unsigned_int [concrete]
// CHECK:STDOUT: %unsigned_int.foo.type: type = fn_type @unsigned_int.foo [concrete]
// CHECK:STDOUT: %unsigned_int.foo: %unsigned_int.foo.type = struct_value () [concrete]
Expand All @@ -566,7 +566,7 @@ fn F() {
// CHECK:STDOUT: import Cpp//...
// CHECK:STDOUT: }
// CHECK:STDOUT: %unsigned_int.decl: type = class_decl @unsigned_int [concrete = constants.%unsigned_int] {} {}
// CHECK:STDOUT: %.afb: %.15a = cpp_overload_set_value @unsigned_int.foo [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.afb: %.15a = cpp_overload_set_value @unsigned_int.foo [concrete = constants.%.afb]
// CHECK:STDOUT: %unsigned_int.foo.decl: %unsigned_int.foo.type = fn_decl @unsigned_int.foo [concrete = constants.%unsigned_int.foo] {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: } {
Expand All @@ -590,7 +590,7 @@ fn F() {
// CHECK:STDOUT: %x.patt: %pattern_type.4a9 = binding_pattern x [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %unsigned_int.ref.loc13: ref %unsigned_int = name_ref unsigned_int, %unsigned_int
// CHECK:STDOUT: %foo.ref: %.15a = name_ref foo, imports.%.afb [concrete = constants.%empty_struct]
// CHECK:STDOUT: %foo.ref: %.15a = name_ref foo, imports.%.afb [concrete = constants.%.afb]
// CHECK:STDOUT: %bound_method.loc13: <bound method> = bound_method %unsigned_int.ref.loc13, %foo.ref
// CHECK:STDOUT: %addr.loc13: %ptr.d47 = addr_of %unsigned_int.ref.loc13
// CHECK:STDOUT: %unsigned_int.foo.call: init %u32 = call imports.%unsigned_int.foo.decl(%addr.loc13)
Expand Down
24 changes: 12 additions & 12 deletions toolchain/check/testdata/interop/cpp/class/access.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,13 @@ fn F() {
// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %.177: type = cpp_overload_set_type @S.foo [concrete]
// CHECK:STDOUT: %empty_struct: %.177 = struct_value () [concrete]
// CHECK:STDOUT: %.dcb: %.177 = cpp_overload_set_value @S.foo [concrete]
// CHECK:STDOUT: %S.foo.type: type = fn_type @S.foo [concrete]
// CHECK:STDOUT: %S.foo: %S.foo.type = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %.dcb: %.177 = cpp_overload_set_value @S.foo [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.dcb: %.177 = cpp_overload_set_value @S.foo [concrete = constants.%.dcb]
// CHECK:STDOUT: %S.foo.decl: %S.foo.type = fn_decl @S.foo [concrete = constants.%S.foo] {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: } {
Expand All @@ -511,7 +511,7 @@ fn F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %s.ref: %ptr.5c7 = name_ref s, %s
// CHECK:STDOUT: %.loc8: ref %S = deref %s.ref
// CHECK:STDOUT: %foo.ref: %.177 = name_ref foo, imports.%.dcb [concrete = constants.%empty_struct]
// CHECK:STDOUT: %foo.ref: %.177 = name_ref foo, imports.%.dcb [concrete = constants.%.dcb]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc8, %foo.ref
// CHECK:STDOUT: %addr: %ptr.5c7 = addr_of %.loc8
// CHECK:STDOUT: %S.foo.call: init %empty_tuple.type = call imports.%S.foo.decl(%addr)
Expand All @@ -524,12 +524,12 @@ fn F() {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %C: type = class_type @C [concrete]
// CHECK:STDOUT: %.d40: type = cpp_overload_set_type @C__carbon_thunk [concrete]
// CHECK:STDOUT: %empty_struct.e73: %.d40 = struct_value () [concrete]
// CHECK:STDOUT: %.40b: %.d40 = cpp_overload_set_value @C__carbon_thunk [concrete]
// CHECK:STDOUT: %ptr.d9e: type = ptr_type %C [concrete]
// CHECK:STDOUT: %C__carbon_thunk.type: type = fn_type @C__carbon_thunk [concrete]
// CHECK:STDOUT: %C__carbon_thunk: %C__carbon_thunk.type = struct_value () [concrete]
// CHECK:STDOUT: %.cd1: type = cpp_overload_set_type @C.foo [concrete]
// CHECK:STDOUT: %empty_struct.b85: %.cd1 = struct_value () [concrete]
// CHECK:STDOUT: %.e4a: %.cd1 = cpp_overload_set_value @C.foo [concrete]
// CHECK:STDOUT: %C.foo.type: type = fn_type @C.foo [concrete]
// CHECK:STDOUT: %C.foo: %C.foo.type = struct_value () [concrete]
// CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanAggregateDestroy>> [concrete]
Expand All @@ -544,29 +544,29 @@ fn F() {
// CHECK:STDOUT: import Cpp//...
// CHECK:STDOUT: }
// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
// CHECK:STDOUT: %.40b: %.d40 = cpp_overload_set_value @C__carbon_thunk [concrete = constants.%empty_struct.e73]
// CHECK:STDOUT: %.40b: %.d40 = cpp_overload_set_value @C__carbon_thunk [concrete = constants.%.40b]
// CHECK:STDOUT: %C__carbon_thunk.decl: %C__carbon_thunk.type = fn_decl @C__carbon_thunk [concrete = constants.%C__carbon_thunk] {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: } {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT: %.e4a: %.cd1 = cpp_overload_set_value @C.foo [concrete = constants.%empty_struct.b85]
// CHECK:STDOUT: %.e4a: %.cd1 = cpp_overload_set_value @C.foo [concrete = constants.%.e4a]
// CHECK:STDOUT: %C.foo.decl: %C.foo.type = fn_decl @C.foo [concrete = constants.%C.foo] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %C.ref.loc8_6: type = name_ref C, imports.%C.decl [concrete = constants.%C]
// CHECK:STDOUT: %C.ref.loc8_8: %.d40 = name_ref C, imports.%.40b [concrete = constants.%empty_struct.e73]
// CHECK:STDOUT: %C.ref.loc8_8: %.d40 = name_ref C, imports.%.40b [concrete = constants.%.40b]
// CHECK:STDOUT: %.loc8_11.1: ref %C = temporary_storage
// CHECK:STDOUT: %addr.loc8_11.1: %ptr.d9e = addr_of %.loc8_11.1
// CHECK:STDOUT: %C__carbon_thunk.call: init %empty_tuple.type = call imports.%C__carbon_thunk.decl(%addr.loc8_11.1)
// CHECK:STDOUT: %.loc8_11.2: init %C = in_place_init %C__carbon_thunk.call, %.loc8_11.1
// CHECK:STDOUT: %.loc8_11.3: ref %C = temporary %.loc8_11.1, %.loc8_11.2
// CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %C.ref.loc9: type = name_ref C, imports.%C.decl [concrete = constants.%C]
// CHECK:STDOUT: %foo.ref: %.cd1 = name_ref foo, imports.%.e4a [concrete = constants.%empty_struct.b85]
// CHECK:STDOUT: %foo.ref: %.cd1 = name_ref foo, imports.%.e4a [concrete = constants.%.e4a]
// CHECK:STDOUT: %C.foo.call: init %empty_tuple.type = call imports.%C.foo.decl()
// CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%C, () [concrete = constants.%facet_value]
// CHECK:STDOUT: %.loc8_11.4: %type_where = converted constants.%C, %facet_value [concrete = constants.%facet_value]
Expand All @@ -584,7 +584,7 @@ fn F() {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %DerivedPublic: type = class_type @DerivedPublic [concrete]
// CHECK:STDOUT: %.5a6: type = cpp_overload_set_type @Base.foo [concrete]
// CHECK:STDOUT: %empty_struct: %.5a6 = struct_value () [concrete]
// CHECK:STDOUT: %.607: %.5a6 = cpp_overload_set_value @Base.foo [concrete]
// CHECK:STDOUT: %Base.foo.type: type = fn_type @Base.foo [concrete]
// CHECK:STDOUT: %Base.foo: %Base.foo.type = struct_value () [concrete]
// CHECK:STDOUT: }
Expand All @@ -595,15 +595,15 @@ fn F() {
// CHECK:STDOUT: import Cpp//...
// CHECK:STDOUT: }
// CHECK:STDOUT: %DerivedPublic.decl: type = class_decl @DerivedPublic [concrete = constants.%DerivedPublic] {} {}
// CHECK:STDOUT: %.607: %.5a6 = cpp_overload_set_value @Base.foo [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.607: %.5a6 = cpp_overload_set_value @Base.foo [concrete = constants.%.607]
// CHECK:STDOUT: %Base.foo.decl: %Base.foo.type = fn_decl @Base.foo [concrete = constants.%Base.foo] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %DerivedPublic.ref: type = name_ref DerivedPublic, imports.%DerivedPublic.decl [concrete = constants.%DerivedPublic]
// CHECK:STDOUT: %foo.ref: %.5a6 = name_ref foo, imports.%.607 [concrete = constants.%empty_struct]
// CHECK:STDOUT: %foo.ref: %.5a6 = name_ref foo, imports.%.607 [concrete = constants.%.607]
// CHECK:STDOUT: %Base.foo.call: init %empty_tuple.type = call imports.%Base.foo.decl()
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
Expand Down
Loading
Loading