mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 17:28:10 +00:00
Diagnostic rendering was part of the data model: `Loc::FormatLocation` and `Loc::FormatSnippet` wrote plain text to a stream, so no capability, color, or terminal width could reach them. A diagnostic is now one message with labels, contexts, and location information attached, and `Diagnostics::Renderer` draws it into a `Terminal::Buffer`. The design is in `toolchain/docs/diagnostics_rendering.md` (#7668), authoring in `toolchain/docs/diagnostics.md`. Before: ``` example.carbon:6:3: error: 1 argument passed to function expecting 0 arguments Run0(1); ^~~~~~~ example.carbon:3:1: note: calling function declared here fn Run0() {} ^~~~~~~~~~~ ``` After: ``` error: 1 argument passed to function expecting 0 arguments ╭─┤ example.carbon:6:3 ┆ 3 │ fn Run0() {} · ─────┬───── · ╰──┤ calling function declared here ┆ -> 6 │ Run0(1); · ─────── ╰──────────── ``` `--no-diagnostic-snippets` gives a compact form, `example.carbon:6:3-9`. File tests use it; the rendering tests under `toolchain/diagnostics/testdata` ask for snippets. C++ interop diagnostics are data now rather than text Clang drew: `SemIR::ClangSourceLocId` names a `clang::SourceRange`, and a Clang location is marked as the point it names. `StreamConsumer` moves to a `:renderer` target that `:emitter` does not depend on, keeping `common/terminal` out of `consumer.h`. Capabilities come from the file behind the error stream, so tests get plain ASCII. `renderer_fuzzer` draws diagnostics built from fuzzer bytes with every capability combination, since a shape the renderer doesn't expect must never be why the compiler dies while reporting a problem. TODOs mark the follow-ups: line weights and crossing lines, wrapping that keeps a quoted type whole, and ordering diagnostics that share a byte offset. Also: `IncorrectExtension`'s hint moves into its message, since its note had no location of its own, and `strip_noise` in `check_diagnostics.py` blanks multi-line `#define`s instead of deleting them. Assisted-by: Claude Code
475 lines
29 KiB
Plaintext
475 lines
29 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/full.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/class/import/field.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/class/import/field.carbon
|
|
|
|
// --- struct.h
|
|
|
|
struct Struct {
|
|
int a;
|
|
int b;
|
|
int* _Nonnull p;
|
|
int* _Nullable q;
|
|
int& r;
|
|
};
|
|
|
|
// --- use_struct_fields.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "struct.h";
|
|
|
|
fn F(s: Cpp.Struct) -> (i32, i32, i32, i32, i32) {
|
|
//@dump-sem-ir-begin
|
|
return (s.a, s.b, *s.p, *s.q.Get(), *s.r);
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- union.h
|
|
|
|
union Union {
|
|
int a;
|
|
int b;
|
|
int* _Nonnull p;
|
|
};
|
|
|
|
// --- use_union_fields.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "union.h";
|
|
|
|
fn F(u: Cpp.Union) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
return u.a;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn G(u: Cpp.Union) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
return u.b;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn H(u: Cpp.Union) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
return *u.p;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- anon_struct_union.h
|
|
|
|
struct A {
|
|
union {
|
|
struct {
|
|
short a_0;
|
|
short b_2;
|
|
int c_4;
|
|
};
|
|
struct {
|
|
char d_0;
|
|
char e_1;
|
|
int f_4;
|
|
short g_8;
|
|
};
|
|
};
|
|
int h_12;
|
|
};
|
|
|
|
// --- use_anon_struct_union.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "anon_struct_union.h";
|
|
|
|
fn GetF(a: Cpp.A) -> i32 { return a.f_4; }
|
|
|
|
// --- with_bitfields.h
|
|
|
|
struct BitfieldStruct {
|
|
int a;
|
|
int b : 2;
|
|
};
|
|
|
|
union BitfieldUnion {
|
|
int c;
|
|
int d : 3;
|
|
};
|
|
|
|
// --- use_non_bitfields_in_type_with_bitfields.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "with_bitfields.h";
|
|
|
|
fn F(s: Cpp.BitfieldStruct) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
return s.a;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn G(s: Cpp.BitfieldUnion) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
return s.c;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- fail_todo_use_bitfields.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: included from: fail_todo_use_bitfields.carbon:[[@LINE+2]]:10 [InCppInclude]
|
|
// CHECK:STDERR: ./with_bitfields.h:4:7: error: semantics TODO: `Unsupported: field declaration has unhandled type or kind` [SemanticsTodo]
|
|
import Cpp library "with_bitfields.h";
|
|
|
|
fn F(s: Cpp.BitfieldStruct) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+4]]:10-12: note: in `Cpp` name lookup for `b` [InCppNameLookup]
|
|
// CHECK:STDERR:
|
|
// CHECK:STDERR: included from: fail_todo_use_bitfields.carbon:[[@LINE-6]]:10 [InCppInclude]
|
|
// CHECK:STDERR: ./with_bitfields.h:9:7: error: semantics TODO: `Unsupported: field declaration has unhandled type or kind` [SemanticsTodo]
|
|
return s.b;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
fn G(s: Cpp.BitfieldUnion) -> i32 {
|
|
//@dump-sem-ir-begin
|
|
// CHECK:STDERR: fail_todo_use_bitfields.carbon:[[@LINE+2]]:10-12: note: in `Cpp` name lookup for `d` [InCppNameLookup]
|
|
// CHECK:STDERR:
|
|
return s.d;
|
|
//@dump-sem-ir-end
|
|
}
|
|
|
|
// --- unsupported_members.h
|
|
|
|
struct UnsupportedMembers {
|
|
// Volatile is not supported.
|
|
volatile int is_volatile;
|
|
// But this should be fine.
|
|
int integer;
|
|
};
|
|
|
|
void Consume(UnsupportedMembers);
|
|
|
|
// --- supported_members_in_type_with_unsupported_members.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
import Cpp library "unsupported_members.h";
|
|
|
|
fn Test(m: Cpp.UnsupportedMembers*) {
|
|
// OK: Can still access supported members.
|
|
m->integer = 42;
|
|
// OK: Can still pass the class to a C++ function.
|
|
Cpp.Consume(*m);
|
|
}
|
|
|
|
// --- fail_use_unsupported_members.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
// CHECK:STDERR: included from: fail_use_unsupported_members.carbon:[[@LINE+2]]:10 [InCppInclude]
|
|
// CHECK:STDERR: ./unsupported_members.h:4:16: error: semantics TODO: `Unsupported: field declaration has unhandled type or kind` [SemanticsTodo]
|
|
import Cpp library "unsupported_members.h";
|
|
|
|
fn Test(m: Cpp.UnsupportedMembers*) {
|
|
// CHECK:STDERR: fail_use_unsupported_members.carbon:[[@LINE+2]]:23-36: note: in `Cpp` name lookup for `is_volatile` [InCppNameLookup]
|
|
// CHECK:STDERR:
|
|
let unused a: i32 = m->is_volatile;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- use_struct_fields.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %Struct: type = class_type @Struct [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %tuple.type.77f: type = tuple_type (%i32, %i32, %i32, %i32, %i32) [concrete]
|
|
// CHECK:STDOUT: %Struct.elem.c8b: type = unbound_element_type %Struct, %i32 [concrete]
|
|
// CHECK:STDOUT: %ptr.a17: type = ptr_type %i32 [concrete]
|
|
// CHECK:STDOUT: %Struct.elem.2d6: type = unbound_element_type %Struct, %ptr.a17 [concrete]
|
|
// CHECK:STDOUT: %OptionalStorage.type: type = facet_type <@OptionalStorage> [concrete]
|
|
// CHECK:STDOUT: %T.220: %OptionalStorage.type = symbolic_binding T, 0 [symbolic]
|
|
// CHECK:STDOUT: %Optional.Get.type.786: type = fn_type @Optional.Get, @Optional(%T.220) [symbolic]
|
|
// CHECK:STDOUT: %Optional.Get.2d0: %Optional.Get.type.786 = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
|
|
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
|
// CHECK:STDOUT: %T.67d: type = symbolic_binding T, 0 [symbolic]
|
|
// CHECK:STDOUT: %ptr.e8f: type = ptr_type %T.67d [symbolic]
|
|
// CHECK:STDOUT: %Destroy.lookup_impl_witness.781: <witness> = lookup_impl_witness %ptr.e8f, @Destroy [symbolic]
|
|
// CHECK:STDOUT: %Destroy.facet.e46: %Destroy.type = facet_value %ptr.e8f, (%Destroy.lookup_impl_witness.781) [symbolic]
|
|
// CHECK:STDOUT: %MaybeUnformed.238: type = class_type @MaybeUnformed, @MaybeUnformed(%Destroy.facet.e46) [symbolic]
|
|
// CHECK:STDOUT: %ptr.as.OptionalStorage.impl.Get.type.790: type = fn_type @ptr.as.OptionalStorage.impl.Get, @ptr.as.OptionalStorage.impl(%T.67d) [symbolic]
|
|
// CHECK:STDOUT: %ptr.as.OptionalStorage.impl.Get.50b: %ptr.as.OptionalStorage.impl.Get.type.790 = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %OptionalStorage.impl_witness.d72: <witness> = impl_witness imports.%OptionalStorage.impl_witness_table.110, @ptr.as.OptionalStorage.impl(%i32) [concrete]
|
|
// CHECK:STDOUT: %OptionalStorage.facet: %OptionalStorage.type = facet_value %ptr.a17, (%OptionalStorage.impl_witness.d72) [concrete]
|
|
// CHECK:STDOUT: %Optional.785: type = class_type @Optional, @Optional(%OptionalStorage.facet) [concrete]
|
|
// CHECK:STDOUT: %Struct.elem.d77: type = unbound_element_type %Struct, %Optional.785 [concrete]
|
|
// CHECK:STDOUT: %const.f38: type = const_type %ptr.a17 [concrete]
|
|
// CHECK:STDOUT: %Struct.elem.4ea: type = unbound_element_type %Struct, %const.f38 [concrete]
|
|
// CHECK:STDOUT: %Optional.Get.type.696: type = fn_type @Optional.Get, @Optional(%OptionalStorage.facet) [concrete]
|
|
// CHECK:STDOUT: %Optional.Get.084: %Optional.Get.type.696 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Optional.Get.specific_fn: <specific function> = specific_function %Optional.Get.084, @Optional.Get(%OptionalStorage.facet) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.a1d: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.3c1: %Int.as.Copy.impl.Op.type.a1d = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Copy.impl_witness.8af: <witness> = impl_witness imports.%Copy.impl_witness_table.f44, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.648: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.cae: %Int.as.Copy.impl.Op.type.648 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.facet.95d: %Copy.type = facet_value %i32, (%Copy.impl_witness.8af) [concrete]
|
|
// CHECK:STDOUT: %Copy.WithSelf.Op.type.f76: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.95d) [concrete]
|
|
// CHECK:STDOUT: %.2b93: type = fn_type_with_self_type %Copy.WithSelf.Op.type.f76, %Copy.facet.95d [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.cae, @Int.as.Copy.impl.Op(%int_32) [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core.import_ref.e50: @Optional.%Optional.Get.type (%Optional.Get.type.786) = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, loaded [symbolic = @Optional.%Optional.Get (constants.%Optional.Get.2d0)]
|
|
// CHECK:STDOUT: %Core.import_ref.0db: type = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.OptionalStorage.impl.%MaybeUnformed (constants.%MaybeUnformed.238)]
|
|
// CHECK:STDOUT: %Core.import_ref.814 = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, unloaded
|
|
// CHECK:STDOUT: %Core.import_ref.a1a = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, unloaded
|
|
// CHECK:STDOUT: %Core.import_ref.322 = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, unloaded
|
|
// CHECK:STDOUT: %Core.import_ref.5c0: @ptr.as.OptionalStorage.impl.%ptr.as.OptionalStorage.impl.Get.type (%ptr.as.OptionalStorage.impl.Get.type.790) = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.OptionalStorage.impl.%ptr.as.OptionalStorage.impl.Get (constants.%ptr.as.OptionalStorage.impl.Get.50b)]
|
|
// CHECK:STDOUT: %Core.import_ref.713 = import_ref Core//prelude/types/optional, loc{{\d+_\d+}}, unloaded
|
|
// CHECK:STDOUT: %OptionalStorage.impl_witness_table.110 = impl_witness_table (%Core.import_ref.0db, %Core.import_ref.814, %Core.import_ref.a1a, %Core.import_ref.322, %Core.import_ref.5c0, %Core.import_ref.713), @ptr.as.OptionalStorage.impl [concrete]
|
|
// CHECK:STDOUT: %Core.import_ref.72f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.a1d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.3c1)]
|
|
// CHECK:STDOUT: %Copy.impl_witness_table.f44 = impl_witness_table (%Core.import_ref.72f), @Int.as.Copy.impl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F(%s.param: %Struct) -> out %return.param: %tuple.type.77f {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %s.ref.loc8_11: %Struct = name_ref s, %s
|
|
// CHECK:STDOUT: %a.ref: %Struct.elem.c8b = name_ref a, @Struct.%field_decl.1 [concrete = @Struct.%field_decl.1]
|
|
// CHECK:STDOUT: %.loc8_12.1: ref %i32 = class_element_access %s.ref.loc8_11, element0
|
|
// CHECK:STDOUT: %.loc8_12.2: %i32 = acquire_value %.loc8_12.1
|
|
// CHECK:STDOUT: %s.ref.loc8_16: %Struct = name_ref s, %s
|
|
// CHECK:STDOUT: %b.ref: %Struct.elem.c8b = name_ref b, @Struct.%field_decl.2 [concrete = @Struct.%field_decl.2]
|
|
// CHECK:STDOUT: %.loc8_17.1: ref %i32 = class_element_access %s.ref.loc8_16, element1
|
|
// CHECK:STDOUT: %.loc8_17.2: %i32 = acquire_value %.loc8_17.1
|
|
// CHECK:STDOUT: %s.ref.loc8_22: %Struct = name_ref s, %s
|
|
// CHECK:STDOUT: %p.ref: %Struct.elem.2d6 = name_ref p, @Struct.%field_decl.3 [concrete = @Struct.%field_decl.3]
|
|
// CHECK:STDOUT: %.loc8_23.1: ref %ptr.a17 = class_element_access %s.ref.loc8_22, element2
|
|
// CHECK:STDOUT: %.loc8_23.2: %ptr.a17 = acquire_value %.loc8_23.1
|
|
// CHECK:STDOUT: %.loc8_21.1: ref %i32 = deref %.loc8_23.2
|
|
// CHECK:STDOUT: %s.ref.loc8_28: %Struct = name_ref s, %s
|
|
// CHECK:STDOUT: %q.ref: %Struct.elem.d77 = name_ref q, @Struct.%field_decl.4 [concrete = @Struct.%field_decl.4]
|
|
// CHECK:STDOUT: %.loc8_29.1: ref %Optional.785 = class_element_access %s.ref.loc8_28, element3
|
|
// CHECK:STDOUT: %.loc8_29.2: %Optional.785 = acquire_value %.loc8_29.1
|
|
// CHECK:STDOUT: %.loc8_31: %Optional.Get.type.696 = specific_constant imports.%Core.import_ref.e50, @Optional(constants.%OptionalStorage.facet) [concrete = constants.%Optional.Get.084]
|
|
// CHECK:STDOUT: %Get.ref: %Optional.Get.type.696 = name_ref Get, %.loc8_31 [concrete = constants.%Optional.Get.084]
|
|
// CHECK:STDOUT: %Optional.Get.bound: <bound method> = bound_method %.loc8_29.2, %Get.ref
|
|
// CHECK:STDOUT: %Optional.Get.specific_fn: <specific function> = specific_function %Get.ref, @Optional.Get(constants.%OptionalStorage.facet) [concrete = constants.%Optional.Get.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_36: <bound method> = bound_method %.loc8_29.2, %Optional.Get.specific_fn
|
|
// CHECK:STDOUT: %Optional.Get.call: init %ptr.a17 = call %bound_method.loc8_36(%.loc8_29.2)
|
|
// CHECK:STDOUT: %.loc8_36.1: %ptr.a17 = value_of_initializer %Optional.Get.call
|
|
// CHECK:STDOUT: %.loc8_36.2: %ptr.a17 = converted %Optional.Get.call, %.loc8_36.1
|
|
// CHECK:STDOUT: %.loc8_27.1: ref %i32 = deref %.loc8_36.2
|
|
// CHECK:STDOUT: %s.ref.loc8_40: %Struct = name_ref s, %s
|
|
// CHECK:STDOUT: %r.ref: %Struct.elem.4ea = name_ref r, @Struct.%field_decl.5 [concrete = @Struct.%field_decl.5]
|
|
// CHECK:STDOUT: %.loc8_41.1: ref %const.f38 = class_element_access %s.ref.loc8_40, element4
|
|
// CHECK:STDOUT: %.loc8_41.2: %const.f38 = acquire_value %.loc8_41.1
|
|
// CHECK:STDOUT: %.loc8_39.1: ref %i32 = deref %.loc8_41.2
|
|
// CHECK:STDOUT: %.loc8_43.1: %tuple.type.77f = tuple_literal (%.loc8_12.2, %.loc8_17.2, %.loc8_21.1, %.loc8_27.1, %.loc8_39.1)
|
|
// CHECK:STDOUT: %impl.elem0.loc8_12: %.2b93 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_12.1: <bound method> = bound_method %.loc8_12.2, %impl.elem0.loc8_12
|
|
// CHECK:STDOUT: %specific_fn.loc8_12: <specific function> = specific_function %impl.elem0.loc8_12, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_12.2: <bound method> = bound_method %.loc8_12.2, %specific_fn.loc8_12
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc8_12: init %i32 = call %bound_method.loc8_12.2(%.loc8_12.2)
|
|
// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %return.param, element0
|
|
// CHECK:STDOUT: %.loc8_43.2: init %i32 to %tuple.elem0 = in_place_init %Int.as.Copy.impl.Op.call.loc8_12
|
|
// CHECK:STDOUT: %impl.elem0.loc8_17: %.2b93 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_17.1: <bound method> = bound_method %.loc8_17.2, %impl.elem0.loc8_17
|
|
// CHECK:STDOUT: %specific_fn.loc8_17: <specific function> = specific_function %impl.elem0.loc8_17, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_17.2: <bound method> = bound_method %.loc8_17.2, %specific_fn.loc8_17
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc8_17: init %i32 = call %bound_method.loc8_17.2(%.loc8_17.2)
|
|
// CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access %return.param, element1
|
|
// CHECK:STDOUT: %.loc8_43.3: init %i32 to %tuple.elem1 = in_place_init %Int.as.Copy.impl.Op.call.loc8_17
|
|
// CHECK:STDOUT: %.loc8_21.2: %i32 = acquire_value %.loc8_21.1
|
|
// CHECK:STDOUT: %impl.elem0.loc8_21: %.2b93 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_21.1: <bound method> = bound_method %.loc8_21.2, %impl.elem0.loc8_21
|
|
// CHECK:STDOUT: %specific_fn.loc8_21: <specific function> = specific_function %impl.elem0.loc8_21, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_21.2: <bound method> = bound_method %.loc8_21.2, %specific_fn.loc8_21
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc8_21: init %i32 = call %bound_method.loc8_21.2(%.loc8_21.2)
|
|
// CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access %return.param, element2
|
|
// CHECK:STDOUT: %.loc8_43.4: init %i32 to %tuple.elem2 = in_place_init %Int.as.Copy.impl.Op.call.loc8_21
|
|
// CHECK:STDOUT: %.loc8_27.2: %i32 = acquire_value %.loc8_27.1
|
|
// CHECK:STDOUT: %impl.elem0.loc8_27: %.2b93 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_27.1: <bound method> = bound_method %.loc8_27.2, %impl.elem0.loc8_27
|
|
// CHECK:STDOUT: %specific_fn.loc8_27: <specific function> = specific_function %impl.elem0.loc8_27, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_27.2: <bound method> = bound_method %.loc8_27.2, %specific_fn.loc8_27
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc8_27: init %i32 = call %bound_method.loc8_27.2(%.loc8_27.2)
|
|
// CHECK:STDOUT: %tuple.elem3: ref %i32 = tuple_access %return.param, element3
|
|
// CHECK:STDOUT: %.loc8_43.5: init %i32 to %tuple.elem3 = in_place_init %Int.as.Copy.impl.Op.call.loc8_27
|
|
// CHECK:STDOUT: %.loc8_39.2: %i32 = acquire_value %.loc8_39.1
|
|
// CHECK:STDOUT: %impl.elem0.loc8_39: %.2b93 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_39.1: <bound method> = bound_method %.loc8_39.2, %impl.elem0.loc8_39
|
|
// CHECK:STDOUT: %specific_fn.loc8_39: <specific function> = specific_function %impl.elem0.loc8_39, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_39.2: <bound method> = bound_method %.loc8_39.2, %specific_fn.loc8_39
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc8_39: init %i32 = call %bound_method.loc8_39.2(%.loc8_39.2)
|
|
// CHECK:STDOUT: %tuple.elem4: ref %i32 = tuple_access %return.param, element4
|
|
// CHECK:STDOUT: %.loc8_43.6: init %i32 to %tuple.elem4 = in_place_init %Int.as.Copy.impl.Op.call.loc8_39
|
|
// CHECK:STDOUT: %.loc8_43.7: init %tuple.type.77f to %return.param = tuple_init (%.loc8_43.2, %.loc8_43.3, %.loc8_43.4, %.loc8_43.5, %.loc8_43.6)
|
|
// CHECK:STDOUT: %.loc8_44: init %tuple.type.77f = converted %.loc8_43.1, %.loc8_43.7
|
|
// CHECK:STDOUT: return %.loc8_44 to %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- use_union_fields.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %Union: type = class_type @Union [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Union.elem.b1b: type = unbound_element_type %Union, %i32 [concrete]
|
|
// CHECK:STDOUT: %ptr.a17: type = ptr_type %i32 [concrete]
|
|
// CHECK:STDOUT: %Union.elem.f97: type = unbound_element_type %Union, %ptr.a17 [concrete]
|
|
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.a1d: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.3c1: %Int.as.Copy.impl.Op.type.a1d = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Copy.impl_witness.8af: <witness> = impl_witness imports.%Copy.impl_witness_table.f44, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.648: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.cae: %Int.as.Copy.impl.Op.type.648 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.8af) [concrete]
|
|
// CHECK:STDOUT: %Copy.WithSelf.Op.type.f76: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
|
|
// CHECK:STDOUT: %.2b9: type = fn_type_with_self_type %Copy.WithSelf.Op.type.f76, %Copy.facet [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.cae, @Int.as.Copy.impl.Op(%int_32) [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core.import_ref.72f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.a1d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.3c1)]
|
|
// CHECK:STDOUT: %Copy.impl_witness_table.f44 = impl_witness_table (%Core.import_ref.72f), @Int.as.Copy.impl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F(%u.param: %Union) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %u.ref: %Union = name_ref u, %u
|
|
// CHECK:STDOUT: %a.ref: %Union.elem.b1b = name_ref a, @Union.%field_decl.1 [concrete = @Union.%field_decl.1]
|
|
// CHECK:STDOUT: %.loc8_11.1: ref %i32 = class_element_access %u.ref, element0
|
|
// CHECK:STDOUT: %.loc8_11.2: %i32 = acquire_value %.loc8_11.1
|
|
// CHECK:STDOUT: %impl.elem0: %.2b9 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %.loc8_11.2, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %.loc8_11.2, %specific_fn
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc8_11.2(%.loc8_11.2)
|
|
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G(%u.param: %Union) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %u.ref: %Union = name_ref u, %u
|
|
// CHECK:STDOUT: %b.ref: %Union.elem.b1b = name_ref b, @Union.%field_decl.2 [concrete = @Union.%field_decl.2]
|
|
// CHECK:STDOUT: %.loc14_11.1: ref %i32 = class_element_access %u.ref, element1
|
|
// CHECK:STDOUT: %.loc14_11.2: %i32 = acquire_value %.loc14_11.1
|
|
// CHECK:STDOUT: %impl.elem0: %.2b9 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc14_11.1: <bound method> = bound_method %.loc14_11.2, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc14_11.2: <bound method> = bound_method %.loc14_11.2, %specific_fn
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc14_11.2(%.loc14_11.2)
|
|
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @H(%u.param: %Union) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %u.ref: %Union = name_ref u, %u
|
|
// CHECK:STDOUT: %p.ref: %Union.elem.f97 = name_ref p, @Union.%field_decl.3 [concrete = @Union.%field_decl.3]
|
|
// CHECK:STDOUT: %.loc20_12.1: ref %ptr.a17 = class_element_access %u.ref, element2
|
|
// CHECK:STDOUT: %.loc20_12.2: %ptr.a17 = acquire_value %.loc20_12.1
|
|
// CHECK:STDOUT: %.loc20_10.1: ref %i32 = deref %.loc20_12.2
|
|
// CHECK:STDOUT: %.loc20_10.2: %i32 = acquire_value %.loc20_10.1
|
|
// CHECK:STDOUT: %impl.elem0: %.2b9 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc20_10.1: <bound method> = bound_method %.loc20_10.2, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc20_10.2: <bound method> = bound_method %.loc20_10.2, %specific_fn
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc20_10.2(%.loc20_10.2)
|
|
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- use_non_bitfields_in_type_with_bitfields.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %BitfieldStruct: type = class_type @BitfieldStruct [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %BitfieldStruct.elem: type = unbound_element_type %BitfieldStruct, %i32 [concrete]
|
|
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.a1d: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.3c1: %Int.as.Copy.impl.Op.type.a1d = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Copy.impl_witness.8af: <witness> = impl_witness imports.%Copy.impl_witness_table.f44, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.648: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.cae: %Int.as.Copy.impl.Op.type.648 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.8af) [concrete]
|
|
// CHECK:STDOUT: %Copy.WithSelf.Op.type.f76: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
|
|
// CHECK:STDOUT: %.2b9: type = fn_type_with_self_type %Copy.WithSelf.Op.type.f76, %Copy.facet [concrete]
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.cae, @Int.as.Copy.impl.Op(%int_32) [concrete]
|
|
// CHECK:STDOUT: %BitfieldUnion: type = class_type @BitfieldUnion [concrete]
|
|
// CHECK:STDOUT: %BitfieldUnion.elem: type = unbound_element_type %BitfieldUnion, %i32 [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core.import_ref.72f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.a1d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.3c1)]
|
|
// CHECK:STDOUT: %Copy.impl_witness_table.f44 = impl_witness_table (%Core.import_ref.72f), @Int.as.Copy.impl [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F(%s.param: %BitfieldStruct) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %s.ref: %BitfieldStruct = name_ref s, %s
|
|
// CHECK:STDOUT: %a.ref: %BitfieldStruct.elem = name_ref a, @BitfieldStruct.%field_decl [concrete = @BitfieldStruct.%field_decl]
|
|
// CHECK:STDOUT: %.loc8_11.1: ref %i32 = class_element_access %s.ref, element0
|
|
// CHECK:STDOUT: %.loc8_11.2: %i32 = acquire_value %.loc8_11.1
|
|
// CHECK:STDOUT: %impl.elem0: %.2b9 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %.loc8_11.2, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %.loc8_11.2, %specific_fn
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc8_11.2(%.loc8_11.2)
|
|
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G(%s.param: %BitfieldUnion) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %s.ref: %BitfieldUnion = name_ref s, %s
|
|
// CHECK:STDOUT: %c.ref: %BitfieldUnion.elem = name_ref c, @BitfieldUnion.%field_decl [concrete = @BitfieldUnion.%field_decl]
|
|
// CHECK:STDOUT: %.loc14_11.1: ref %i32 = class_element_access %s.ref, element0
|
|
// CHECK:STDOUT: %.loc14_11.2: %i32 = acquire_value %.loc14_11.1
|
|
// CHECK:STDOUT: %impl.elem0: %.2b9 = impl_witness_access constants.%Copy.impl_witness.8af, element0 [concrete = constants.%Int.as.Copy.impl.Op.cae]
|
|
// CHECK:STDOUT: %bound_method.loc14_11.1: <bound method> = bound_method %.loc14_11.2, %impl.elem0
|
|
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
|
|
// CHECK:STDOUT: %bound_method.loc14_11.2: <bound method> = bound_method %.loc14_11.2, %specific_fn
|
|
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc14_11.2(%.loc14_11.2)
|
|
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- fail_todo_use_bitfields.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %BitfieldStruct: type = class_type @BitfieldStruct [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %BitfieldUnion: type = class_type @BitfieldUnion [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F(%s.param: %BitfieldStruct) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %s.ref: %BitfieldStruct = name_ref s, %s
|
|
// CHECK:STDOUT: %b.ref: <error> = name_ref b, <error> [concrete = <error>]
|
|
// CHECK:STDOUT: return <error>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G(%s.param: %BitfieldUnion) -> out %return.param: %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %s.ref: %BitfieldUnion = name_ref s, %s
|
|
// CHECK:STDOUT: %d.ref: <error> = name_ref d, <error> [concrete = <error>]
|
|
// CHECK:STDOUT: return <error>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|