mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 08:44:41 +01:00
Make C++ enum types impl Core.Copy. (#7013)
Remove special-case handling in conversion logic for C++ enum types, synthesize a custom witness of `Core.Copy` using the `primitive_copy` builtin function.
This commit is contained in:
+19
-2
@@ -40,7 +40,16 @@ fn F() {
|
||||
// CHECK:STDOUT: %Enum: type = class_type @Enum [concrete]
|
||||
// CHECK:STDOUT: %pattern_type.ebf: type = pattern_type %Enum [concrete]
|
||||
// CHECK:STDOUT: %int_0: %Enum = int_value 0 [concrete]
|
||||
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
||||
// CHECK:STDOUT: %Enum.Op.type: type = fn_type @Enum.Op [concrete]
|
||||
// CHECK:STDOUT: %Enum.Op: %Enum.Op.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %custom_witness.0a8: <witness> = custom_witness (%Enum.Op), @Copy [concrete]
|
||||
// CHECK:STDOUT: %Copy.facet.897: %Copy.type = facet_value %Enum, (%custom_witness.0a8) [concrete]
|
||||
// CHECK:STDOUT: %Copy.WithSelf.Op.type.67c: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.897) [concrete]
|
||||
// CHECK:STDOUT: %.76d: type = fn_type_with_self_type %Copy.WithSelf.Op.type.67c, %Copy.facet.897 [concrete]
|
||||
// CHECK:STDOUT: %Enum.Op.bound.3a0: <bound method> = bound_method %int_0, %Enum.Op [concrete]
|
||||
// CHECK:STDOUT: %int_1: %Enum = int_value 1 [concrete]
|
||||
// CHECK:STDOUT: %Enum.Op.bound.87b: <bound method> = bound_method %int_1, %Enum.Op [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
@@ -67,7 +76,10 @@ fn F() {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc12_21: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Enum.ref.loc12_24: type = name_ref Enum, imports.%Enum.decl [concrete = constants.%Enum]
|
||||
// CHECK:STDOUT: %a.ref.loc12: %Enum = name_ref a, imports.%int_0 [concrete = constants.%int_0]
|
||||
// CHECK:STDOUT: assign %a.var, %a.ref.loc12
|
||||
// CHECK:STDOUT: %impl.elem0.loc12: %.76d = impl_witness_access constants.%custom_witness.0a8, element0 [concrete = constants.%Enum.Op]
|
||||
// CHECK:STDOUT: %bound_method.loc12: <bound method> = bound_method %a.ref.loc12, %impl.elem0.loc12 [concrete = constants.%Enum.Op.bound.3a0]
|
||||
// CHECK:STDOUT: %Enum.Op.call.loc12: init %Enum = call %bound_method.loc12(%a.ref.loc12) [concrete = constants.%int_0]
|
||||
// CHECK:STDOUT: assign %a.var, %Enum.Op.call.loc12
|
||||
// CHECK:STDOUT: %.loc12: type = splice_block %Enum.ref.loc12_13 [concrete = constants.%Enum] {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc12_10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Enum.ref.loc12_13: type = name_ref Enum, imports.%Enum.decl [concrete = constants.%Enum]
|
||||
@@ -77,7 +89,12 @@ fn F() {
|
||||
// CHECK:STDOUT: %Cpp.ref.loc14: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
|
||||
// CHECK:STDOUT: %Enum.ref.loc14: type = name_ref Enum, imports.%Enum.decl [concrete = constants.%Enum]
|
||||
// CHECK:STDOUT: %b.ref: %Enum = name_ref b, imports.%int_1 [concrete = constants.%int_1]
|
||||
// CHECK:STDOUT: assign %a.ref.loc14, %b.ref
|
||||
// CHECK:STDOUT: %impl.elem0.loc14: %.76d = impl_witness_access constants.%custom_witness.0a8, element0 [concrete = constants.%Enum.Op]
|
||||
// CHECK:STDOUT: %bound_method.loc14: <bound method> = bound_method %b.ref, %impl.elem0.loc14 [concrete = constants.%Enum.Op.bound.87b]
|
||||
// CHECK:STDOUT: %Enum.Op.call.loc14: init %Enum = call %bound_method.loc14(%b.ref) [concrete = constants.%int_1]
|
||||
// CHECK:STDOUT: assign %a.ref.loc14, %Enum.Op.call.loc14
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @Enum.Op(%self.param: %Enum) -> out %return.param: %Enum = "primitive_copy";
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user