mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:40:10 +01:00
This change partially implements [PR #7362], which revises how objects are destroyed. It is a partial implementation for two reasons: 1. This change moves `Destroy.Op`'s current behaviour into `Destroy.SubobjectDestroy`, but it doesn't add support for objects with non-trivial destruction. 2. `Destroy.SubobjectDestroy` is a workaround for `require impls SubobjectDestroy`. We aren't able to use the latter until the dependents add their requirements' implementations to their own witness tables. [PR #7362]: https://github.com/carbon-language/carbon-lang/pulls/7362
470 lines
30 KiB
Plaintext
470 lines
30 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/as/const.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/as/const.carbon
|
|
|
|
// --- add_const.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class X {}
|
|
|
|
fn Init() -> X;
|
|
let value: X = Init();
|
|
var reference: X;
|
|
let ptr: X* = &reference;
|
|
|
|
fn Use() {
|
|
// TODO: Should some of these be valid without the `as`?
|
|
//@dump-sem-ir-begin
|
|
var unused i: const X = Init() as const X;
|
|
let unused v: const X = value as const X;
|
|
let unused a: const X* = &(reference as const X);
|
|
let unused b: const X* = ptr as const X*;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- remove_const.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class X {}
|
|
|
|
fn Init() -> const X;
|
|
let value: const X = Init();
|
|
|
|
fn Use() {
|
|
// TODO: Should some of these be valid without the `as`?
|
|
//@dump-sem-ir-begin
|
|
var unused i: X = Init() as X;
|
|
let unused v: X = value as X;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- fail_cannot_remove_const.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class X {}
|
|
|
|
var reference: const X;
|
|
let ptr: const X* = &reference;
|
|
|
|
fn Use() {
|
|
// CHECK:STDERR: fail_cannot_remove_const.carbon:[[@LINE+7]]:24: error: cannot convert expression of type `const X` to `X` with `as` [ConversionFailure]
|
|
// CHECK:STDERR: let unused a: X* = &(reference as X);
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
|
// CHECK:STDERR: fail_cannot_remove_const.carbon:[[@LINE+4]]:24: note: type `const X` does not implement interface `Core.As(X)` [MissingImplInMemberAccessInContext]
|
|
// CHECK:STDERR: let unused a: X* = &(reference as X);
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
let unused a: X* = &(reference as X);
|
|
// CHECK:STDERR: fail_cannot_remove_const.carbon:[[@LINE+7]]:22: error: cannot convert expression of type `const X*` to `X*` with `as` [ConversionFailure]
|
|
// CHECK:STDERR: let unused b: X* = ptr as X*;
|
|
// CHECK:STDERR: ^~~~~~~~~
|
|
// CHECK:STDERR: fail_cannot_remove_const.carbon:[[@LINE+4]]:22: note: type `const X*` does not implement interface `Core.As(X*)` [MissingImplInMemberAccessInContext]
|
|
// CHECK:STDERR: let unused b: X* = ptr as X*;
|
|
// CHECK:STDERR: ^~~~~~~~~
|
|
// CHECK:STDERR:
|
|
let unused b: X* = ptr as X*;
|
|
}
|
|
|
|
// --- unsafe_remove_const.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class X {}
|
|
|
|
var reference: const X;
|
|
let ptr: const X* = &reference;
|
|
|
|
fn Use() {
|
|
//@dump-sem-ir-begin
|
|
let unused a: X* = &(reference unsafe as X);
|
|
let unused b: X* = ptr unsafe as X*;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// CHECK:STDOUT: --- add_const.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %X: type = class_type @X [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %pattern_type.6cb: type = pattern_type %X [concrete]
|
|
// CHECK:STDOUT: %Init.type: type = fn_type @Init [concrete]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %Init: %Init.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %ptr.db8: type = ptr_type %X [concrete]
|
|
// CHECK:STDOUT: %const: type = const_type %X [concrete]
|
|
// CHECK:STDOUT: %pattern_type.dfd: type = pattern_type %const [concrete]
|
|
// CHECK:STDOUT: %i.patt: %pattern_type.dfd = ref_binding_pattern i [concrete]
|
|
// CHECK:STDOUT: %i.var_patt: %pattern_type.dfd = var_pattern %i.patt [concrete]
|
|
// CHECK:STDOUT: %v.patt: %pattern_type.dfd = value_binding_pattern v [concrete]
|
|
// CHECK:STDOUT: %ptr.faf: type = ptr_type %const [concrete]
|
|
// CHECK:STDOUT: %pattern_type.7f7: type = pattern_type %ptr.faf [concrete]
|
|
// CHECK:STDOUT: %a.patt: %pattern_type.7f7 = value_binding_pattern a [concrete]
|
|
// CHECK:STDOUT: %reference.var: ref %const = var_storage file.%reference.var_patt [concrete]
|
|
// CHECK:STDOUT: %addr.daa: %ptr.faf = addr_of %reference.var [concrete]
|
|
// CHECK:STDOUT: %b.patt: %pattern_type.7f7 = value_binding_pattern b [concrete]
|
|
// CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: %self.param_patt.52f: %pattern_type.a96 = ref_param_pattern [concrete]
|
|
// CHECK:STDOUT: %self.patt.4b1: %pattern_type.a96 = wrapper_binding_pattern self, %self.param_patt.52f [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.1: type = fn_type @Destroy.WithSelf.SubobjectDestroy.loc14_3.1 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.d01daf.1: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.1 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.ef016f.1: type = fn_type @Destroy.WithSelf.Op.loc14_3.1 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.403171.1: %Destroy.WithSelf.Op.type.ef016f.1 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %self.param_patt.925: %pattern_type.6cb = ref_param_pattern [concrete]
|
|
// CHECK:STDOUT: %self.patt.617: %pattern_type.6cb = wrapper_binding_pattern self, %self.param_patt.925 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.2: type = fn_type @Destroy.WithSelf.SubobjectDestroy.loc14_3.2 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.d01daf.2: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.2 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.ef016f.2: type = fn_type @Destroy.WithSelf.Op.loc14_3.2 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.403171.2: %Destroy.WithSelf.Op.type.ef016f.2 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %self.param_patt.b9b: %pattern_type.dfd = ref_param_pattern [concrete]
|
|
// CHECK:STDOUT: %self.patt.a99: %pattern_type.dfd = wrapper_binding_pattern self, %self.param_patt.b9b [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.3: type = fn_type @Destroy.WithSelf.SubobjectDestroy.loc14_3.3 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.d01daf.3: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.3 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.ef016f.3: type = fn_type @Destroy.WithSelf.Op.loc14_3.3 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.403171.3: %Destroy.WithSelf.Op.type.ef016f.3 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.type.fbceb5.3: type = fn_type @Destroy.WithSelf.SelfDestruct.loc14_3.3 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.db3fdb.3: %Destroy.WithSelf.SelfDestruct.type.fbceb5.3 = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generated {
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.decl.763c71.1: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.1 = fn_decl @Destroy.WithSelf.SubobjectDestroy.loc14_3.1 [concrete = constants.%Destroy.WithSelf.SubobjectDestroy.d01daf.1] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.a96 = ref_param_pattern [concrete = constants.%self.param_patt.52f]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.a96 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.4b1]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %empty_struct_type = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %empty_struct_type = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.decl.5f94cf.1: %Destroy.WithSelf.Op.type.ef016f.1 = fn_decl @Destroy.WithSelf.Op.loc14_3.1 [concrete = constants.%Destroy.WithSelf.Op.403171.1] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.a96 = ref_param_pattern [concrete = constants.%self.param_patt.52f]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.a96 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.4b1]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %empty_struct_type = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %empty_struct_type = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.decl.763c71.2: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.2 = fn_decl @Destroy.WithSelf.SubobjectDestroy.loc14_3.2 [concrete = constants.%Destroy.WithSelf.SubobjectDestroy.d01daf.2] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.6cb = ref_param_pattern [concrete = constants.%self.param_patt.925]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.6cb = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.617]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %X = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %X = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.decl.5f94cf.2: %Destroy.WithSelf.Op.type.ef016f.2 = fn_decl @Destroy.WithSelf.Op.loc14_3.2 [concrete = constants.%Destroy.WithSelf.Op.403171.2] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.6cb = ref_param_pattern [concrete = constants.%self.param_patt.925]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.6cb = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.617]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %X = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %X = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.decl.763c71.3: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.3 = fn_decl @Destroy.WithSelf.SubobjectDestroy.loc14_3.3 [concrete = constants.%Destroy.WithSelf.SubobjectDestroy.d01daf.3] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.dfd = ref_param_pattern [concrete = constants.%self.param_patt.b9b]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.dfd = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.a99]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %const = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %const = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.decl.5f94cf.3: %Destroy.WithSelf.Op.type.ef016f.3 = fn_decl @Destroy.WithSelf.Op.loc14_3.3 [concrete = constants.%Destroy.WithSelf.Op.403171.3] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.dfd = ref_param_pattern [concrete = constants.%self.param_patt.b9b]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.dfd = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.a99]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %const = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %const = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Use() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %i.var: ref %const = var_storage %i.var_patt
|
|
// CHECK:STDOUT: %Init.ref: %Init.type = name_ref Init, file.%Init.decl [concrete = constants.%Init]
|
|
// CHECK:STDOUT: %.loc14_3: ref %const = splice_block %i.var {}
|
|
// CHECK:STDOUT: %Init.call: init %X to %.loc14_3 = call %Init.ref()
|
|
// CHECK:STDOUT: %X.ref.loc14_43: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc14_37: type = const_type %X.ref.loc14_43 [concrete = constants.%const]
|
|
// CHECK:STDOUT: %.loc14_34.1: init %const = as_compatible %Init.call
|
|
// CHECK:STDOUT: %.loc14_34.2: init %const = converted %Init.call, %.loc14_34.1
|
|
// CHECK:STDOUT: assign %i.var, %.loc14_34.2
|
|
// CHECK:STDOUT: %.loc14_17: type = splice_block %const.loc14_17 [concrete = constants.%const] {
|
|
// CHECK:STDOUT: %X.ref.loc14_23: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc14_17: type = const_type %X.ref.loc14_23 [concrete = constants.%const]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %i: ref %const = wrapper_binding i, %i.var
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %i.patt: %pattern_type.dfd = ref_binding_pattern i [concrete = constants.%i.patt]
|
|
// CHECK:STDOUT: %i.var_patt: %pattern_type.dfd = var_pattern %i.patt [concrete = constants.%i.var_patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %value.ref: %X = name_ref value, file.%value
|
|
// CHECK:STDOUT: %X.ref.loc15_42: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc15_36: type = const_type %X.ref.loc15_42 [concrete = constants.%const]
|
|
// CHECK:STDOUT: %.loc15_33.1: %const = as_compatible %value.ref
|
|
// CHECK:STDOUT: %.loc15_33.2: %const = converted %value.ref, %.loc15_33.1
|
|
// CHECK:STDOUT: %.loc15_17: type = splice_block %const.loc15_17 [concrete = constants.%const] {
|
|
// CHECK:STDOUT: %X.ref.loc15_23: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc15_17: type = const_type %X.ref.loc15_23 [concrete = constants.%const]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %v: %const = wrapper_binding v, %.loc15_33.2
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %v.patt: %pattern_type.dfd = value_binding_pattern v [concrete = constants.%v.patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %reference.ref: ref %X = name_ref reference, file.%reference [concrete = file.%reference.var]
|
|
// CHECK:STDOUT: %X.ref.loc16_49: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc16_43: type = const_type %X.ref.loc16_49 [concrete = constants.%const]
|
|
// CHECK:STDOUT: %.loc16_40.1: ref %const = as_compatible %reference.ref [concrete = constants.%reference.var]
|
|
// CHECK:STDOUT: %.loc16_40.2: ref %const = converted %reference.ref, %.loc16_40.1 [concrete = constants.%reference.var]
|
|
// CHECK:STDOUT: %addr: %ptr.faf = addr_of %.loc16_40.2 [concrete = constants.%addr.daa]
|
|
// CHECK:STDOUT: %.loc16_24: type = splice_block %ptr.loc16 [concrete = constants.%ptr.faf] {
|
|
// CHECK:STDOUT: %X.ref.loc16_23: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc16_17: type = const_type %X.ref.loc16_23 [concrete = constants.%const]
|
|
// CHECK:STDOUT: %ptr.loc16: type = ptr_type %const.loc16_17 [concrete = constants.%ptr.faf]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %a: %ptr.faf = wrapper_binding a, %addr
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %a.patt: %pattern_type.7f7 = value_binding_pattern a [concrete = constants.%a.patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %ptr.ref: %ptr.db8 = name_ref ptr, file.%ptr.loc9_8
|
|
// CHECK:STDOUT: %X.ref.loc17_41: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc17_35: type = const_type %X.ref.loc17_41 [concrete = constants.%const]
|
|
// CHECK:STDOUT: %ptr.loc17_42: type = ptr_type %const.loc17_35 [concrete = constants.%ptr.faf]
|
|
// CHECK:STDOUT: %.loc17_32.1: %ptr.faf = as_compatible %ptr.ref
|
|
// CHECK:STDOUT: %.loc17_32.2: %ptr.faf = converted %ptr.ref, %.loc17_32.1
|
|
// CHECK:STDOUT: %.loc17_24: type = splice_block %ptr.loc17_24 [concrete = constants.%ptr.faf] {
|
|
// CHECK:STDOUT: %X.ref.loc17_23: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %const.loc17_17: type = const_type %X.ref.loc17_23 [concrete = constants.%const]
|
|
// CHECK:STDOUT: %ptr.loc17_24: type = ptr_type %const.loc17_17 [concrete = constants.%ptr.faf]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %b: %ptr.faf = wrapper_binding b, %.loc17_32.2
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %b.patt: %pattern_type.7f7 = value_binding_pattern b [concrete = constants.%b.patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.bound: <bound method> = bound_method %i.var, constants.%Destroy.WithSelf.SelfDestruct.db3fdb.3
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.call: init %empty_tuple.type = call %Destroy.WithSelf.SelfDestruct.bound(%i.var)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SubobjectDestroy.loc14_3.1(%self.param: ref %empty_struct_type) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.Op.loc14_3.1(%self.param: ref %empty_struct_type) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SelfDestruct.loc14_3.1(%self.param: ref %empty_struct_type) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.Op.decl.5f94cf.1(%self.param)
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.SubobjectDestroy.decl.763c71.1(%self.param)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SubobjectDestroy.loc14_3.2(%self.param: ref %X) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.Op.loc14_3.2(%self.param: ref %X) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SelfDestruct.loc14_3.2(%self.param: ref %X) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.Op.decl.5f94cf.2(%self.param)
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.SubobjectDestroy.decl.763c71.2(%self.param)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SubobjectDestroy.loc14_3.3(%self.param: ref %const) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.Op.loc14_3.3(%self.param: ref %const) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SelfDestruct.loc14_3.3(%self.param: ref %const) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.Op.decl.5f94cf.3(%self.param)
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.SubobjectDestroy.decl.763c71.3(%self.param)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @__global_init() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- remove_const.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %X: type = class_type @X [concrete]
|
|
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
|
|
// CHECK:STDOUT: %const: type = const_type %X [concrete]
|
|
// CHECK:STDOUT: %Init.type: type = fn_type @Init [concrete]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %Init: %Init.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %pattern_type.6cb: type = pattern_type %X [concrete]
|
|
// CHECK:STDOUT: %i.patt: %pattern_type.6cb = ref_binding_pattern i [concrete]
|
|
// CHECK:STDOUT: %i.var_patt: %pattern_type.6cb = var_pattern %i.patt [concrete]
|
|
// CHECK:STDOUT: %v.patt: %pattern_type.6cb = value_binding_pattern v [concrete]
|
|
// CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
|
|
// CHECK:STDOUT: %self.param_patt.52f: %pattern_type.a96 = ref_param_pattern [concrete]
|
|
// CHECK:STDOUT: %self.patt.4b1: %pattern_type.a96 = wrapper_binding_pattern self, %self.param_patt.52f [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.1: type = fn_type @Destroy.WithSelf.SubobjectDestroy.loc12_3.1 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.d01daf.1: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.1 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.ef016f.1: type = fn_type @Destroy.WithSelf.Op.loc12_3.1 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.403171.1: %Destroy.WithSelf.Op.type.ef016f.1 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %self.param_patt.925: %pattern_type.6cb = ref_param_pattern [concrete]
|
|
// CHECK:STDOUT: %self.patt.617: %pattern_type.6cb = wrapper_binding_pattern self, %self.param_patt.925 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.2: type = fn_type @Destroy.WithSelf.SubobjectDestroy.loc12_3.2 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.d01daf.2: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.2 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.type.ef016f.2: type = fn_type @Destroy.WithSelf.Op.loc12_3.2 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.403171.2: %Destroy.WithSelf.Op.type.ef016f.2 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.type.fbceb5.2: type = fn_type @Destroy.WithSelf.SelfDestruct.loc12_3.2 [concrete]
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.db3fdb.2: %Destroy.WithSelf.SelfDestruct.type.fbceb5.2 = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generated {
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.decl.763c71.1: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.1 = fn_decl @Destroy.WithSelf.SubobjectDestroy.loc12_3.1 [concrete = constants.%Destroy.WithSelf.SubobjectDestroy.d01daf.1] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.a96 = ref_param_pattern [concrete = constants.%self.param_patt.52f]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.a96 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.4b1]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %empty_struct_type = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %empty_struct_type = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.decl.5f94cf.1: %Destroy.WithSelf.Op.type.ef016f.1 = fn_decl @Destroy.WithSelf.Op.loc12_3.1 [concrete = constants.%Destroy.WithSelf.Op.403171.1] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.a96 = ref_param_pattern [concrete = constants.%self.param_patt.52f]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.a96 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.4b1]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %empty_struct_type = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %empty_struct_type = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.decl.763c71.2: %Destroy.WithSelf.SubobjectDestroy.type.dfcbdb.2 = fn_decl @Destroy.WithSelf.SubobjectDestroy.loc12_3.2 [concrete = constants.%Destroy.WithSelf.SubobjectDestroy.d01daf.2] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.6cb = ref_param_pattern [concrete = constants.%self.param_patt.925]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.6cb = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.617]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %X = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %X = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.decl.5f94cf.2: %Destroy.WithSelf.Op.type.ef016f.2 = fn_decl @Destroy.WithSelf.Op.loc12_3.2 [concrete = constants.%Destroy.WithSelf.Op.403171.2] {
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.6cb = ref_param_pattern [concrete = constants.%self.param_patt.925]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.6cb = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.617]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: ref %X = ref_param call_param0
|
|
// CHECK:STDOUT: %self: ref %X = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Use() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %i.var: ref %X = var_storage %i.var_patt
|
|
// CHECK:STDOUT: %Init.ref: %Init.type = name_ref Init, file.%Init.decl [concrete = constants.%Init]
|
|
// CHECK:STDOUT: %.loc12_3: ref %X = splice_block %i.var {}
|
|
// CHECK:STDOUT: %Init.call: init %const to %.loc12_3 = call %Init.ref()
|
|
// CHECK:STDOUT: %X.ref.loc12_31: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %.loc12_28.1: init %X = as_compatible %Init.call
|
|
// CHECK:STDOUT: %.loc12_28.2: init %X = converted %Init.call, %.loc12_28.1
|
|
// CHECK:STDOUT: assign %i.var, %.loc12_28.2
|
|
// CHECK:STDOUT: %X.ref.loc12_17: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %i: ref %X = wrapper_binding i, %i.var
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %i.patt: %pattern_type.6cb = ref_binding_pattern i [concrete = constants.%i.patt]
|
|
// CHECK:STDOUT: %i.var_patt: %pattern_type.6cb = var_pattern %i.patt [concrete = constants.%i.var_patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %value.ref: %const = name_ref value, file.%value
|
|
// CHECK:STDOUT: %X.ref.loc13_30: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %.loc13_27.1: %X = as_compatible %value.ref
|
|
// CHECK:STDOUT: %.loc13_27.2: %X = converted %value.ref, %.loc13_27.1
|
|
// CHECK:STDOUT: %X.ref.loc13_17: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %v: %X = wrapper_binding v, %.loc13_27.2
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %v.patt: %pattern_type.6cb = value_binding_pattern v [concrete = constants.%v.patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.bound: <bound method> = bound_method %i.var, constants.%Destroy.WithSelf.SelfDestruct.db3fdb.2
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SelfDestruct.call: init %empty_tuple.type = call %Destroy.WithSelf.SelfDestruct.bound(%i.var)
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SubobjectDestroy.loc12_3.1(%self.param: ref %empty_struct_type) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.Op.loc12_3.1(%self.param: ref %empty_struct_type) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SelfDestruct.loc12_3.1(%self.param: ref %empty_struct_type) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.Op.decl.5f94cf.1(%self.param)
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.SubobjectDestroy.decl.763c71.1(%self.param)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SubobjectDestroy.loc12_3.2(%self.param: ref %X) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.Op.loc12_3.2(%self.param: ref %X) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Destroy.WithSelf.SelfDestruct.loc12_3.2(%self.param: ref %X) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.Op.decl.5f94cf.2(%self.param)
|
|
// CHECK:STDOUT: %Destroy.WithSelf.SubobjectDestroy.call: init %empty_tuple.type = call generated.%Destroy.WithSelf.SubobjectDestroy.decl.763c71.2(%self.param)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @__global_init() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- unsafe_remove_const.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %X: type = class_type @X [concrete]
|
|
// CHECK:STDOUT: %const: type = const_type %X [concrete]
|
|
// CHECK:STDOUT: %ptr.faf: type = ptr_type %const [concrete]
|
|
// CHECK:STDOUT: %ptr.db8: type = ptr_type %X [concrete]
|
|
// CHECK:STDOUT: %pattern_type.990: type = pattern_type %ptr.db8 [concrete]
|
|
// CHECK:STDOUT: %a.patt: %pattern_type.990 = value_binding_pattern a [concrete]
|
|
// CHECK:STDOUT: %reference.var: ref %X = var_storage file.%reference.var_patt [concrete]
|
|
// CHECK:STDOUT: %addr.0f1: %ptr.db8 = addr_of %reference.var [concrete]
|
|
// CHECK:STDOUT: %b.patt: %pattern_type.990 = value_binding_pattern b [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Use() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %reference.ref: ref %const = name_ref reference, file.%reference [concrete = file.%reference.var]
|
|
// CHECK:STDOUT: %X.ref.loc11_44: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %.loc11_41.1: ref %X = as_compatible %reference.ref [concrete = constants.%reference.var]
|
|
// CHECK:STDOUT: %.loc11_41.2: ref %X = converted %reference.ref, %.loc11_41.1 [concrete = constants.%reference.var]
|
|
// CHECK:STDOUT: %addr: %ptr.db8 = addr_of %.loc11_41.2 [concrete = constants.%addr.0f1]
|
|
// CHECK:STDOUT: %.loc11_18: type = splice_block %ptr.loc11 [concrete = constants.%ptr.db8] {
|
|
// CHECK:STDOUT: %X.ref.loc11_17: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %ptr.loc11: type = ptr_type %X.ref.loc11_17 [concrete = constants.%ptr.db8]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %a: %ptr.db8 = wrapper_binding a, %addr
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %a.patt: %pattern_type.990 = value_binding_pattern a [concrete = constants.%a.patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %ptr.ref: %ptr.faf = name_ref ptr, file.%ptr.loc7_8
|
|
// CHECK:STDOUT: %X.ref.loc12_36: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %ptr.loc12_37: type = ptr_type %X.ref.loc12_36 [concrete = constants.%ptr.db8]
|
|
// CHECK:STDOUT: %.loc12_33.1: %ptr.db8 = as_compatible %ptr.ref
|
|
// CHECK:STDOUT: %.loc12_33.2: %ptr.db8 = converted %ptr.ref, %.loc12_33.1
|
|
// CHECK:STDOUT: %.loc12_18: type = splice_block %ptr.loc12_18 [concrete = constants.%ptr.db8] {
|
|
// CHECK:STDOUT: %X.ref.loc12_17: type = name_ref X, file.%X.decl [concrete = constants.%X]
|
|
// CHECK:STDOUT: %ptr.loc12_18: type = ptr_type %X.ref.loc12_17 [concrete = constants.%ptr.db8]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %b: %ptr.db8 = wrapper_binding b, %.loc12_33.2
|
|
// CHECK:STDOUT: name_binding_decl {
|
|
// CHECK:STDOUT: %b.patt: %pattern_type.990 = value_binding_pattern b [concrete = constants.%b.patt]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @__global_init() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: <elided>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|