mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 11:55:52 +01:00
This resolves a TODO in `expr_info.cpp` by using the inst kind rather than the bound value to track the binding's category. Since we're churning all the `bind_name` insts in testdata anyway, I'm also taking this opportunity to align the inst naming with the design's terminology, by calling these insts "bindings" (this aspect of the PR is dependent on #6231 resolving an ambiguity in that terminology). For consistency we'll need to rename several other insts as well (see the TODO on `RefBinding`); I'm deferring that to a separate PR to minimize the review load, but I think those name changes are in-scope for this review.
91 lines
5.7 KiB
Plaintext
91 lines
5.7 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
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/forward_declared.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/forward_declared.carbon
|
|
|
|
class Class;
|
|
|
|
fn F(p: Class*) -> Class* { return p; }
|
|
|
|
// CHECK:STDOUT: --- forward_declared.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Class: type = class_type @Class [concrete]
|
|
// CHECK:STDOUT: %ptr.e71: type = ptr_type %Class [concrete]
|
|
// CHECK:STDOUT: %pattern_type.796: type = pattern_type %ptr.e71 [concrete]
|
|
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
|
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
|
// CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
|
|
// CHECK:STDOUT: %T.8b3: type = bind_symbolic_name T, 0 [symbolic]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.31f: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%T.8b3) [symbolic]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.8a8: %ptr.as.Copy.impl.Op.type.31f = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Copy.impl_witness.929: <witness> = impl_witness imports.%Copy.impl_witness_table.53c, @ptr.as.Copy.impl(%Class) [concrete]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.039: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%Class) [concrete]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.275: %ptr.as.Copy.impl.Op.type.039 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %ptr.e71, (%Copy.impl_witness.929) [concrete]
|
|
// CHECK:STDOUT: %.93e: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet [concrete]
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %ptr.as.Copy.impl.Op.275, @ptr.as.Copy.impl.Op(%Class) [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
|
// CHECK:STDOUT: .Copy = %Core.Copy
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
|
|
// CHECK:STDOUT: %Core.import_ref.0e4: @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op.type (%ptr.as.Copy.impl.Op.type.31f) = import_ref Core//prelude/parts/copy, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op (constants.%ptr.as.Copy.impl.Op.8a8)]
|
|
// CHECK:STDOUT: %Copy.impl_witness_table.53c = impl_witness_table (%Core.import_ref.0e4), @ptr.as.Copy.impl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Class = %Class.decl
|
|
// CHECK:STDOUT: .F = %F.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %Class.decl: type = class_decl @Class [concrete = constants.%Class] {} {}
|
|
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
|
// CHECK:STDOUT: %p.patt: %pattern_type.796 = value_binding_pattern p [concrete]
|
|
// CHECK:STDOUT: %p.param_patt: %pattern_type.796 = value_param_pattern %p.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.796 = return_slot_pattern [concrete]
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.796 = out_param_pattern %return.patt, call_param1 [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %Class.ref.loc17_20: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
|
|
// CHECK:STDOUT: %ptr.loc17_25: type = ptr_type %Class.ref.loc17_20 [concrete = constants.%ptr.e71]
|
|
// CHECK:STDOUT: %p.param: %ptr.e71 = value_param call_param0
|
|
// CHECK:STDOUT: %.loc17: type = splice_block %ptr.loc17_14 [concrete = constants.%ptr.e71] {
|
|
// CHECK:STDOUT: %Class.ref.loc17_9: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
|
|
// CHECK:STDOUT: %ptr.loc17_14: type = ptr_type %Class.ref.loc17_9 [concrete = constants.%ptr.e71]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %p: %ptr.e71 = value_binding p, %p.param
|
|
// CHECK:STDOUT: %return.param: ref %ptr.e71 = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref %ptr.e71 = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Class;
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F(%p.param: %ptr.e71) -> %ptr.e71 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %p.ref: %ptr.e71 = name_ref p, %p
|
|
// CHECK:STDOUT: %impl.elem0: %.93e = impl_witness_access constants.%Copy.impl_witness.929, element0 [concrete = constants.%ptr.as.Copy.impl.Op.275]
|
|
// CHECK:STDOUT: %bound_method.loc17_36.1: <bound method> = bound_method %p.ref, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @ptr.as.Copy.impl.Op(constants.%Class) [concrete = constants.%ptr.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc17_36.2: <bound method> = bound_method %p.ref, %specific_fn
|
|
// CHECK:STDOUT: %ptr.as.Copy.impl.Op.call: init %ptr.e71 = call %bound_method.loc17_36.2(%p.ref)
|
|
// CHECK:STDOUT: return %ptr.as.Copy.impl.Op.call to %return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|