From 25e72882fcb2379eeb055e3b0662eb659cf716bd Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 11 Jun 2026 09:45:39 -0700 Subject: [PATCH] Implement `Core.CharLiteral` operations from #6710 and #7314 (#7316) Adds support for arithmetic and comparison operators on `Core.CharLiteral`s, as well as conversions between `CharLiteral` and integer types. Make some minor tweaks to fix skill issues encountered while making this change. Assisted-by: Gemini via Antigravity --- .agents/skills/builtins/SKILL.md | 13 + .agents/skills/toolchain_tests/SKILL.md | 7 +- core/prelude/operators/arithmetic.carbon | 21 + core/prelude/operators/as.carbon | 7 + core/prelude/types.carbon | 1 + core/prelude/types/char.carbon | 17 +- core/prelude/types/char_literal.carbon | 8 + core/prelude/types/float.carbon | 6 +- core/prelude/types/int.carbon | 28 +- core/prelude/types/uint.carbon | 28 +- toolchain/check/eval.cpp | 202 ++++++++- toolchain/check/handle_literal.cpp | 5 +- .../check/testdata/array/bound_values.carbon | 12 +- .../testdata/builtins/char_literal/add.carbon | 130 ++++++ .../convert_char.carbon} | 27 +- .../builtins/char_literal/convert_int.carbon | 168 ++++++++ .../testdata/builtins/char_literal/eq.carbon | 66 +++ .../builtins/char_literal/greater.carbon | 66 +++ .../builtins/char_literal/greater_eq.carbon | 78 ++++ .../builtins/char_literal/less.carbon | 66 +++ .../builtins/char_literal/less_eq.carbon | 78 ++++ .../testdata/builtins/char_literal/neq.carbon | 66 +++ .../builtins/char_literal/sub_char.carbon | 128 ++++++ .../builtins/char_literal/sub_int.carbon | 123 ++++++ .../builtins/int/add_char_literal.carbon | 104 +++++ .../builtins/int/convert_char_literal.carbon | 167 ++++++++ .../import/arithmetic_types_bridged.carbon | 50 +-- .../long_and_long_long.llp64.carbon | 20 +- .../long_and_long_long.lp64.carbon | 20 +- toolchain/diagnostics/kind.def | 2 + .../compile/optimize/optimize_debug.carbon | 8 +- .../compile/optimize/optimize_default.carbon | 8 +- .../compile/optimize/optimize_none.carbon | 20 +- .../compile/optimize/optimize_size.carbon | 20 +- .../compile/optimize/optimize_speed.carbon | 8 +- toolchain/lower/handle_call.cpp | 14 +- toolchain/lower/testdata/array/iterate.carbon | 20 +- .../lower/testdata/for/break_continue.carbon | 20 +- toolchain/lower/testdata/for/for.carbon | 20 +- .../lower/testdata/operators/increment.carbon | 20 +- .../lower/testdata/primitives/char.carbon | 232 +++++----- .../testdata/primitives/char_literals.carbon | 405 ++++++++++++++++++ .../testdata/primitives/int_types.carbon | 74 ++-- .../lower/testdata/primitives/optional.carbon | 52 +-- toolchain/sem_ir/builtin_function_kind.cpp | 92 +++- toolchain/sem_ir/builtin_function_kind.def | 16 +- toolchain/sem_ir/ids.cpp | 13 + toolchain/sem_ir/ids.h | 8 + .../testdata/min_prelude/parts/char.carbon | 2 +- 49 files changed, 2411 insertions(+), 355 deletions(-) create mode 100644 core/prelude/types/char_literal.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/add.carbon rename toolchain/check/testdata/builtins/{char/convert_checked.carbon => char_literal/convert_char.carbon} (90%) create mode 100644 toolchain/check/testdata/builtins/char_literal/convert_int.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/eq.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/greater.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/greater_eq.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/less.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/less_eq.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/neq.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/sub_char.carbon create mode 100644 toolchain/check/testdata/builtins/char_literal/sub_int.carbon create mode 100644 toolchain/check/testdata/builtins/int/add_char_literal.carbon create mode 100644 toolchain/check/testdata/builtins/int/convert_char_literal.carbon create mode 100644 toolchain/lower/testdata/primitives/char_literals.carbon diff --git a/.agents/skills/builtins/SKILL.md b/.agents/skills/builtins/SKILL.md index fa201cc425b0..8db4fc05a75b 100644 --- a/.agents/skills/builtins/SKILL.md +++ b/.agents/skills/builtins/SKILL.md @@ -227,6 +227,19 @@ patterns for builtins: Create validation splits under [toolchain/check/testdata/builtins/](../../../toolchain/check/testdata/builtins/): +- **Test Naming Convention**: All tests under + [toolchain/check/testdata/builtins/](../../../toolchain/check/testdata/builtins/) + must be named after the builtin they are testing, replacing `.` characters + in the builtin name with `/` (directories). For example, a test for the + builtin `"char_literal.convert"` must be located at + `toolchain/check/testdata/builtins/char_literal/convert.carbon`. +- **Minimal Prelude & Direct Call Isolation**: Builtin tests must **not** test + the prelude library or operators. They must use the minimal primitive + prelude + (`// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon`) + or a smaller prelude, and explicitly declare and call the builtin functions + under test directly (e.g., `fn Add(a: f64, b: f64) -> f64 = "float.add";`). + This isolates the testing of compiler builtins from the library prelude. - **Min-Prelude Limitations**: Standard operators (like `+`, `-`, `/`, `<`, etc.) are **not** available in minimized preludes because the core operators library isn't imported. To write tests with a minimal footprint, call diff --git a/.agents/skills/toolchain_tests/SKILL.md b/.agents/skills/toolchain_tests/SKILL.md index b006412a2c2a..e8e66b9dff3c 100644 --- a/.agents/skills/toolchain_tests/SKILL.md +++ b/.agents/skills/toolchain_tests/SKILL.md @@ -74,9 +74,10 @@ library "[[@TEST_NAME]]"; // ... ``` -- Use `library "[[@TEST_NAME]]";` in each split when necessary to prevent name - conflicts or redefining the default library. -- Exactly `[[@TEST_NAME]]` (including the brackets) should be used. The test +- **Always** use `library "[[@TEST_NAME]]";` in each split rather than + hardcoding the library name. This prevents name conflicts, avoids redefining + the default library, and keeps the test code clean and templateable. +- Exactly `[[@TEST_NAME]]` (including the brackets) must be used. The test infrastructure automatically replaces it with the split's filename minus `todo_` and `fail_` prefixes. - **Do not put code that is expected to pass and code that is expected to fail diff --git a/core/prelude/operators/arithmetic.carbon b/core/prelude/operators/arithmetic.carbon index 46872572f153..6850ee6932fd 100644 --- a/core/prelude/operators/arithmetic.carbon +++ b/core/prelude/operators/arithmetic.carbon @@ -4,6 +4,7 @@ package Core library "prelude/operators/arithmetic"; +import library "prelude/types/char_literal"; import library "prelude/types/int_literal"; // TODO: Per the design, the associated type `Result` in each of these @@ -115,3 +116,23 @@ impl IntLiteral as Negate where .Result = Self { impl IntLiteral as SubWith(Self) where .Result = Self { fn Op(self, other: Self) -> Self = "int.ssub"; } + + +// Operations for CharLiteral. These need to be here because CharLiteral has no +// associated library of its own. + +impl CharLiteral as AddWith(IntLiteral) where .Result = CharLiteral { + fn Op(self, other: IntLiteral) -> CharLiteral = "char_literal.add"; +} + +impl IntLiteral as AddWith(CharLiteral) where .Result = CharLiteral { + fn Op(self, other: CharLiteral) -> CharLiteral = "int.add_char_literal"; +} + +impl CharLiteral as SubWith(IntLiteral) where .Result = CharLiteral { + fn Op(self, other: IntLiteral) -> CharLiteral = "char_literal.sub_int"; +} + +impl CharLiteral as SubWith(Self) where .Result = IntLiteral { + fn Op(self, other: Self) -> IntLiteral = "char_literal.sub_char"; +} diff --git a/core/prelude/operators/as.carbon b/core/prelude/operators/as.carbon index 62a2cc52d8c4..b9b46726e95e 100644 --- a/core/prelude/operators/as.carbon +++ b/core/prelude/operators/as.carbon @@ -5,6 +5,7 @@ package Core library "prelude/operators/as"; import library "prelude/copy"; +import library "prelude/types/char_literal"; import library "prelude/types/int_literal"; import library "prelude/types/float_literal"; @@ -73,5 +74,11 @@ impl FloatLiteral as UnsafeAs(IntLiteral) { fn Convert(self) -> IntLiteral = "float.convert_int"; } +// Integer literals can be explicitly cast to char literals. +impl IntLiteral as As(CharLiteral) { + fn Convert(self) -> CharLiteral = "int.convert_char_literal"; +} + + interface IntFitsIn(Dest:! type) {} interface FloatFitsIn(Src:! type) {} diff --git a/core/prelude/types.carbon b/core/prelude/types.carbon index 4059033d35dd..1198b73f543c 100644 --- a/core/prelude/types.carbon +++ b/core/prelude/types.carbon @@ -6,6 +6,7 @@ package Core library "prelude/types"; export import library "prelude/types/bool"; export import library "prelude/types/char"; +export import library "prelude/types/char_literal"; export import library "prelude/types/cpp/int"; export import library "prelude/types/cpp/nullptr"; export import library "prelude/types/cpp/void"; diff --git a/core/prelude/types/char.carbon b/core/prelude/types/char.carbon index c4552bc4461b..3f2e1164ad95 100644 --- a/core/prelude/types/char.carbon +++ b/core/prelude/types/char.carbon @@ -9,14 +9,10 @@ import library "prelude/default"; import library "prelude/destroy"; import library "prelude/operators"; import library "prelude/types/uint"; +import library "prelude/types/char_literal"; import library "prelude/types/int"; import library "prelude/types/int_literal"; -private fn MakeCharLiteral() -> type = "char_literal.make_type"; -alias CharLiteral = MakeCharLiteral(); - -// TODO: Provide operations for `CharLiteral`. - class Char { adapt u8; } @@ -30,18 +26,17 @@ impl Char as Copy { // Conversions. impl CharLiteral as ImplicitAs(Char) { - fn Convert(self) -> Char = "char.convert_checked"; + fn Convert(self) -> Char = "char_literal.convert_char"; } // TODO: Remove these once ImplicitAs extends As. impl CharLiteral as As(Char) { - fn Convert(self) -> Char = "char.convert_checked"; + fn Convert(self) -> Char = "char_literal.convert_char"; } impl forall [From:! IntLiteral] UInt(From) as As(Char) { fn Convert(self) -> Char = "int.convert_char"; } - // `char` explicitly converts to any type that `u8` implicitly converts to. impl forall [T:! type where u8 impls ImplicitAs(.Self)] Char as As(T) { fn Convert(self) -> T { @@ -98,7 +93,7 @@ impl forall [T:! AnyInt & As(u8)] Char as AddWith(T) where .Result = Char { fn Op(self, other: T) -> Self { // TODO: This should be erroneous if the addition overflows. - return ((self as u8) + (other as u8)) as char; + return ((self as u8) + (other as u8)) as Char; } } @@ -106,7 +101,7 @@ impl forall [T:! AnyInt & As(u8)] T as AddWith(Char) where .Result = Char { fn Op(self, other: Char) -> Char { // TODO: This should be erroneous if the addition overflows. - return ((self as u8) + (other as u8)) as char; + return ((self as u8) + (other as u8)) as Char; } } @@ -114,7 +109,7 @@ final impl forall [T:! AnyInt & As(u8)] Char as SubWith(T) where .Result = Char { fn Op(self, other: T) -> Self { // TODO: This should be erroneous if the addition overflows. - return ((self as u8) - (other as u8)) as char; + return ((self as u8) - (other as u8)) as Char; } } diff --git a/core/prelude/types/char_literal.carbon b/core/prelude/types/char_literal.carbon new file mode 100644 index 000000000000..5edf3b18eb55 --- /dev/null +++ b/core/prelude/types/char_literal.carbon @@ -0,0 +1,8 @@ +// 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 + +package Core library "prelude/types/char_literal"; + +private fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); diff --git a/core/prelude/types/float.carbon b/core/prelude/types/float.carbon index 66173c5b3dd3..99970f24d1c1 100644 --- a/core/prelude/types/float.carbon +++ b/core/prelude/types/float.carbon @@ -72,7 +72,7 @@ impl forall [From:! IntLiteral, To:! AnyFloat where Float(From) impls FloatFitsI // impl forall [From:! IntLiteral, To:! IntLiteral // where Float(From) impls FloatFitsIn(Float(To))] // Float(From) as ImplicitAs(Float(To)) { -// fn Convert[self: Self]() -> Float(To) = "float.convert"; +// fn Convert(self) -> Float(To) = "float.convert"; // } // Conversions from floating-point to integer type. Always unsafe: not all @@ -163,13 +163,13 @@ impl forall [To:! IntLiteral, From:! IntImplicitAsFloat(To)] // impl forall [From:! IntLiteral, To:! IntLiteral // where Int(From) impls ImplicitAs(Float(To))] // Int(From) as ImplicitAs(Float(To)) { -// fn Convert[self: Self]() -> Float(To) = "int.convert_float"; +// fn Convert(self) -> Float(To) = "int.convert_float"; // } // // impl forall [From:! IntLiteral, To:! IntLiteral // where UInt(From) impls ImplicitAs(Float(To))] // UInt(From) as ImplicitAs(Float(To)) { -// fn Convert[self: Self]() -> Float(To) = "int.convert_float"; +// fn Convert(self) -> Float(To) = "int.convert_float"; // } impl forall [To:! IntLiteral] diff --git a/core/prelude/types/int.carbon b/core/prelude/types/int.carbon index 93fe1310f7ac..72e202eddbf7 100644 --- a/core/prelude/types/int.carbon +++ b/core/prelude/types/int.carbon @@ -8,8 +8,9 @@ import library "prelude/copy"; import library "prelude/default"; import library "prelude/destroy"; import library "prelude/operators"; -import library "prelude/types/int_literal"; +import library "prelude/types/char_literal"; import library "prelude/types/float_literal"; +import library "prelude/types/int_literal"; private fn MakeInt(size: IntLiteral) -> type = "int.make_type_signed"; @@ -70,6 +71,15 @@ final impl forall [From:! IntLiteral, To:! IntLiteral] Int(From) as As(Int(To)) fn Convert(self) -> Int(To) = "int.convert"; } +// Explicit conversion to/from character literals. +impl forall [N:! IntLiteral] Int(N) as As(CharLiteral) { + fn Convert(self) -> CharLiteral = "int.convert_char_literal"; +} + +impl forall [N:! IntLiteral] CharLiteral as As(Int(N)) { + fn Convert(self) -> Int(N) = "char_literal.convert_int"; +} + // Explicit conversion from floating-point literals. impl forall [To:! IntLiteral] FloatLiteral as UnsafeAs(Int(To)) { @@ -211,6 +221,21 @@ impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))] fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.ssub"; } +// - CharLiteral and Int(N). + +impl forall [N:! IntLiteral] CharLiteral as AddWith(Int(N)) where .Result = CharLiteral { + fn Op(self, other: Int(N)) -> CharLiteral = "char_literal.add"; +} + +impl forall [N:! IntLiteral] Int(N) as AddWith(CharLiteral) where .Result = CharLiteral { + fn Op(self, other: CharLiteral) -> CharLiteral = "int.add_char_literal"; +} + +impl forall [N:! IntLiteral] CharLiteral as SubWith(Int(N)) where .Result = CharLiteral { + fn Op(self, other: Int(N)) -> CharLiteral = "char_literal.sub_int"; +} + + // Bitwise operators. // - Homogeneous. @@ -351,6 +376,7 @@ impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))] fn Op(ref self, other: Self) = "int.ssub_assign"; } + // Increment and decrement. // TODO: Add builtins for these to avoid emitting a call. diff --git a/core/prelude/types/uint.carbon b/core/prelude/types/uint.carbon index 852f7f034c6b..421913755656 100644 --- a/core/prelude/types/uint.carbon +++ b/core/prelude/types/uint.carbon @@ -8,9 +8,10 @@ import library "prelude/copy"; import library "prelude/default"; import library "prelude/destroy"; import library "prelude/operators"; +import library "prelude/types/char_literal"; +import library "prelude/types/float_literal"; import library "prelude/types/int"; import library "prelude/types/int_literal"; -import library "prelude/types/float_literal"; private fn MakeUInt(size: IntLiteral) -> type = "int.make_type_unsigned"; @@ -102,6 +103,15 @@ impl forall [From:! IntLiteral, To:! IntLiteral] Int(From) as As(UInt(To)) { fn Convert(self) -> UInt(To) = "int.convert"; } +// Explicit conversion to/from character literals. +impl forall [N:! IntLiteral] UInt(N) as As(CharLiteral) { + fn Convert(self) -> CharLiteral = "int.convert_char_literal"; +} + +impl forall [N:! IntLiteral] CharLiteral as As(UInt(N)) { + fn Convert(self) -> UInt(N) = "char_literal.convert_int"; +} + // Explicit conversion from floating-point literals. impl forall [To:! IntLiteral] FloatLiteral as UnsafeAs(UInt(To)) { @@ -273,6 +283,21 @@ impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))] fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.usub"; } +// - CharLiteral and UInt(N). + +impl forall [N:! IntLiteral] CharLiteral as AddWith(UInt(N)) where .Result = CharLiteral { + fn Op(self, other: UInt(N)) -> CharLiteral = "char_literal.add"; +} + +impl forall [N:! IntLiteral] UInt(N) as AddWith(CharLiteral) where .Result = CharLiteral { + fn Op(self, other: CharLiteral) -> CharLiteral = "int.add_char_literal"; +} + +impl forall [N:! IntLiteral] CharLiteral as SubWith(UInt(N)) where .Result = CharLiteral { + fn Op(self, other: UInt(N)) -> CharLiteral = "char_literal.sub_int"; +} + + // Bitwise operators. // - Homogeneous. @@ -413,6 +438,7 @@ impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))] fn Op(ref self, other: Self) = "int.usub_assign"; } + // Increment and decrement. // TODO: Add builtins for these to avoid emitting a call. diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 5fbc4f09c15b..0c6e33c30d26 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -1129,21 +1129,27 @@ static auto PerformArrayIndex(EvalContext& eval_context, SemIR::ArrayIndex inst) return eval_context.GetConstantValue(elements[index_val.getZExtValue()]); } +// Diagnoses that a character value is too large for the destination type. +static auto DiagnoseCharTooLargeForType(Context& context, SemIR::LocId loc_id, + SemIR::CharId char_id, + SemIR::TypeId dest_type_id) -> void { + CARBON_DIAGNOSTIC(CharTooLargeForType, Error, + "character value {0} too large for type {1}", SemIR::CharId, + SemIR::TypeId); + context.emitter().Emit(loc_id, CharTooLargeForType, char_id, dest_type_id); +} + // Performs a conversion between character types, diagnosing if the value // doesn't fit in the destination type. -static auto PerformCheckedCharConvert(Context& context, SemIR::LocId loc_id, - SemIR::InstId arg_id, - SemIR::TypeId dest_type_id) +static auto PerformCharLiteralConvertChar(Context& context, SemIR::LocId loc_id, + SemIR::InstId arg_id, + SemIR::TypeId dest_type_id) -> SemIR::ConstantId { auto arg = context.insts().GetAs(arg_id); // Values over 0x80 require multiple code units in UTF-8. if (arg.value.index >= 0x80) { - CARBON_DIAGNOSTIC(CharTooLargeForType, Error, - "character value {0} too large for type {1}", - SemIR::CharId, SemIR::TypeId); - context.emitter().Emit(loc_id, CharTooLargeForType, arg.value, - dest_type_id); + DiagnoseCharTooLargeForType(context, loc_id, arg.value, dest_type_id); return SemIR::ErrorInst::ConstantId; } @@ -1152,6 +1158,132 @@ static auto PerformCheckedCharConvert(Context& context, SemIR::LocId loc_id, std::move(int_val)); } +// Converts a CharLiteral to an integer type. +static auto PerformCharLiteralConvertInt(Context& context, SemIR::LocId loc_id, + SemIR::InstId arg_id, + SemIR::TypeId dest_type_id) + -> SemIR::ConstantId { + auto arg = context.insts().GetAs(arg_id); + auto [is_signed, bit_width_id] = + context.sem_ir().types().GetIntTypeInfo(dest_type_id); + CARBON_CHECK(bit_width_id.has_value()); + unsigned int width = context.ints().Get(bit_width_id).getZExtValue(); + + int32_t code_point = arg.value.index; + // Determine the bit width of the code point value. Log2_32(0) is -1, so this + // correctly computes a width of 0 for U+0000. + unsigned code_point_bit_width = llvm::Log2_32(code_point) + 1; + if (code_point_bit_width > width - is_signed) { + DiagnoseCharTooLargeForType(context, loc_id, arg.value, dest_type_id); + return SemIR::ErrorInst::ConstantId; + } + + llvm::APInt int_val(width, code_point, /*isSigned=*/false); + return MakeIntResult(context, dest_type_id, is_signed, std::move(int_val)); +} + +// Converts an integer to a CharLiteral, checking if the value is a valid +// Unicode code point. +static auto PerformIntConvertCharLiteral(Context& context, SemIR::LocId loc_id, + SemIR::InstId arg_id, + SemIR::TypeId dest_type_id) + -> SemIR::ConstantId { + auto arg = context.insts().GetAs(arg_id); + llvm::APInt arg_val = context.ints().Get(arg.int_id); + auto char_id = SemIR::CharId::ForCodePoint(arg_val); + if (!char_id) { + CARBON_DIAGNOSTIC(InvalidCharLiteralValue, Error, + "integer value {0} is not a valid Unicode code point", + TypedInt); + context.emitter().Emit(loc_id, InvalidCharLiteralValue, + {.type = arg.type_id, .value = arg_val}); + return SemIR::ErrorInst::ConstantId; + } + return MakeConstantResult( + context, + SemIR::CharLiteralValue{.type_id = dest_type_id, .value = *char_id}, + Phase::Concrete); +} + +// Performs a comparison between two CharLiteral values. +static auto PerformCharLiteralComparison( + Context& context, SemIR::BuiltinFunctionKind builtin_kind, + SemIR::InstId lhs_id, SemIR::InstId rhs_id, SemIR::TypeId bool_type_id) + -> SemIR::ConstantId { + auto lhs = context.insts().GetAs(lhs_id); + auto rhs = context.insts().GetAs(rhs_id); + bool result; + switch (builtin_kind) { + case SemIR::BuiltinFunctionKind::CharLiteralEq: + result = (lhs.value.index == rhs.value.index); + break; + case SemIR::BuiltinFunctionKind::CharLiteralNeq: + result = (lhs.value.index != rhs.value.index); + break; + case SemIR::BuiltinFunctionKind::CharLiteralLess: + result = (lhs.value.index < rhs.value.index); + break; + case SemIR::BuiltinFunctionKind::CharLiteralLessEq: + result = (lhs.value.index <= rhs.value.index); + break; + case SemIR::BuiltinFunctionKind::CharLiteralGreater: + result = (lhs.value.index > rhs.value.index); + break; + case SemIR::BuiltinFunctionKind::CharLiteralGreaterEq: + result = (lhs.value.index >= rhs.value.index); + break; + default: + CARBON_FATAL("Unexpected operation kind."); + } + return MakeBoolResult(context, bool_type_id, result); +} + +// Performs subtraction/addition of CharLiteral and Int. +static auto PerformCharLiteralArithmetic( + Context& context, SemIR::LocId loc_id, + SemIR::BuiltinFunctionKind builtin_kind, SemIR::InstId lhs_id, + SemIR::InstId rhs_id, SemIR::TypeId dest_type_id) -> SemIR::ConstantId { + auto lhs = context.insts().GetAs(lhs_id); + auto rhs = context.insts().GetAs(rhs_id); + const llvm::APInt& rhs_val = context.ints().Get(rhs.int_id); + + // The code point value fits in 21 bits, so 32 bits is plenty for the + // CharLiteral. Active bits + 2 gives us room for a sign bit and a carry, + // while avoiding an APInt heap allocation except on the error path. + auto val = rhs_val.sextOrTrunc(std::max(32U, rhs_val.getActiveBits() + 2)); + if (builtin_kind == SemIR::BuiltinFunctionKind::CharLiteralSubInt) { + val.negate(); + } + val += lhs.value.index; + + auto char_id = SemIR::CharId::ForCodePoint(val); + if (!char_id) { + CARBON_DIAGNOSTIC(InvalidCharLiteralArithmeticResult, Error, + "character arithmetic result {0} is not a valid " + "Unicode code point", + llvm::APSInt); + context.emitter().Emit(loc_id, InvalidCharLiteralArithmeticResult, + llvm::APSInt(val, /*isUnsigned=*/false)); + return SemIR::ErrorInst::ConstantId; + } + return MakeConstantResult( + context, + SemIR::CharLiteralValue{.type_id = dest_type_id, .value = *char_id}, + Phase::Concrete); +} + +// Performs subtraction of two CharLiteral values. +static auto PerformCharLiteralSubChar(Context& context, SemIR::InstId lhs_id, + SemIR::InstId rhs_id, + SemIR::TypeId dest_type_id) + -> SemIR::ConstantId { + auto lhs = context.insts().GetAs(lhs_id); + auto rhs = context.insts().GetAs(rhs_id); + int32_t result = lhs.value.index - rhs.value.index; + return MakeIntResult(context, dest_type_id, /*is_signed=*/true, + llvm::APInt(32, result, /*isSigned=*/true)); +} + // Forms a constant int type as an evaluation result. Requires that width_id is // constant. static auto MakeIntTypeResult(Context& context, SemIR::LocId loc_id, @@ -2289,14 +2421,62 @@ static auto MakeConstantForBuiltinCall(EvalContext& eval_context, return context.constant_values().Get(SemIR::FormType::TypeInstId); } - // Character conversions. - case SemIR::BuiltinFunctionKind::CharConvertChecked: { + case SemIR::BuiltinFunctionKind::CharLiteralAdd: + case SemIR::BuiltinFunctionKind::CharLiteralSubInt: { + if (phase != Phase::Concrete) { + break; + } + return PerformCharLiteralArithmetic(context, loc_id, builtin_kind, + arg_ids[0], arg_ids[1], call.type_id); + } + case SemIR::BuiltinFunctionKind::CharLiteralConvertChar: { if (phase != Phase::Concrete) { return MakeConstantResult(context, call, phase); } - return PerformCheckedCharConvert(context, loc_id, arg_ids[0], + return PerformCharLiteralConvertChar(context, loc_id, arg_ids[0], + call.type_id); + } + case SemIR::BuiltinFunctionKind::CharLiteralConvertInt: { + if (phase != Phase::Concrete) { + return MakeConstantResult(context, call, phase); + } + return PerformCharLiteralConvertInt(context, loc_id, arg_ids[0], + call.type_id); + } + case SemIR::BuiltinFunctionKind::CharLiteralEq: + case SemIR::BuiltinFunctionKind::CharLiteralGreater: + case SemIR::BuiltinFunctionKind::CharLiteralGreaterEq: + case SemIR::BuiltinFunctionKind::CharLiteralLess: + case SemIR::BuiltinFunctionKind::CharLiteralLessEq: + case SemIR::BuiltinFunctionKind::CharLiteralNeq: { + if (phase != Phase::Concrete) { + break; + } + return PerformCharLiteralComparison(context, builtin_kind, arg_ids[0], + arg_ids[1], call.type_id); + } + case SemIR::BuiltinFunctionKind::CharLiteralSubChar: { + if (phase != Phase::Concrete) { + break; + } + return PerformCharLiteralSubChar(context, arg_ids[0], arg_ids[1], call.type_id); } + case SemIR::BuiltinFunctionKind::IntAddCharLiteral: { + if (phase != Phase::Concrete) { + break; + } + return PerformCharLiteralArithmetic( + context, loc_id, SemIR::BuiltinFunctionKind::CharLiteralAdd, + arg_ids[1], arg_ids[0], call.type_id); + } + case SemIR::BuiltinFunctionKind::IntConvertCharLiteral: { + if (phase != Phase::Concrete) { + return MakeConstantResult(context, call, phase); + } + return PerformIntConvertCharLiteral(context, loc_id, arg_ids[0], + call.type_id); + } // Integer conversions. case SemIR::BuiltinFunctionKind::IntConvertChar: { diff --git a/toolchain/check/handle_literal.cpp b/toolchain/check/handle_literal.cpp index 46d57487e156..ca1110cc865b 100644 --- a/toolchain/check/handle_literal.cpp +++ b/toolchain/check/handle_literal.cpp @@ -35,10 +35,13 @@ auto HandleParseNode(Context& context, Parse::BoolLiteralTrueId node_id) auto HandleParseNode(Context& context, Parse::CharLiteralId node_id) -> bool { auto value = context.tokens().GetCharLiteralValue( context.parse_tree().node_token(node_id)); + auto char_id = SemIR::CharId::ForCodePoint(llvm::APInt(32, value.value)); + CARBON_CHECK(char_id.has_value(), "Invalid character literal parsed: {0}", + value.value); auto inst_id = AddInst( context, node_id, {.type_id = GetSingletonType(context, SemIR::CharLiteralType::TypeInstId), - .value = SemIR::CharId(value.value)}); + .value = *char_id}); context.node_stack().Push(node_id, inst_id); return true; } diff --git a/toolchain/check/testdata/array/bound_values.carbon b/toolchain/check/testdata/array/bound_values.carbon index 9940cde8a559..bb586958061f 100644 --- a/toolchain/check/testdata/array/bound_values.carbon +++ b/toolchain/check/testdata/array/bound_values.carbon @@ -87,7 +87,7 @@ var b: array(1, 39999999999999999993); // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core.import_ref.abd = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, unloaded // CHECK:STDOUT: %Core.import_ref.9c3: %Core.IntLiteral.as.AddWith.impl.Op.type = import_ref Core//prelude/operators/arithmetic, loc{{\d+_\d+}}, loaded [concrete = constants.%Core.IntLiteral.as.AddWith.impl.Op] -// CHECK:STDOUT: %AddWith.impl_witness_table = impl_witness_table (%Core.import_ref.abd, %Core.import_ref.9c3), @Core.IntLiteral.as.AddWith.impl [concrete] +// CHECK:STDOUT: %AddWith.impl_witness_table = impl_witness_table (%Core.import_ref.abd, %Core.import_ref.9c3), @Core.IntLiteral.as.AddWith.impl.d4d [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -118,11 +118,11 @@ var b: array(1, 39999999999999999993); // CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete] // CHECK:STDOUT: %As.type.8bf: type = facet_type <@As, @As(%u32)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.fb3: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.fb3: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.e51(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.f86: %Core.IntLiteral.as.As.impl.Convert.type.fb3 = struct_value () [symbolic] // CHECK:STDOUT: %From.fe9: Core.IntLiteral = symbolic_binding From, 0 [symbolic] -// CHECK:STDOUT: %As.impl_witness.384: = impl_witness imports.%As.impl_witness_table.8fa, @Core.IntLiteral.as.As.impl(%int_32) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.afd: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_32) [concrete] +// CHECK:STDOUT: %As.impl_witness.384: = impl_witness imports.%As.impl_witness_table.8fa, @Core.IntLiteral.as.As.impl.e51(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.afd: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.e51(%int_32) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.776: %Core.IntLiteral.as.As.impl.Convert.type.afd = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.8bf = facet_value Core.IntLiteral, (%As.impl_witness.384) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.adb: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%u32, %As.facet) [concrete] @@ -147,8 +147,8 @@ var b: array(1, 39999999999999999993); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core.import_ref.59a: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.fb3) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.f86)] -// CHECK:STDOUT: %As.impl_witness_table.8fa = impl_witness_table (%Core.import_ref.59a), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.59a: @Core.IntLiteral.as.As.impl.e51.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.fb3) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.e51.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.f86)] +// CHECK:STDOUT: %As.impl_witness_table.8fa = impl_witness_table (%Core.import_ref.59a), @Core.IntLiteral.as.As.impl.e51 [concrete] // CHECK:STDOUT: %Core.import_ref.baa: @UInt.as.ImplicitAs.impl.3d3.%UInt.as.ImplicitAs.impl.Convert.type (%UInt.as.ImplicitAs.impl.Convert.type.3ec) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @UInt.as.ImplicitAs.impl.3d3.%UInt.as.ImplicitAs.impl.Convert (constants.%UInt.as.ImplicitAs.impl.Convert.06e)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a83 = impl_witness_table (%Core.import_ref.baa), @UInt.as.ImplicitAs.impl.3d3 [concrete] // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/builtins/char_literal/add.carbon b/toolchain/check/testdata/builtins/char_literal/add.carbon new file mode 100644 index 000000000000..5df509922c21 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/add.carbon @@ -0,0 +1,130 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/add.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/add.carbon + +// --- success.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn AddCharInt(c: CharLiteral, n: IntLiteral) -> CharLiteral = "char_literal.add"; + +//@dump-sem-ir-begin +let a: CharLiteral = AddCharInt('a', 1); +// It's fine to perform an addition that is in-bounds for `CharLiteral` but out +// of the range of a `char` or a byte. +let b: CharLiteral = AddCharInt('\u{7F}', 1); +let c: CharLiteral = AddCharInt('\u{FF}', 1); +//@dump-sem-ir-end + +// --- fail_overflow.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn AddCharInt(c: CharLiteral, n: IntLiteral) -> CharLiteral = "char_literal.add"; +fn Negate(n: IntLiteral) -> IntLiteral = "int.snegate"; + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:22: error: character arithmetic result 4503599627370593 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let a: CharLiteral = AddCharInt('a', 0x10000000000000); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let a: CharLiteral = AddCharInt('a', 0x10000000000000); + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+11]]:5: error: duplicate name `a` being declared in the same scope [NameDeclDuplicate] +// CHECK:STDERR: let a: CharLiteral = AddCharInt('\u{10FFFF}', 1); +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_overflow.carbon:[[@LINE-5]]:5: note: name is previously declared here [NameDeclPrevious] +// CHECK:STDERR: let a: CharLiteral = AddCharInt('a', 0x10000000000000); +// CHECK:STDERR: ^~~~~~~~~~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:22: error: character arithmetic result 1114112 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let a: CharLiteral = AddCharInt('\u{10FFFF}', 1); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let a: CharLiteral = AddCharInt('\u{10FFFF}', 1); + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:22: error: character arithmetic result 55296 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let b: CharLiteral = AddCharInt('\u{D7FF}', 1); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let b: CharLiteral = AddCharInt('\u{D7FF}', 1); + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:22: error: character arithmetic result -1 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let c: CharLiteral = AddCharInt('a', Negate(98)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let c: CharLiteral = AddCharInt('a', Negate(98)); + +// CHECK:STDOUT: --- success.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.8c6: type = pattern_type Core.CharLiteral [concrete] +// CHECK:STDOUT: %AddCharInt.type: type = fn_type @AddCharInt [concrete] +// CHECK:STDOUT: %AddCharInt: %AddCharInt.type = struct_value () [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %.e28: Core.CharLiteral = char_value U+007F [concrete] +// CHECK:STDOUT: %.ae7: Core.CharLiteral = char_value U+0080 [concrete] +// CHECK:STDOUT: %.ad8: Core.CharLiteral = char_value U+00FF [concrete] +// CHECK:STDOUT: %.a8b: Core.CharLiteral = char_value U+0100 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.8c6 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc12: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc12_39.1: Core.CharLiteral = value_of_initializer @__global_init.%AddCharInt.call.loc12 [concrete = constants.%.711] +// CHECK:STDOUT: %.loc12_39.2: Core.CharLiteral = converted @__global_init.%AddCharInt.call.loc12, %.loc12_39.1 [concrete = constants.%.711] +// CHECK:STDOUT: %a: Core.CharLiteral = value_binding a, %.loc12_39.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.8c6 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc15: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc15_44.1: Core.CharLiteral = value_of_initializer @__global_init.%AddCharInt.call.loc15 [concrete = constants.%.ae7] +// CHECK:STDOUT: %.loc15_44.2: Core.CharLiteral = converted @__global_init.%AddCharInt.call.loc15, %.loc15_44.1 [concrete = constants.%.ae7] +// CHECK:STDOUT: %b: Core.CharLiteral = value_binding b, %.loc15_44.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %pattern_type.8c6 = value_binding_pattern c [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc16: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc16_44.1: Core.CharLiteral = value_of_initializer @__global_init.%AddCharInt.call.loc16 [concrete = constants.%.a8b] +// CHECK:STDOUT: %.loc16_44.2: Core.CharLiteral = converted @__global_init.%AddCharInt.call.loc16, %.loc16_44.1 [concrete = constants.%.a8b] +// CHECK:STDOUT: %c: Core.CharLiteral = value_binding c, %.loc16_44.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %AddCharInt.ref.loc12: %AddCharInt.type = name_ref AddCharInt, file.%AddCharInt.decl [concrete = constants.%AddCharInt] +// CHECK:STDOUT: %.loc12: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %AddCharInt.call.loc12: init Core.CharLiteral = call %AddCharInt.ref.loc12(%.loc12, %int_1.loc12) [concrete = constants.%.711] +// CHECK:STDOUT: %AddCharInt.ref.loc15: %AddCharInt.type = name_ref AddCharInt, file.%AddCharInt.decl [concrete = constants.%AddCharInt] +// CHECK:STDOUT: %.loc15: Core.CharLiteral = char_value U+007F [concrete = constants.%.e28] +// CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %AddCharInt.call.loc15: init Core.CharLiteral = call %AddCharInt.ref.loc15(%.loc15, %int_1.loc15) [concrete = constants.%.ae7] +// CHECK:STDOUT: %AddCharInt.ref.loc16: %AddCharInt.type = name_ref AddCharInt, file.%AddCharInt.decl [concrete = constants.%AddCharInt] +// CHECK:STDOUT: %.loc16: Core.CharLiteral = char_value U+00FF [concrete = constants.%.ad8] +// CHECK:STDOUT: %int_1.loc16: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %AddCharInt.call.loc16: init Core.CharLiteral = call %AddCharInt.ref.loc16(%.loc16, %int_1.loc16) [concrete = constants.%.a8b] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char/convert_checked.carbon b/toolchain/check/testdata/builtins/char_literal/convert_char.carbon similarity index 90% rename from toolchain/check/testdata/builtins/char/convert_checked.carbon rename to toolchain/check/testdata/builtins/char_literal/convert_char.carbon index 1aa3420169de..717d7200aaaf 100644 --- a/toolchain/check/testdata/builtins/char/convert_checked.carbon +++ b/toolchain/check/testdata/builtins/char_literal/convert_char.carbon @@ -1,14 +1,13 @@ // 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/builtins/char/convert_checked.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/convert_char.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char/convert_checked.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/convert_char.carbon // --- builtin.carbon @@ -20,30 +19,30 @@ fn MakeIntLiteral() -> type = "int_literal.make_type"; alias IntLiteral = MakeIntLiteral(); fn UInt(n: IntLiteral) -> type = "int.make_type_unsigned"; -fn ToChar(c: CharLiteral) -> UInt(8) = "char.convert_checked"; +fn ToChar(c: CharLiteral) -> UInt(8) = "char_literal.convert_char"; // --- fail_bad_decl.carbon library "[[@TEST_NAME]]"; import library "builtin"; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "char.convert_checked" [InvalidBuiltinSignature] -// CHECK:STDERR: fn ToCharBarResultU16(c: CharLiteral) -> UInt(16) = "char.convert_checked"; +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "char_literal.convert_char" [InvalidBuiltinSignature] +// CHECK:STDERR: fn ToCharBarResultU16(c: CharLiteral) -> UInt(16) = "char_literal.convert_char"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -fn ToCharBarResultU16(c: CharLiteral) -> UInt(16) = "char.convert_checked"; +fn ToCharBarResultU16(c: CharLiteral) -> UInt(16) = "char_literal.convert_char"; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "char.convert_checked" [InvalidBuiltinSignature] -// CHECK:STDERR: fn ToCharBadResultU9(c: CharLiteral) -> UInt(9) = "char.convert_checked"; +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "char_literal.convert_char" [InvalidBuiltinSignature] +// CHECK:STDERR: fn ToCharBadResultU9(c: CharLiteral) -> UInt(9) = "char_literal.convert_char"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -fn ToCharBadResultU9(c: CharLiteral) -> UInt(9) = "char.convert_checked"; +fn ToCharBadResultU9(c: CharLiteral) -> UInt(9) = "char_literal.convert_char"; -// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "char.convert_checked" [InvalidBuiltinSignature] -// CHECK:STDERR: fn ToCharNoParam() -> UInt(8) = "char.convert_checked"; +// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "char_literal.convert_char" [InvalidBuiltinSignature] +// CHECK:STDERR: fn ToCharNoParam() -> UInt(8) = "char_literal.convert_char"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: -fn ToCharNoParam() -> UInt(8) = "char.convert_checked"; +fn ToCharNoParam() -> UInt(8) = "char_literal.convert_char"; // --- fail_runtime_call.carbon @@ -56,7 +55,7 @@ let c: CharLiteral = 'a'; // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: fail_runtime_call.carbon:[[@LINE-6]]:1: in import [InImport] // CHECK:STDERR: builtin.carbon:10:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] -// CHECK:STDERR: fn ToChar(c: CharLiteral) -> UInt(8) = "char.convert_checked"; +// CHECK:STDERR: fn ToChar(c: CharLiteral) -> UInt(8) = "char_literal.convert_char"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: let d: UInt(8) = ToChar(c); diff --git a/toolchain/check/testdata/builtins/char_literal/convert_int.carbon b/toolchain/check/testdata/builtins/char_literal/convert_int.carbon new file mode 100644 index 000000000000..b7f6d5eff40d --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/convert_int.carbon @@ -0,0 +1,168 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/convert_int.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/convert_int.carbon + +// --- success.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); + +fn ConvertToI32(c: CharLiteral) -> i32 = "char_literal.convert_int"; +fn ConvertToU32(c: CharLiteral) -> u32 = "char_literal.convert_int"; +fn ConvertToI64(c: CharLiteral) -> i64 = "char_literal.convert_int"; +fn ConvertToU64(c: CharLiteral) -> u64 = "char_literal.convert_int"; +fn ConvertToU8(c: CharLiteral) -> u8 = "char_literal.convert_int"; + +//@dump-sem-ir-begin +let a: i32 = ConvertToI32('a'); +let b: u32 = ConvertToU32('b'); +let c: i64 = ConvertToI64('\u{10FFFF}'); +let d: u64 = ConvertToU64('\0'); +// Code points in [U+0080, U+00FF] fit in u8 but not in char. +let e: u8 = ConvertToU8('\u{80}'); +let f: u8 = ConvertToU8('\u{FF}'); +//@dump-sem-ir-end + +// --- fail_overflow.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); +fn UInt(n: IntLiteral) -> type = "int.make_type_unsigned"; + +fn ConvertToU8(c: CharLiteral) -> UInt(8) = "char_literal.convert_int"; + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+11]]:13: error: character value U+0100 too large for type `` [CharTooLargeForType] +// CHECK:STDERR: let g: u8 = ConvertToU8('\u{100}'); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+7]]:13: error: cannot implicitly convert expression of type `` to `u8` [ConversionFailure] +// CHECK:STDERR: let g: u8 = ConvertToU8('\u{100}'); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:13: note: type `` does not implement interface `Core.ImplicitAs(u8)` [MissingImplInMemberAccessInContext] +// CHECK:STDERR: let g: u8 = ConvertToU8('\u{100}'); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let g: u8 = ConvertToU8('\u{100}'); + +// CHECK:STDOUT: --- success.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete] +// CHECK:STDOUT: %ConvertToI32.type: type = fn_type @ConvertToI32 [concrete] +// CHECK:STDOUT: %ConvertToI32: %ConvertToI32.type = struct_value () [concrete] +// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.668: type = pattern_type %u32 [concrete] +// CHECK:STDOUT: %ConvertToU32.type: type = fn_type @ConvertToU32 [concrete] +// CHECK:STDOUT: %ConvertToU32: %ConvertToU32.type = struct_value () [concrete] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.f57: type = pattern_type %i64 [concrete] +// CHECK:STDOUT: %ConvertToI64.type: type = fn_type @ConvertToI64 [concrete] +// CHECK:STDOUT: %ConvertToI64: %ConvertToI64.type = struct_value () [concrete] +// CHECK:STDOUT: %u64: type = class_type @UInt, @UInt(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.b35: type = pattern_type %u64 [concrete] +// CHECK:STDOUT: %ConvertToU64.type: type = fn_type @ConvertToU64 [concrete] +// CHECK:STDOUT: %ConvertToU64: %ConvertToU64.type = struct_value () [concrete] +// CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete] +// CHECK:STDOUT: %u8: type = class_type @UInt, @UInt(%int_8) [concrete] +// CHECK:STDOUT: %pattern_type.186: type = pattern_type %u8 [concrete] +// CHECK:STDOUT: %ConvertToU8.type: type = fn_type @ConvertToU8 [concrete] +// CHECK:STDOUT: %ConvertToU8: %ConvertToU8.type = struct_value () [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %int_97: %i32 = int_value 97 [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %int_98: %u32 = int_value 98 [concrete] +// CHECK:STDOUT: %.914: Core.CharLiteral = char_value U+10FFFF [concrete] +// CHECK:STDOUT: %int_1114111: %i64 = int_value 1114111 [concrete] +// CHECK:STDOUT: %.dc9: Core.CharLiteral = char_value U+0000 [concrete] +// CHECK:STDOUT: %int_0: %u64 = int_value 0 [concrete] +// CHECK:STDOUT: %.ae7: Core.CharLiteral = char_value U+0080 [concrete] +// CHECK:STDOUT: %int_128: %u8 = int_value 128 [concrete] +// CHECK:STDOUT: %.ad8: Core.CharLiteral = char_value U+00FF [concrete] +// CHECK:STDOUT: %int_255: %u8 = int_value 255 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.6b6 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc14_30.1: %i32 = value_of_initializer @__global_init.%ConvertToI32.call [concrete = constants.%int_97] +// CHECK:STDOUT: %.loc14_30.2: %i32 = converted @__global_init.%ConvertToI32.call, %.loc14_30.1 [concrete = constants.%int_97] +// CHECK:STDOUT: %a: %i32 = value_binding a, %.loc14_30.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.668 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u32: type = type_literal constants.%u32 [concrete = constants.%u32] +// CHECK:STDOUT: %.loc15_30.1: %u32 = value_of_initializer @__global_init.%ConvertToU32.call [concrete = constants.%int_98] +// CHECK:STDOUT: %.loc15_30.2: %u32 = converted @__global_init.%ConvertToU32.call, %.loc15_30.1 [concrete = constants.%int_98] +// CHECK:STDOUT: %b: %u32 = value_binding b, %.loc15_30.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %pattern_type.f57 = value_binding_pattern c [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i64: type = type_literal constants.%i64 [concrete = constants.%i64] +// CHECK:STDOUT: %.loc16_39.1: %i64 = value_of_initializer @__global_init.%ConvertToI64.call [concrete = constants.%int_1114111] +// CHECK:STDOUT: %.loc16_39.2: %i64 = converted @__global_init.%ConvertToI64.call, %.loc16_39.1 [concrete = constants.%int_1114111] +// CHECK:STDOUT: %c: %i64 = value_binding c, %.loc16_39.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %pattern_type.b35 = value_binding_pattern d [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u64: type = type_literal constants.%u64 [concrete = constants.%u64] +// CHECK:STDOUT: %.loc17_31.1: %u64 = value_of_initializer @__global_init.%ConvertToU64.call [concrete = constants.%int_0] +// CHECK:STDOUT: %.loc17_31.2: %u64 = converted @__global_init.%ConvertToU64.call, %.loc17_31.1 [concrete = constants.%int_0] +// CHECK:STDOUT: %d: %u64 = value_binding d, %.loc17_31.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %pattern_type.186 = value_binding_pattern e [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u8.loc19: type = type_literal constants.%u8 [concrete = constants.%u8] +// CHECK:STDOUT: %.loc19_33.1: %u8 = value_of_initializer @__global_init.%ConvertToU8.call.loc19 [concrete = constants.%int_128] +// CHECK:STDOUT: %.loc19_33.2: %u8 = converted @__global_init.%ConvertToU8.call.loc19, %.loc19_33.1 [concrete = constants.%int_128] +// CHECK:STDOUT: %e: %u8 = value_binding e, %.loc19_33.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %pattern_type.186 = value_binding_pattern f [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %u8.loc20: type = type_literal constants.%u8 [concrete = constants.%u8] +// CHECK:STDOUT: %.loc20_33.1: %u8 = value_of_initializer @__global_init.%ConvertToU8.call.loc20 [concrete = constants.%int_255] +// CHECK:STDOUT: %.loc20_33.2: %u8 = converted @__global_init.%ConvertToU8.call.loc20, %.loc20_33.1 [concrete = constants.%int_255] +// CHECK:STDOUT: %f: %u8 = value_binding f, %.loc20_33.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ConvertToI32.ref: %ConvertToI32.type = name_ref ConvertToI32, file.%ConvertToI32.decl [concrete = constants.%ConvertToI32] +// CHECK:STDOUT: %.loc14: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %ConvertToI32.call: init %i32 = call %ConvertToI32.ref(%.loc14) [concrete = constants.%int_97] +// CHECK:STDOUT: %ConvertToU32.ref: %ConvertToU32.type = name_ref ConvertToU32, file.%ConvertToU32.decl [concrete = constants.%ConvertToU32] +// CHECK:STDOUT: %.loc15: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %ConvertToU32.call: init %u32 = call %ConvertToU32.ref(%.loc15) [concrete = constants.%int_98] +// CHECK:STDOUT: %ConvertToI64.ref: %ConvertToI64.type = name_ref ConvertToI64, file.%ConvertToI64.decl [concrete = constants.%ConvertToI64] +// CHECK:STDOUT: %.loc16: Core.CharLiteral = char_value U+10FFFF [concrete = constants.%.914] +// CHECK:STDOUT: %ConvertToI64.call: init %i64 = call %ConvertToI64.ref(%.loc16) [concrete = constants.%int_1114111] +// CHECK:STDOUT: %ConvertToU64.ref: %ConvertToU64.type = name_ref ConvertToU64, file.%ConvertToU64.decl [concrete = constants.%ConvertToU64] +// CHECK:STDOUT: %.loc17: Core.CharLiteral = char_value U+0000 [concrete = constants.%.dc9] +// CHECK:STDOUT: %ConvertToU64.call: init %u64 = call %ConvertToU64.ref(%.loc17) [concrete = constants.%int_0] +// CHECK:STDOUT: %ConvertToU8.ref.loc19: %ConvertToU8.type = name_ref ConvertToU8, file.%ConvertToU8.decl [concrete = constants.%ConvertToU8] +// CHECK:STDOUT: %.loc19: Core.CharLiteral = char_value U+0080 [concrete = constants.%.ae7] +// CHECK:STDOUT: %ConvertToU8.call.loc19: init %u8 = call %ConvertToU8.ref.loc19(%.loc19) [concrete = constants.%int_128] +// CHECK:STDOUT: %ConvertToU8.ref.loc20: %ConvertToU8.type = name_ref ConvertToU8, file.%ConvertToU8.decl [concrete = constants.%ConvertToU8] +// CHECK:STDOUT: %.loc20: Core.CharLiteral = char_value U+00FF [concrete = constants.%.ad8] +// CHECK:STDOUT: %ConvertToU8.call.loc20: init %u8 = call %ConvertToU8.ref.loc20(%.loc20) [concrete = constants.%int_255] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/eq.carbon b/toolchain/check/testdata/builtins/char_literal/eq.carbon new file mode 100644 index 000000000000..b9bc2172d6d0 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/eq.carbon @@ -0,0 +1,66 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/eq.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/eq.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); + +fn Eq(a: CharLiteral, b: CharLiteral) -> bool = "char_literal.eq"; + +//@dump-sem-ir-begin +let a: bool = Eq('a', 'a'); +let b: bool = Eq('a', 'b'); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- eq.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] +// CHECK:STDOUT: %Eq.type: type = fn_type @Eq [concrete] +// CHECK:STDOUT: %Eq: %Eq.type = struct_value () [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %true: bool = bool_literal true [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %false: bool = bool_literal false [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.831 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc21_26.1: bool = value_of_initializer @__global_init.%Eq.call.loc21 [concrete = constants.%true] +// CHECK:STDOUT: %.loc21_26.2: bool = converted @__global_init.%Eq.call.loc21, %.loc21_26.1 [concrete = constants.%true] +// CHECK:STDOUT: %a: bool = value_binding a, %.loc21_26.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.831 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc22_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc22_26.1: bool = value_of_initializer @__global_init.%Eq.call.loc22 [concrete = constants.%false] +// CHECK:STDOUT: %.loc22_26.2: bool = converted @__global_init.%Eq.call.loc22, %.loc22_26.1 [concrete = constants.%false] +// CHECK:STDOUT: %b: bool = value_binding b, %.loc22_26.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Eq.ref.loc21: %Eq.type = name_ref Eq, file.%Eq.decl [concrete = constants.%Eq] +// CHECK:STDOUT: %.loc21_18: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc21_23: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %Eq.call.loc21: init bool = call %Eq.ref.loc21(%.loc21_18, %.loc21_23) [concrete = constants.%true] +// CHECK:STDOUT: %Eq.ref.loc22: %Eq.type = name_ref Eq, file.%Eq.decl [concrete = constants.%Eq] +// CHECK:STDOUT: %.loc22_18: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc22_23: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %Eq.call.loc22: init bool = call %Eq.ref.loc22(%.loc22_18, %.loc22_23) [concrete = constants.%false] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/greater.carbon b/toolchain/check/testdata/builtins/char_literal/greater.carbon new file mode 100644 index 000000000000..7c9fe132a232 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/greater.carbon @@ -0,0 +1,66 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/greater.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/greater.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); + +fn Greater(a: CharLiteral, b: CharLiteral) -> bool = "char_literal.greater"; + +//@dump-sem-ir-begin +let a: bool = Greater('b', 'a'); +let b: bool = Greater('a', 'b'); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- greater.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] +// CHECK:STDOUT: %Greater.type: type = fn_type @Greater [concrete] +// CHECK:STDOUT: %Greater: %Greater.type = struct_value () [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %true: bool = bool_literal true [concrete] +// CHECK:STDOUT: %false: bool = bool_literal false [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.831 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc21_31.1: bool = value_of_initializer @__global_init.%Greater.call.loc21 [concrete = constants.%true] +// CHECK:STDOUT: %.loc21_31.2: bool = converted @__global_init.%Greater.call.loc21, %.loc21_31.1 [concrete = constants.%true] +// CHECK:STDOUT: %a: bool = value_binding a, %.loc21_31.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.831 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc22_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc22_31.1: bool = value_of_initializer @__global_init.%Greater.call.loc22 [concrete = constants.%false] +// CHECK:STDOUT: %.loc22_31.2: bool = converted @__global_init.%Greater.call.loc22, %.loc22_31.1 [concrete = constants.%false] +// CHECK:STDOUT: %b: bool = value_binding b, %.loc22_31.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Greater.ref.loc21: %Greater.type = name_ref Greater, file.%Greater.decl [concrete = constants.%Greater] +// CHECK:STDOUT: %.loc21_23: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %.loc21_28: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %Greater.call.loc21: init bool = call %Greater.ref.loc21(%.loc21_23, %.loc21_28) [concrete = constants.%true] +// CHECK:STDOUT: %Greater.ref.loc22: %Greater.type = name_ref Greater, file.%Greater.decl [concrete = constants.%Greater] +// CHECK:STDOUT: %.loc22_23: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc22_28: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %Greater.call.loc22: init bool = call %Greater.ref.loc22(%.loc22_23, %.loc22_28) [concrete = constants.%false] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/greater_eq.carbon b/toolchain/check/testdata/builtins/char_literal/greater_eq.carbon new file mode 100644 index 000000000000..8ef3fc711739 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/greater_eq.carbon @@ -0,0 +1,78 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/greater_eq.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/greater_eq.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); + +fn GreaterEq(a: CharLiteral, b: CharLiteral) -> bool = "char_literal.greater_eq"; + +//@dump-sem-ir-begin +let a: bool = GreaterEq('a', 'a'); +let b: bool = GreaterEq('b', 'a'); +let c: bool = GreaterEq('a', 'b'); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- greater_eq.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] +// CHECK:STDOUT: %GreaterEq.type: type = fn_type @GreaterEq [concrete] +// CHECK:STDOUT: %GreaterEq: %GreaterEq.type = struct_value () [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %true: bool = bool_literal true [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %false: bool = bool_literal false [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.831 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc21_33.1: bool = value_of_initializer @__global_init.%GreaterEq.call.loc21 [concrete = constants.%true] +// CHECK:STDOUT: %.loc21_33.2: bool = converted @__global_init.%GreaterEq.call.loc21, %.loc21_33.1 [concrete = constants.%true] +// CHECK:STDOUT: %a: bool = value_binding a, %.loc21_33.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.831 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc22_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc22_33.1: bool = value_of_initializer @__global_init.%GreaterEq.call.loc22 [concrete = constants.%true] +// CHECK:STDOUT: %.loc22_33.2: bool = converted @__global_init.%GreaterEq.call.loc22, %.loc22_33.1 [concrete = constants.%true] +// CHECK:STDOUT: %b: bool = value_binding b, %.loc22_33.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %pattern_type.831 = value_binding_pattern c [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc23_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc23_33.1: bool = value_of_initializer @__global_init.%GreaterEq.call.loc23 [concrete = constants.%false] +// CHECK:STDOUT: %.loc23_33.2: bool = converted @__global_init.%GreaterEq.call.loc23, %.loc23_33.1 [concrete = constants.%false] +// CHECK:STDOUT: %c: bool = value_binding c, %.loc23_33.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %GreaterEq.ref.loc21: %GreaterEq.type = name_ref GreaterEq, file.%GreaterEq.decl [concrete = constants.%GreaterEq] +// CHECK:STDOUT: %.loc21_25: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc21_30: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %GreaterEq.call.loc21: init bool = call %GreaterEq.ref.loc21(%.loc21_25, %.loc21_30) [concrete = constants.%true] +// CHECK:STDOUT: %GreaterEq.ref.loc22: %GreaterEq.type = name_ref GreaterEq, file.%GreaterEq.decl [concrete = constants.%GreaterEq] +// CHECK:STDOUT: %.loc22_25: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %.loc22_30: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %GreaterEq.call.loc22: init bool = call %GreaterEq.ref.loc22(%.loc22_25, %.loc22_30) [concrete = constants.%true] +// CHECK:STDOUT: %GreaterEq.ref.loc23: %GreaterEq.type = name_ref GreaterEq, file.%GreaterEq.decl [concrete = constants.%GreaterEq] +// CHECK:STDOUT: %.loc23_25: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc23_30: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %GreaterEq.call.loc23: init bool = call %GreaterEq.ref.loc23(%.loc23_25, %.loc23_30) [concrete = constants.%false] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/less.carbon b/toolchain/check/testdata/builtins/char_literal/less.carbon new file mode 100644 index 000000000000..5838b6948a90 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/less.carbon @@ -0,0 +1,66 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/less.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/less.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); + +fn Less(a: CharLiteral, b: CharLiteral) -> bool = "char_literal.less"; + +//@dump-sem-ir-begin +let a: bool = Less('a', 'b'); +let b: bool = Less('b', 'a'); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- less.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] +// CHECK:STDOUT: %Less.type: type = fn_type @Less [concrete] +// CHECK:STDOUT: %Less: %Less.type = struct_value () [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %true: bool = bool_literal true [concrete] +// CHECK:STDOUT: %false: bool = bool_literal false [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.831 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc21_28.1: bool = value_of_initializer @__global_init.%Less.call.loc21 [concrete = constants.%true] +// CHECK:STDOUT: %.loc21_28.2: bool = converted @__global_init.%Less.call.loc21, %.loc21_28.1 [concrete = constants.%true] +// CHECK:STDOUT: %a: bool = value_binding a, %.loc21_28.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.831 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc22_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc22_28.1: bool = value_of_initializer @__global_init.%Less.call.loc22 [concrete = constants.%false] +// CHECK:STDOUT: %.loc22_28.2: bool = converted @__global_init.%Less.call.loc22, %.loc22_28.1 [concrete = constants.%false] +// CHECK:STDOUT: %b: bool = value_binding b, %.loc22_28.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Less.ref.loc21: %Less.type = name_ref Less, file.%Less.decl [concrete = constants.%Less] +// CHECK:STDOUT: %.loc21_20: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc21_25: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %Less.call.loc21: init bool = call %Less.ref.loc21(%.loc21_20, %.loc21_25) [concrete = constants.%true] +// CHECK:STDOUT: %Less.ref.loc22: %Less.type = name_ref Less, file.%Less.decl [concrete = constants.%Less] +// CHECK:STDOUT: %.loc22_20: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %.loc22_25: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %Less.call.loc22: init bool = call %Less.ref.loc22(%.loc22_20, %.loc22_25) [concrete = constants.%false] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/less_eq.carbon b/toolchain/check/testdata/builtins/char_literal/less_eq.carbon new file mode 100644 index 000000000000..3ede33801e71 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/less_eq.carbon @@ -0,0 +1,78 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/less_eq.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/less_eq.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); + +fn LessEq(a: CharLiteral, b: CharLiteral) -> bool = "char_literal.less_eq"; + +//@dump-sem-ir-begin +let a: bool = LessEq('a', 'a'); +let b: bool = LessEq('a', 'b'); +let c: bool = LessEq('b', 'a'); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- less_eq.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] +// CHECK:STDOUT: %LessEq.type: type = fn_type @LessEq [concrete] +// CHECK:STDOUT: %LessEq: %LessEq.type = struct_value () [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %true: bool = bool_literal true [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %false: bool = bool_literal false [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.831 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc21_30.1: bool = value_of_initializer @__global_init.%LessEq.call.loc21 [concrete = constants.%true] +// CHECK:STDOUT: %.loc21_30.2: bool = converted @__global_init.%LessEq.call.loc21, %.loc21_30.1 [concrete = constants.%true] +// CHECK:STDOUT: %a: bool = value_binding a, %.loc21_30.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.831 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc22_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc22_30.1: bool = value_of_initializer @__global_init.%LessEq.call.loc22 [concrete = constants.%true] +// CHECK:STDOUT: %.loc22_30.2: bool = converted @__global_init.%LessEq.call.loc22, %.loc22_30.1 [concrete = constants.%true] +// CHECK:STDOUT: %b: bool = value_binding b, %.loc22_30.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %pattern_type.831 = value_binding_pattern c [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc23_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc23_30.1: bool = value_of_initializer @__global_init.%LessEq.call.loc23 [concrete = constants.%false] +// CHECK:STDOUT: %.loc23_30.2: bool = converted @__global_init.%LessEq.call.loc23, %.loc23_30.1 [concrete = constants.%false] +// CHECK:STDOUT: %c: bool = value_binding c, %.loc23_30.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %LessEq.ref.loc21: %LessEq.type = name_ref LessEq, file.%LessEq.decl [concrete = constants.%LessEq] +// CHECK:STDOUT: %.loc21_22: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc21_27: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %LessEq.call.loc21: init bool = call %LessEq.ref.loc21(%.loc21_22, %.loc21_27) [concrete = constants.%true] +// CHECK:STDOUT: %LessEq.ref.loc22: %LessEq.type = name_ref LessEq, file.%LessEq.decl [concrete = constants.%LessEq] +// CHECK:STDOUT: %.loc22_22: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc22_27: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %LessEq.call.loc22: init bool = call %LessEq.ref.loc22(%.loc22_22, %.loc22_27) [concrete = constants.%true] +// CHECK:STDOUT: %LessEq.ref.loc23: %LessEq.type = name_ref LessEq, file.%LessEq.decl [concrete = constants.%LessEq] +// CHECK:STDOUT: %.loc23_22: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %.loc23_27: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %LessEq.call.loc23: init bool = call %LessEq.ref.loc23(%.loc23_22, %.loc23_27) [concrete = constants.%false] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/neq.carbon b/toolchain/check/testdata/builtins/char_literal/neq.carbon new file mode 100644 index 000000000000..baf35a0c771c --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/neq.carbon @@ -0,0 +1,66 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/neq.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/neq.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); + +fn Neq(a: CharLiteral, b: CharLiteral) -> bool = "char_literal.neq"; + +//@dump-sem-ir-begin +let a: bool = Neq('a', 'b'); +let b: bool = Neq('a', 'a'); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- neq.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] +// CHECK:STDOUT: %Neq.type: type = fn_type @Neq [concrete] +// CHECK:STDOUT: %Neq: %Neq.type = struct_value () [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %true: bool = bool_literal true [concrete] +// CHECK:STDOUT: %false: bool = bool_literal false [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.831 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc21_27.1: bool = value_of_initializer @__global_init.%Neq.call.loc21 [concrete = constants.%true] +// CHECK:STDOUT: %.loc21_27.2: bool = converted @__global_init.%Neq.call.loc21, %.loc21_27.1 [concrete = constants.%true] +// CHECK:STDOUT: %a: bool = value_binding a, %.loc21_27.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.831 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc22_8: type = type_literal bool [concrete = bool] +// CHECK:STDOUT: %.loc22_27.1: bool = value_of_initializer @__global_init.%Neq.call.loc22 [concrete = constants.%false] +// CHECK:STDOUT: %.loc22_27.2: bool = converted @__global_init.%Neq.call.loc22, %.loc22_27.1 [concrete = constants.%false] +// CHECK:STDOUT: %b: bool = value_binding b, %.loc22_27.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Neq.ref.loc21: %Neq.type = name_ref Neq, file.%Neq.decl [concrete = constants.%Neq] +// CHECK:STDOUT: %.loc21_19: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc21_24: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %Neq.call.loc21: init bool = call %Neq.ref.loc21(%.loc21_19, %.loc21_24) [concrete = constants.%true] +// CHECK:STDOUT: %Neq.ref.loc22: %Neq.type = name_ref Neq, file.%Neq.decl [concrete = constants.%Neq] +// CHECK:STDOUT: %.loc22_19: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc22_24: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %Neq.call.loc22: init bool = call %Neq.ref.loc22(%.loc22_19, %.loc22_24) [concrete = constants.%false] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/sub_char.carbon b/toolchain/check/testdata/builtins/char_literal/sub_char.carbon new file mode 100644 index 000000000000..3c5c505e3da1 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/sub_char.carbon @@ -0,0 +1,128 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/sub_char.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/sub_char.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn SubCharCharToIntLiteral(a: CharLiteral, b: CharLiteral) -> IntLiteral = "char_literal.sub_char"; +fn SubCharCharToI32(a: CharLiteral, b: CharLiteral) -> i32 = "char_literal.sub_char"; + +//@dump-sem-ir-begin +let a: IntLiteral = SubCharCharToIntLiteral('b', 'a'); +let b: i32 = SubCharCharToI32('b', 'a'); +let c: IntLiteral = SubCharCharToIntLiteral('a', 'b'); +let d: i32 = SubCharCharToI32('a', 'b'); +let max: i32 = SubCharCharToI32('\u{10FFFF}', '\u{0}'); +let min: i32 = SubCharCharToI32('\u{0}', '\u{10FFFF}'); +//@dump-sem-ir-end + +// CHECK:STDOUT: --- sub_char.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.dc0: type = pattern_type Core.IntLiteral [concrete] +// CHECK:STDOUT: %SubCharCharToIntLiteral.type: type = fn_type @SubCharCharToIntLiteral [concrete] +// CHECK:STDOUT: %SubCharCharToIntLiteral: %SubCharCharToIntLiteral.type = struct_value () [concrete] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete] +// CHECK:STDOUT: %SubCharCharToI32.type: type = fn_type @SubCharCharToI32 [concrete] +// CHECK:STDOUT: %SubCharCharToI32: %SubCharCharToI32.type = struct_value () [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %int_1.0c6: %i32 = int_value 1 [concrete] +// CHECK:STDOUT: %int_-1.638: Core.IntLiteral = int_value -1 [concrete] +// CHECK:STDOUT: %int_-1.4ef: %i32 = int_value -1 [concrete] +// CHECK:STDOUT: %.914: Core.CharLiteral = char_value U+10FFFF [concrete] +// CHECK:STDOUT: %.dc9: Core.CharLiteral = char_value U+0000 [concrete] +// CHECK:STDOUT: %int_1114111: %i32 = int_value 1114111 [concrete] +// CHECK:STDOUT: %int_-1114111: %i32 = int_value -1114111 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.dc0 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %IntLiteral.ref.loc24: type = name_ref IntLiteral, %IntLiteral [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc24_53.1: Core.IntLiteral = value_of_initializer @__global_init.%SubCharCharToIntLiteral.call.loc24 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc24_53.2: Core.IntLiteral = converted @__global_init.%SubCharCharToIntLiteral.call.loc24, %.loc24_53.1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %a: Core.IntLiteral = value_binding a, %.loc24_53.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.6b6 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc25: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc25_39.1: %i32 = value_of_initializer @__global_init.%SubCharCharToI32.call.loc25 [concrete = constants.%int_1.0c6] +// CHECK:STDOUT: %.loc25_39.2: %i32 = converted @__global_init.%SubCharCharToI32.call.loc25, %.loc25_39.1 [concrete = constants.%int_1.0c6] +// CHECK:STDOUT: %b: %i32 = value_binding b, %.loc25_39.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %pattern_type.dc0 = value_binding_pattern c [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %IntLiteral.ref.loc26: type = name_ref IntLiteral, %IntLiteral [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc26_53.1: Core.IntLiteral = value_of_initializer @__global_init.%SubCharCharToIntLiteral.call.loc26 [concrete = constants.%int_-1.638] +// CHECK:STDOUT: %.loc26_53.2: Core.IntLiteral = converted @__global_init.%SubCharCharToIntLiteral.call.loc26, %.loc26_53.1 [concrete = constants.%int_-1.638] +// CHECK:STDOUT: %c: Core.IntLiteral = value_binding c, %.loc26_53.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %pattern_type.6b6 = value_binding_pattern d [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc27: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc27_39.1: %i32 = value_of_initializer @__global_init.%SubCharCharToI32.call.loc27 [concrete = constants.%int_-1.4ef] +// CHECK:STDOUT: %.loc27_39.2: %i32 = converted @__global_init.%SubCharCharToI32.call.loc27, %.loc27_39.1 [concrete = constants.%int_-1.4ef] +// CHECK:STDOUT: %d: %i32 = value_binding d, %.loc27_39.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %max.patt: %pattern_type.6b6 = value_binding_pattern max [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc28: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc28_54.1: %i32 = value_of_initializer @__global_init.%SubCharCharToI32.call.loc28 [concrete = constants.%int_1114111] +// CHECK:STDOUT: %.loc28_54.2: %i32 = converted @__global_init.%SubCharCharToI32.call.loc28, %.loc28_54.1 [concrete = constants.%int_1114111] +// CHECK:STDOUT: %max: %i32 = value_binding max, %.loc28_54.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %min.patt: %pattern_type.6b6 = value_binding_pattern min [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i32.loc29: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc29_54.1: %i32 = value_of_initializer @__global_init.%SubCharCharToI32.call.loc29 [concrete = constants.%int_-1114111] +// CHECK:STDOUT: %.loc29_54.2: %i32 = converted @__global_init.%SubCharCharToI32.call.loc29, %.loc29_54.1 [concrete = constants.%int_-1114111] +// CHECK:STDOUT: %min: %i32 = value_binding min, %.loc29_54.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %SubCharCharToIntLiteral.ref.loc24: %SubCharCharToIntLiteral.type = name_ref SubCharCharToIntLiteral, file.%SubCharCharToIntLiteral.decl [concrete = constants.%SubCharCharToIntLiteral] +// CHECK:STDOUT: %.loc24_45: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %.loc24_50: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %SubCharCharToIntLiteral.call.loc24: init Core.IntLiteral = call %SubCharCharToIntLiteral.ref.loc24(%.loc24_45, %.loc24_50) [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %SubCharCharToI32.ref.loc25: %SubCharCharToI32.type = name_ref SubCharCharToI32, file.%SubCharCharToI32.decl [concrete = constants.%SubCharCharToI32] +// CHECK:STDOUT: %.loc25_31: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %.loc25_36: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %SubCharCharToI32.call.loc25: init %i32 = call %SubCharCharToI32.ref.loc25(%.loc25_31, %.loc25_36) [concrete = constants.%int_1.0c6] +// CHECK:STDOUT: %SubCharCharToIntLiteral.ref.loc26: %SubCharCharToIntLiteral.type = name_ref SubCharCharToIntLiteral, file.%SubCharCharToIntLiteral.decl [concrete = constants.%SubCharCharToIntLiteral] +// CHECK:STDOUT: %.loc26_45: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc26_50: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %SubCharCharToIntLiteral.call.loc26: init Core.IntLiteral = call %SubCharCharToIntLiteral.ref.loc26(%.loc26_45, %.loc26_50) [concrete = constants.%int_-1.638] +// CHECK:STDOUT: %SubCharCharToI32.ref.loc27: %SubCharCharToI32.type = name_ref SubCharCharToI32, file.%SubCharCharToI32.decl [concrete = constants.%SubCharCharToI32] +// CHECK:STDOUT: %.loc27_31: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc27_36: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %SubCharCharToI32.call.loc27: init %i32 = call %SubCharCharToI32.ref.loc27(%.loc27_31, %.loc27_36) [concrete = constants.%int_-1.4ef] +// CHECK:STDOUT: %SubCharCharToI32.ref.loc28: %SubCharCharToI32.type = name_ref SubCharCharToI32, file.%SubCharCharToI32.decl [concrete = constants.%SubCharCharToI32] +// CHECK:STDOUT: %.loc28_33: Core.CharLiteral = char_value U+10FFFF [concrete = constants.%.914] +// CHECK:STDOUT: %.loc28_47: Core.CharLiteral = char_value U+0000 [concrete = constants.%.dc9] +// CHECK:STDOUT: %SubCharCharToI32.call.loc28: init %i32 = call %SubCharCharToI32.ref.loc28(%.loc28_33, %.loc28_47) [concrete = constants.%int_1114111] +// CHECK:STDOUT: %SubCharCharToI32.ref.loc29: %SubCharCharToI32.type = name_ref SubCharCharToI32, file.%SubCharCharToI32.decl [concrete = constants.%SubCharCharToI32] +// CHECK:STDOUT: %.loc29_33: Core.CharLiteral = char_value U+0000 [concrete = constants.%.dc9] +// CHECK:STDOUT: %.loc29_42: Core.CharLiteral = char_value U+10FFFF [concrete = constants.%.914] +// CHECK:STDOUT: %SubCharCharToI32.call.loc29: init %i32 = call %SubCharCharToI32.ref.loc29(%.loc29_33, %.loc29_42) [concrete = constants.%int_-1114111] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/char_literal/sub_int.carbon b/toolchain/check/testdata/builtins/char_literal/sub_int.carbon new file mode 100644 index 000000000000..f1f323cebb38 --- /dev/null +++ b/toolchain/check/testdata/builtins/char_literal/sub_int.carbon @@ -0,0 +1,123 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/char_literal/sub_int.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/char_literal/sub_int.carbon + +// --- success.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn SubCharInt(c: CharLiteral, n: IntLiteral) -> CharLiteral = "char_literal.sub_int"; +fn Negate(n: IntLiteral) -> IntLiteral = "int.snegate"; + +//@dump-sem-ir-begin +let a: CharLiteral = SubCharInt('b', 1); +// It's fine to perform a subtraction that is in-bounds for `CharLiteral` but out +// of the range of a `char` or a byte. +let b: CharLiteral = SubCharInt('\u{7F}', Negate(1)); +let c: CharLiteral = SubCharInt('\u{FF}', Negate(1)); +//@dump-sem-ir-end + +// --- fail_invalid_result.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn SubCharInt(c: CharLiteral, n: IntLiteral) -> CharLiteral = "char_literal.sub_int"; +fn Negate(n: IntLiteral) -> IntLiteral = "int.snegate"; + +// CHECK:STDERR: fail_invalid_result.carbon:[[@LINE+4]]:22: error: character arithmetic result -1 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let a: CharLiteral = SubCharInt('\u{0000}', 1); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let a: CharLiteral = SubCharInt('\u{0000}', 1); + +// CHECK:STDERR: fail_invalid_result.carbon:[[@LINE+4]]:22: error: character arithmetic result 1114112 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let b: CharLiteral = SubCharInt('\u{10FFFF}', Negate(1)); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let b: CharLiteral = SubCharInt('\u{10FFFF}', Negate(1)); + +// CHECK:STDOUT: --- success.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.8c6: type = pattern_type Core.CharLiteral [concrete] +// CHECK:STDOUT: %SubCharInt.type: type = fn_type @SubCharInt [concrete] +// CHECK:STDOUT: %SubCharInt: %SubCharInt.type = struct_value () [concrete] +// CHECK:STDOUT: %Negate.type: type = fn_type @Negate [concrete] +// CHECK:STDOUT: %Negate: %Negate.type = struct_value () [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %.e28: Core.CharLiteral = char_value U+007F [concrete] +// CHECK:STDOUT: %int_-1: Core.IntLiteral = int_value -1 [concrete] +// CHECK:STDOUT: %.ae7: Core.CharLiteral = char_value U+0080 [concrete] +// CHECK:STDOUT: %.ad8: Core.CharLiteral = char_value U+00FF [concrete] +// CHECK:STDOUT: %.a8b: Core.CharLiteral = char_value U+0100 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.8c6 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc13: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc13_39.1: Core.CharLiteral = value_of_initializer @__global_init.%SubCharInt.call.loc13 [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc13_39.2: Core.CharLiteral = converted @__global_init.%SubCharInt.call.loc13, %.loc13_39.1 [concrete = constants.%.54f] +// CHECK:STDOUT: %a: Core.CharLiteral = value_binding a, %.loc13_39.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.8c6 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc16: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc16_52.1: Core.CharLiteral = value_of_initializer @__global_init.%SubCharInt.call.loc16 [concrete = constants.%.ae7] +// CHECK:STDOUT: %.loc16_52.2: Core.CharLiteral = converted @__global_init.%SubCharInt.call.loc16, %.loc16_52.1 [concrete = constants.%.ae7] +// CHECK:STDOUT: %b: Core.CharLiteral = value_binding b, %.loc16_52.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %pattern_type.8c6 = value_binding_pattern c [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc17: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc17_52.1: Core.CharLiteral = value_of_initializer @__global_init.%SubCharInt.call.loc17 [concrete = constants.%.a8b] +// CHECK:STDOUT: %.loc17_52.2: Core.CharLiteral = converted @__global_init.%SubCharInt.call.loc17, %.loc17_52.1 [concrete = constants.%.a8b] +// CHECK:STDOUT: %c: Core.CharLiteral = value_binding c, %.loc17_52.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %SubCharInt.ref.loc13: %SubCharInt.type = name_ref SubCharInt, file.%SubCharInt.decl [concrete = constants.%SubCharInt] +// CHECK:STDOUT: %.loc13: Core.CharLiteral = char_value U+0062 [concrete = constants.%.711] +// CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %SubCharInt.call.loc13: init Core.CharLiteral = call %SubCharInt.ref.loc13(%.loc13, %int_1.loc13) [concrete = constants.%.54f] +// CHECK:STDOUT: %SubCharInt.ref.loc16: %SubCharInt.type = name_ref SubCharInt, file.%SubCharInt.decl [concrete = constants.%SubCharInt] +// CHECK:STDOUT: %.loc16_33: Core.CharLiteral = char_value U+007F [concrete = constants.%.e28] +// CHECK:STDOUT: %Negate.ref.loc16: %Negate.type = name_ref Negate, file.%Negate.decl [concrete = constants.%Negate] +// CHECK:STDOUT: %int_1.loc16: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %Negate.call.loc16: init Core.IntLiteral = call %Negate.ref.loc16(%int_1.loc16) [concrete = constants.%int_-1] +// CHECK:STDOUT: %.loc16_51.1: Core.IntLiteral = value_of_initializer %Negate.call.loc16 [concrete = constants.%int_-1] +// CHECK:STDOUT: %.loc16_51.2: Core.IntLiteral = converted %Negate.call.loc16, %.loc16_51.1 [concrete = constants.%int_-1] +// CHECK:STDOUT: %SubCharInt.call.loc16: init Core.CharLiteral = call %SubCharInt.ref.loc16(%.loc16_33, %.loc16_51.2) [concrete = constants.%.ae7] +// CHECK:STDOUT: %SubCharInt.ref.loc17: %SubCharInt.type = name_ref SubCharInt, file.%SubCharInt.decl [concrete = constants.%SubCharInt] +// CHECK:STDOUT: %.loc17_33: Core.CharLiteral = char_value U+00FF [concrete = constants.%.ad8] +// CHECK:STDOUT: %Negate.ref.loc17: %Negate.type = name_ref Negate, file.%Negate.decl [concrete = constants.%Negate] +// CHECK:STDOUT: %int_1.loc17: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %Negate.call.loc17: init Core.IntLiteral = call %Negate.ref.loc17(%int_1.loc17) [concrete = constants.%int_-1] +// CHECK:STDOUT: %.loc17_51.1: Core.IntLiteral = value_of_initializer %Negate.call.loc17 [concrete = constants.%int_-1] +// CHECK:STDOUT: %.loc17_51.2: Core.IntLiteral = converted %Negate.call.loc17, %.loc17_51.1 [concrete = constants.%int_-1] +// CHECK:STDOUT: %SubCharInt.call.loc17: init Core.CharLiteral = call %SubCharInt.ref.loc17(%.loc17_33, %.loc17_51.2) [concrete = constants.%.a8b] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/int/add_char_literal.carbon b/toolchain/check/testdata/builtins/int/add_char_literal.carbon new file mode 100644 index 000000000000..add4d9aad073 --- /dev/null +++ b/toolchain/check/testdata/builtins/int/add_char_literal.carbon @@ -0,0 +1,104 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/add_char_literal.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/add_char_literal.carbon + +// --- success.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn AddIntChar(n: IntLiteral, c: CharLiteral) -> CharLiteral = "int.add_char_literal"; + +//@dump-sem-ir-begin +let a: CharLiteral = AddIntChar(1, 'a'); +//@dump-sem-ir-end + +// --- fail_overflow.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn AddIntChar(n: IntLiteral, c: CharLiteral) -> CharLiteral = "int.add_char_literal"; + +// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:22: error: character arithmetic result 4503599627370593 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let a: CharLiteral = AddIntChar(0x10000000000000, 'a'); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let a: CharLiteral = AddIntChar(0x10000000000000, 'a'); + +// --- fail_invalid_result.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn AddIntChar(n: IntLiteral, c: CharLiteral) -> CharLiteral = "int.add_char_literal"; +fn Negate(n: IntLiteral) -> IntLiteral = "int.snegate"; + +// CHECK:STDERR: fail_invalid_result.carbon:[[@LINE+4]]:22: error: character arithmetic result 1114112 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let a: CharLiteral = AddIntChar(1, '\u{10FFFF}'); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let a: CharLiteral = AddIntChar(1, '\u{10FFFF}'); + +// CHECK:STDERR: fail_invalid_result.carbon:[[@LINE+4]]:22: error: character arithmetic result 55296 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let b: CharLiteral = AddIntChar(1, '\u{D7FF}'); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let b: CharLiteral = AddIntChar(1, '\u{D7FF}'); + +// CHECK:STDERR: fail_invalid_result.carbon:[[@LINE+4]]:22: error: character arithmetic result -1 is not a valid Unicode code point [InvalidCharLiteralArithmeticResult] +// CHECK:STDERR: let c: CharLiteral = AddIntChar(Negate(98), 'a'); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let c: CharLiteral = AddIntChar(Negate(98), 'a'); + +// CHECK:STDOUT: --- success.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.8c6: type = pattern_type Core.CharLiteral [concrete] +// CHECK:STDOUT: %AddIntChar.type: type = fn_type @AddIntChar [concrete] +// CHECK:STDOUT: %AddIntChar: %AddIntChar.type = struct_value () [concrete] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.8c6 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc12_39.1: Core.CharLiteral = value_of_initializer @__global_init.%AddIntChar.call [concrete = constants.%.711] +// CHECK:STDOUT: %.loc12_39.2: Core.CharLiteral = converted @__global_init.%AddIntChar.call, %.loc12_39.1 [concrete = constants.%.711] +// CHECK:STDOUT: %a: Core.CharLiteral = value_binding a, %.loc12_39.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %AddIntChar.ref: %AddIntChar.type = name_ref AddIntChar, file.%AddIntChar.decl [concrete = constants.%AddIntChar] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %.loc12: Core.CharLiteral = char_value U+0061 [concrete = constants.%.54f] +// CHECK:STDOUT: %AddIntChar.call: init Core.CharLiteral = call %AddIntChar.ref(%int_1, %.loc12) [concrete = constants.%.711] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/int/convert_char_literal.carbon b/toolchain/check/testdata/builtins/int/convert_char_literal.carbon new file mode 100644 index 000000000000..52b04448e2e1 --- /dev/null +++ b/toolchain/check/testdata/builtins/int/convert_char_literal.carbon @@ -0,0 +1,167 @@ +// 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/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/convert_char_literal.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/convert_char_literal.carbon + +// --- success.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn ConvertFromIntLiteral(n: IntLiteral) -> CharLiteral = "int.convert_char_literal"; +fn ConvertFromI32(n: i32) -> CharLiteral = "int.convert_char_literal"; +fn ConvertFromU32(n: u32) -> CharLiteral = "int.convert_char_literal"; + +//@dump-sem-ir-begin +let a: CharLiteral = ConvertFromIntLiteral(97); +let b: CharLiteral = ConvertFromI32(98); +let c: CharLiteral = ConvertFromU32(99); +//@dump-sem-ir-end + +// --- fail_invalid.carbon + +library "[[@TEST_NAME]]"; + +fn MakeCharLiteral() -> type = "char_literal.make_type"; +alias CharLiteral = MakeCharLiteral(); +fn MakeIntLiteral() -> type = "int_literal.make_type"; +alias IntLiteral = MakeIntLiteral(); + +fn ConvertFromIntLiteral(n: IntLiteral) -> CharLiteral = "int.convert_char_literal"; + +// CHECK:STDERR: fail_invalid.carbon:[[@LINE+4]]:22: error: integer value -1 is not a valid Unicode code point [InvalidCharLiteralValue] +// CHECK:STDERR: let a: CharLiteral = ConvertFromIntLiteral(-1); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let a: CharLiteral = ConvertFromIntLiteral(-1); + +// CHECK:STDERR: fail_invalid.carbon:[[@LINE+4]]:22: error: integer value 55296 is not a valid Unicode code point [InvalidCharLiteralValue] +// CHECK:STDERR: let b: CharLiteral = ConvertFromIntLiteral(0xD800); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let b: CharLiteral = ConvertFromIntLiteral(0xD800); + +// CHECK:STDERR: fail_invalid.carbon:[[@LINE+4]]:22: error: integer value 1114112 is not a valid Unicode code point [InvalidCharLiteralValue] +// CHECK:STDERR: let c: CharLiteral = ConvertFromIntLiteral(0x110000); +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: +let c: CharLiteral = ConvertFromIntLiteral(0x110000); + +// CHECK:STDOUT: --- success.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %pattern_type.8c6: type = pattern_type Core.CharLiteral [concrete] +// CHECK:STDOUT: %ConvertFromIntLiteral.type: type = fn_type @ConvertFromIntLiteral [concrete] +// CHECK:STDOUT: %ConvertFromIntLiteral: %ConvertFromIntLiteral.type = struct_value () [concrete] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] +// CHECK:STDOUT: %ConvertFromI32.type: type = fn_type @ConvertFromI32 [concrete] +// CHECK:STDOUT: %ConvertFromI32: %ConvertFromI32.type = struct_value () [concrete] +// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete] +// CHECK:STDOUT: %ConvertFromU32.type: type = fn_type @ConvertFromU32 [concrete] +// CHECK:STDOUT: %ConvertFromU32: %ConvertFromU32.type = struct_value () [concrete] +// CHECK:STDOUT: %int_97: Core.IntLiteral = int_value 97 [concrete] +// CHECK:STDOUT: %.54f: Core.CharLiteral = char_value U+0061 [concrete] +// CHECK:STDOUT: %int_98.fb6: Core.IntLiteral = int_value 98 [concrete] +// CHECK:STDOUT: %ImplicitAs.type.914: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e74: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.0e9(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.845: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e74 = struct_value () [symbolic] +// CHECK:STDOUT: %ImplicitAs.impl_witness.a23: = impl_witness imports.%ImplicitAs.impl_witness_table.b3c, @Core.IntLiteral.as.ImplicitAs.impl.0e9(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.2ba: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.1, @Core.IntLiteral.as.ImplicitAs.impl.0e9(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.e39: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.2ba = struct_value () [concrete] +// CHECK:STDOUT: %ImplicitAs.facet.9f1: %ImplicitAs.type.914 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.a23) [concrete] +// CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.740: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet.9f1) [concrete] +// CHECK:STDOUT: %.1c5: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.740, %ImplicitAs.facet.9f1 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.dc1: = bound_method %int_98.fb6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.e39 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.571: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.e39, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(%int_32) [concrete] +// CHECK:STDOUT: %bound_method.6e9: = bound_method %int_98.fb6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.571 [concrete] +// CHECK:STDOUT: %int_98.1e6: %i32 = int_value 98 [concrete] +// CHECK:STDOUT: %.711: Core.CharLiteral = char_value U+0062 [concrete] +// CHECK:STDOUT: %int_99.6d1: Core.IntLiteral = int_value 99 [concrete] +// CHECK:STDOUT: %ImplicitAs.type.efe: type = facet_type <@ImplicitAs, @ImplicitAs(%u32)> [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.199: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.2, @Core.IntLiteral.as.ImplicitAs.impl.b68(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.170: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.199 = struct_value () [symbolic] +// CHECK:STDOUT: %ImplicitAs.impl_witness.0a1: = impl_witness imports.%ImplicitAs.impl_witness_table.42f, @Core.IntLiteral.as.ImplicitAs.impl.b68(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.957: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert.2, @Core.IntLiteral.as.ImplicitAs.impl.b68(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.9db: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.957 = struct_value () [concrete] +// CHECK:STDOUT: %ImplicitAs.facet.134: %ImplicitAs.type.efe = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.0a1) [concrete] +// CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b71: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%u32, %ImplicitAs.facet.134) [concrete] +// CHECK:STDOUT: %.22b: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.b71, %ImplicitAs.facet.134 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.62f: = bound_method %int_99.6d1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.9db [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.4ac: = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.9db, @Core.IntLiteral.as.ImplicitAs.impl.Convert.2(%int_32) [concrete] +// CHECK:STDOUT: %bound_method.bfd: = bound_method %int_99.6d1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.4ac [concrete] +// CHECK:STDOUT: %int_99.d4e: %u32 = int_value 99 [concrete] +// CHECK:STDOUT: %.b9b: Core.CharLiteral = char_value U+0063 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core.import_ref.edf: @Core.IntLiteral.as.ImplicitAs.impl.0e9.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e74) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.0e9.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.845)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.b3c = impl_witness_table (%Core.import_ref.edf), @Core.IntLiteral.as.ImplicitAs.impl.0e9 [concrete] +// CHECK:STDOUT: %Core.import_ref.aa5: @Core.IntLiteral.as.ImplicitAs.impl.b68.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.199) = import_ref Core//prelude/parts/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.b68.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.170)] +// CHECK:STDOUT: %ImplicitAs.impl_witness_table.42f = impl_witness_table (%Core.import_ref.aa5), @Core.IntLiteral.as.ImplicitAs.impl.b68 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %pattern_type.8c6 = value_binding_pattern a [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc14: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc14_46.1: Core.CharLiteral = value_of_initializer @__global_init.%ConvertFromIntLiteral.call [concrete = constants.%.54f] +// CHECK:STDOUT: %.loc14_46.2: Core.CharLiteral = converted @__global_init.%ConvertFromIntLiteral.call, %.loc14_46.1 [concrete = constants.%.54f] +// CHECK:STDOUT: %a: Core.CharLiteral = value_binding a, %.loc14_46.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %pattern_type.8c6 = value_binding_pattern b [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc15: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc15_39.1: Core.CharLiteral = value_of_initializer @__global_init.%ConvertFromI32.call [concrete = constants.%.711] +// CHECK:STDOUT: %.loc15_39.2: Core.CharLiteral = converted @__global_init.%ConvertFromI32.call, %.loc15_39.1 [concrete = constants.%.711] +// CHECK:STDOUT: %b: Core.CharLiteral = value_binding b, %.loc15_39.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %pattern_type.8c6 = value_binding_pattern c [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %CharLiteral.ref.loc16: type = name_ref CharLiteral, %CharLiteral [concrete = Core.CharLiteral] +// CHECK:STDOUT: %.loc16_39.1: Core.CharLiteral = value_of_initializer @__global_init.%ConvertFromU32.call [concrete = constants.%.b9b] +// CHECK:STDOUT: %.loc16_39.2: Core.CharLiteral = converted @__global_init.%ConvertFromU32.call, %.loc16_39.1 [concrete = constants.%.b9b] +// CHECK:STDOUT: %c: Core.CharLiteral = value_binding c, %.loc16_39.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @__global_init() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %ConvertFromIntLiteral.ref: %ConvertFromIntLiteral.type = name_ref ConvertFromIntLiteral, file.%ConvertFromIntLiteral.decl [concrete = constants.%ConvertFromIntLiteral] +// CHECK:STDOUT: %int_97: Core.IntLiteral = int_value 97 [concrete = constants.%int_97] +// CHECK:STDOUT: %ConvertFromIntLiteral.call: init Core.CharLiteral = call %ConvertFromIntLiteral.ref(%int_97) [concrete = constants.%.54f] +// CHECK:STDOUT: %ConvertFromI32.ref: %ConvertFromI32.type = name_ref ConvertFromI32, file.%ConvertFromI32.decl [concrete = constants.%ConvertFromI32] +// CHECK:STDOUT: %int_98: Core.IntLiteral = int_value 98 [concrete = constants.%int_98.fb6] +// CHECK:STDOUT: %impl.elem0.loc15: %.1c5 = impl_witness_access constants.%ImplicitAs.impl_witness.a23, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.e39] +// CHECK:STDOUT: %bound_method.loc15_37.1: = bound_method %int_98, %impl.elem0.loc15 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.dc1] +// CHECK:STDOUT: %specific_fn.loc15: = specific_function %impl.elem0.loc15, @Core.IntLiteral.as.ImplicitAs.impl.Convert.1(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.571] +// CHECK:STDOUT: %bound_method.loc15_37.2: = bound_method %int_98, %specific_fn.loc15 [concrete = constants.%bound_method.6e9] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc15: init %i32 = call %bound_method.loc15_37.2(%int_98) [concrete = constants.%int_98.1e6] +// CHECK:STDOUT: %.loc15_37.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc15 [concrete = constants.%int_98.1e6] +// CHECK:STDOUT: %.loc15_37.2: %i32 = converted %int_98, %.loc15_37.1 [concrete = constants.%int_98.1e6] +// CHECK:STDOUT: %ConvertFromI32.call: init Core.CharLiteral = call %ConvertFromI32.ref(%.loc15_37.2) [concrete = constants.%.711] +// CHECK:STDOUT: %ConvertFromU32.ref: %ConvertFromU32.type = name_ref ConvertFromU32, file.%ConvertFromU32.decl [concrete = constants.%ConvertFromU32] +// CHECK:STDOUT: %int_99: Core.IntLiteral = int_value 99 [concrete = constants.%int_99.6d1] +// CHECK:STDOUT: %impl.elem0.loc16: %.22b = impl_witness_access constants.%ImplicitAs.impl_witness.0a1, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.9db] +// CHECK:STDOUT: %bound_method.loc16_37.1: = bound_method %int_99, %impl.elem0.loc16 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.62f] +// CHECK:STDOUT: %specific_fn.loc16: = specific_function %impl.elem0.loc16, @Core.IntLiteral.as.ImplicitAs.impl.Convert.2(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.4ac] +// CHECK:STDOUT: %bound_method.loc16_37.2: = bound_method %int_99, %specific_fn.loc16 [concrete = constants.%bound_method.bfd] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16: init %u32 = call %bound_method.loc16_37.2(%int_99) [concrete = constants.%int_99.d4e] +// CHECK:STDOUT: %.loc16_37.1: %u32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16 [concrete = constants.%int_99.d4e] +// CHECK:STDOUT: %.loc16_37.2: %u32 = converted %int_99, %.loc16_37.1 [concrete = constants.%int_99.d4e] +// CHECK:STDOUT: %ConvertFromU32.call: init Core.CharLiteral = call %ConvertFromU32.ref(%.loc16_37.2) [concrete = constants.%.b9b] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon index 618d2adcafdd..096b14b18535 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon @@ -1103,10 +1103,10 @@ fn F() { // CHECK:STDOUT: %i16.builtin: type = int_type signed, %int_16 [concrete] // CHECK:STDOUT: %As.type.6f1: type = facet_type <@As, @As(%i16)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.6ee: %Core.IntLiteral.as.As.impl.Convert.type.c5d = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl(%int_16) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_16) [concrete] +// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.70c: %Core.IntLiteral.as.As.impl.Convert.type.4b7 = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.6f1 = facet_value Core.IntLiteral, (%As.impl_witness.820) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.d73: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i16, %As.facet) [concrete] @@ -1143,8 +1143,8 @@ fn F() { // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete = constants.%foo.cpp_overload_set.value] -// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] -// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] +// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl.f25 [concrete] // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] { // CHECK:STDOUT: // CHECK:STDOUT: } { @@ -1409,10 +1409,10 @@ fn F() { // CHECK:STDOUT: %i16.builtin: type = int_type signed, %int_16 [concrete] // CHECK:STDOUT: %As.type.6f1: type = facet_type <@As, @As(%i16)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.6ee: %Core.IntLiteral.as.As.impl.Convert.type.c5d = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl(%int_16) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_16) [concrete] +// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.70c: %Core.IntLiteral.as.As.impl.Convert.type.4b7 = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.6f1 = facet_value Core.IntLiteral, (%As.impl_witness.820) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.d73: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i16, %As.facet) [concrete] @@ -1449,8 +1449,8 @@ fn F() { // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete = constants.%foo.cpp_overload_set.value] -// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] -// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] +// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl.f25 [concrete] // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] { // CHECK:STDOUT: // CHECK:STDOUT: } { @@ -1506,10 +1506,10 @@ fn F() { // CHECK:STDOUT: %i16.builtin: type = int_type signed, %int_16 [concrete] // CHECK:STDOUT: %As.type.6f1: type = facet_type <@As, @As(%i16)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.6ee: %Core.IntLiteral.as.As.impl.Convert.type.c5d = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl(%int_16) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_16) [concrete] +// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.70c: %Core.IntLiteral.as.As.impl.Convert.type.4b7 = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.6f1 = facet_value Core.IntLiteral, (%As.impl_witness.820) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.d73: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i16, %As.facet) [concrete] @@ -1546,8 +1546,8 @@ fn F() { // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete = constants.%foo.cpp_overload_set.value] -// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] -// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] +// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl.f25 [concrete] // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] { // CHECK:STDOUT: // CHECK:STDOUT: } { @@ -1603,10 +1603,10 @@ fn F() { // CHECK:STDOUT: %i16.builtin: type = int_type signed, %int_16 [concrete] // CHECK:STDOUT: %As.type.6f1: type = facet_type <@As, @As(%i16)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.6ee: %Core.IntLiteral.as.As.impl.Convert.type.c5d = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl(%int_16) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_16) [concrete] +// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.70c: %Core.IntLiteral.as.As.impl.Convert.type.4b7 = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.6f1 = facet_value Core.IntLiteral, (%As.impl_witness.820) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.d73: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i16, %As.facet) [concrete] @@ -1643,8 +1643,8 @@ fn F() { // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete = constants.%foo.cpp_overload_set.value] -// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] -// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] +// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl.f25 [concrete] // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] { // CHECK:STDOUT: // CHECK:STDOUT: } { @@ -1700,10 +1700,10 @@ fn F() { // CHECK:STDOUT: %i16.builtin: type = int_type signed, %int_16 [concrete] // CHECK:STDOUT: %As.type.6f1: type = facet_type <@As, @As(%i16)> [concrete] // CHECK:STDOUT: %To.fe9: Core.IntLiteral = symbolic_binding To, 0 [symbolic] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.6ee: %Core.IntLiteral.as.As.impl.Convert.type.c5d = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl(%int_16) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_16) [concrete] +// CHECK:STDOUT: %As.impl_witness.820: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.4b7: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%int_16) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.70c: %Core.IntLiteral.as.As.impl.Convert.type.4b7 = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.6f1 = facet_value Core.IntLiteral, (%As.impl_witness.820) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.d73: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i16, %As.facet) [concrete] @@ -1740,8 +1740,8 @@ fn F() { // CHECK:STDOUT: import Cpp//... // CHECK:STDOUT: } // CHECK:STDOUT: %foo.cpp_overload_set.value: %foo.cpp_overload_set.type = cpp_overload_set_value @foo.cpp_overload_set [concrete = constants.%foo.cpp_overload_set.value] -// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] -// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] +// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl.f25 [concrete] // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] { // CHECK:STDOUT: // CHECK:STDOUT: } { diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon index 9d520a02f31c..3bb2f50358c9 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.llp64.carbon @@ -714,10 +714,10 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %f32.c73: type = class_type @Float, @Float(%int_32) [concrete] // CHECK:STDOUT: %As.type.998: type = facet_type <@As, @As(%i64)> [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.6ee: %Core.IntLiteral.as.As.impl.Convert.type.c5d = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.2e1: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.1a1: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %As.impl_witness.2e1: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl.f25(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.1a1: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.3d9: %Core.IntLiteral.as.As.impl.Convert.type.1a1 = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.998 = facet_value Core.IntLiteral, (%As.impl_witness.2e1) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.2b4: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i64, %As.facet) [concrete] @@ -768,8 +768,8 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %ImplicitAs.impl_witness_table.b3c = impl_witness_table (%Core.import_ref.edf), @Core.IntLiteral.as.ImplicitAs.impl.0e9 [concrete] // CHECK:STDOUT: %Core.import_ref.32e: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.48d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.0f9)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.b8b = impl_witness_table (%Core.import_ref.32e), @Int.as.ImplicitAs.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] -// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] +// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl.f25 [concrete] // CHECK:STDOUT: %Core.import_ref.c4c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.063) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.d4f)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.393 = impl_witness_table (%Core.import_ref.c4c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } @@ -887,10 +887,10 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %f32.c73: type = class_type @Float, @Float(%int_32) [concrete] // CHECK:STDOUT: %As.type.72f: type = facet_type <@As, @As(%u64)> [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.fb3: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.fb3: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.e51(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.f86: %Core.IntLiteral.as.As.impl.Convert.type.fb3 = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.8fb: = impl_witness imports.%As.impl_witness_table.8fa, @Core.IntLiteral.as.As.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.49f: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %As.impl_witness.8fb: = impl_witness imports.%As.impl_witness_table.8fa, @Core.IntLiteral.as.As.impl.e51(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.49f: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.e51(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.990: %Core.IntLiteral.as.As.impl.Convert.type.49f = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.72f = facet_value Core.IntLiteral, (%As.impl_witness.8fb) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.8dd: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%u64, %As.facet) [concrete] @@ -941,8 +941,8 @@ fn CopyUnsignedLong() { // CHECK:STDOUT: %ImplicitAs.impl_witness_table.42f = impl_witness_table (%Core.import_ref.aa5), @Core.IntLiteral.as.ImplicitAs.impl.b68 [concrete] // CHECK:STDOUT: %Core.import_ref.baa: @UInt.as.ImplicitAs.impl.3d3.%UInt.as.ImplicitAs.impl.Convert.type (%UInt.as.ImplicitAs.impl.Convert.type.3ec) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @UInt.as.ImplicitAs.impl.3d3.%UInt.as.ImplicitAs.impl.Convert (constants.%UInt.as.ImplicitAs.impl.Convert.06e)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a83 = impl_witness_table (%Core.import_ref.baa), @UInt.as.ImplicitAs.impl.3d3 [concrete] -// CHECK:STDOUT: %Core.import_ref.59a: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.fb3) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.f86)] -// CHECK:STDOUT: %As.impl_witness_table.8fa = impl_witness_table (%Core.import_ref.59a), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.59a: @Core.IntLiteral.as.As.impl.e51.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.fb3) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.e51.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.f86)] +// CHECK:STDOUT: %As.impl_witness_table.8fa = impl_witness_table (%Core.import_ref.59a), @Core.IntLiteral.as.As.impl.e51 [concrete] // CHECK:STDOUT: %Core.import_ref.c4c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.063) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.d4f)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.393 = impl_witness_table (%Core.import_ref.c4c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon index 147e3693b689..7e5066025ea7 100644 --- a/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon +++ b/toolchain/check/testdata/interop/cpp/primitive_types/long_and_long_long.lp64.carbon @@ -662,10 +662,10 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %f32.c73: type = class_type @Float, @Float(%int_32) [concrete] // CHECK:STDOUT: %As.type.998: type = facet_type <@As, @As(%i64)> [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.c5d: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.6ee: %Core.IntLiteral.as.As.impl.Convert.type.c5d = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.2e1: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.1a1: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %As.impl_witness.2e1: = impl_witness imports.%As.impl_witness_table.1c5, @Core.IntLiteral.as.As.impl.f25(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.1a1: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.f25(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.3d9: %Core.IntLiteral.as.As.impl.Convert.type.1a1 = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.998 = facet_value Core.IntLiteral, (%As.impl_witness.2e1) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.2b4: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i64, %As.facet) [concrete] @@ -716,8 +716,8 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %ImplicitAs.impl_witness_table.b3c = impl_witness_table (%Core.import_ref.edf), @Core.IntLiteral.as.ImplicitAs.impl.0e9 [concrete] // CHECK:STDOUT: %Core.import_ref.32e: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.48d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.0f9)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.b8b = impl_witness_table (%Core.import_ref.32e), @Int.as.ImplicitAs.impl [concrete] -// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] -// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.64b: @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.c5d) = import_ref Core//prelude/types/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.f25.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.6ee)] +// CHECK:STDOUT: %As.impl_witness_table.1c5 = impl_witness_table (%Core.import_ref.64b), @Core.IntLiteral.as.As.impl.f25 [concrete] // CHECK:STDOUT: %Core.import_ref.c4c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.063) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.d4f)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.393 = impl_witness_table (%Core.import_ref.c4c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } @@ -835,10 +835,10 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %f32.c73: type = class_type @Float, @Float(%int_32) [concrete] // CHECK:STDOUT: %As.type.72f: type = facet_type <@As, @As(%u64)> [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.fb3: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To.fe9) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.fb3: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.e51(%To.fe9) [symbolic] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.f86: %Core.IntLiteral.as.As.impl.Convert.type.fb3 = struct_value () [symbolic] -// CHECK:STDOUT: %As.impl_witness.8fb: = impl_witness imports.%As.impl_witness_table.8fa, @Core.IntLiteral.as.As.impl(%int_64) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.49f: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %As.impl_witness.8fb: = impl_witness imports.%As.impl_witness_table.8fa, @Core.IntLiteral.as.As.impl.e51(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.49f: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl.e51(%int_64) [concrete] // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.990: %Core.IntLiteral.as.As.impl.Convert.type.49f = struct_value () [concrete] // CHECK:STDOUT: %As.facet: %As.type.72f = facet_value Core.IntLiteral, (%As.impl_witness.8fb) [concrete] // CHECK:STDOUT: %As.WithSelf.Convert.type.8dd: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%u64, %As.facet) [concrete] @@ -889,8 +889,8 @@ fn CopyUnsignedLongLong() { // CHECK:STDOUT: %ImplicitAs.impl_witness_table.42f = impl_witness_table (%Core.import_ref.aa5), @Core.IntLiteral.as.ImplicitAs.impl.b68 [concrete] // CHECK:STDOUT: %Core.import_ref.baa: @UInt.as.ImplicitAs.impl.3d3.%UInt.as.ImplicitAs.impl.Convert.type (%UInt.as.ImplicitAs.impl.Convert.type.3ec) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @UInt.as.ImplicitAs.impl.3d3.%UInt.as.ImplicitAs.impl.Convert (constants.%UInt.as.ImplicitAs.impl.Convert.06e)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a83 = impl_witness_table (%Core.import_ref.baa), @UInt.as.ImplicitAs.impl.3d3 [concrete] -// CHECK:STDOUT: %Core.import_ref.59a: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.fb3) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.f86)] -// CHECK:STDOUT: %As.impl_witness_table.8fa = impl_witness_table (%Core.import_ref.59a), @Core.IntLiteral.as.As.impl [concrete] +// CHECK:STDOUT: %Core.import_ref.59a: @Core.IntLiteral.as.As.impl.e51.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.fb3) = import_ref Core//prelude/types/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.e51.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.f86)] +// CHECK:STDOUT: %As.impl_witness_table.8fa = impl_witness_table (%Core.import_ref.59a), @Core.IntLiteral.as.As.impl.e51 [concrete] // CHECK:STDOUT: %Core.import_ref.c4c: @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type (%Core.FloatLiteral.as.ImplicitAs.impl.Convert.type.063) = import_ref Core//prelude/types/float, loc{{\d+_\d+}}, loaded [symbolic = @Core.FloatLiteral.as.ImplicitAs.impl.%Core.FloatLiteral.as.ImplicitAs.impl.Convert (constants.%Core.FloatLiteral.as.ImplicitAs.impl.Convert.d4f)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.393 = impl_witness_table (%Core.import_ref.c4c), @Core.FloatLiteral.as.ImplicitAs.impl [concrete] // CHECK:STDOUT: } diff --git a/toolchain/diagnostics/kind.def b/toolchain/diagnostics/kind.def index fbe3269954ff..7e9ebc7f9384 100644 --- a/toolchain/diagnostics/kind.def +++ b/toolchain/diagnostics/kind.def @@ -466,6 +466,8 @@ CARBON_DIAGNOSTIC_KIND(IncompleteTypeInMemberAccessOfFacet) CARBON_DIAGNOSTIC_KIND(IncompleteTypeInValueConversion) CARBON_DIAGNOSTIC_KIND(InCopy) CARBON_DIAGNOSTIC_KIND(CharTooLargeForType) +CARBON_DIAGNOSTIC_KIND(InvalidCharLiteralValue) +CARBON_DIAGNOSTIC_KIND(InvalidCharLiteralArithmeticResult) CARBON_DIAGNOSTIC_KIND(IntTooLargeForCppType) CARBON_DIAGNOSTIC_KIND(IntTooLargeForType) CARBON_DIAGNOSTIC_KIND(FloatLiteralTooLargeForType) diff --git a/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon b/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon index 33ec72d5bcd7..4194401e3da8 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_debug.carbon @@ -119,16 +119,16 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !19) // CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16) // CHECK:STDOUT: !23 = !DILocation(line: 19, column: 5, scope: !16) -// CHECK:STDOUT: !24 = !DILocation(line: 306, column: 3, scope: !25, inlinedAt: !32) -// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !26, line: 306, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) +// CHECK:STDOUT: !24 = !DILocation(line: 331, column: 3, scope: !25, inlinedAt: !32) +// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !26, line: 331, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) // CHECK:STDOUT: !26 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !27 = !DISubroutineType(types: !28) // CHECK:STDOUT: !28 = !{null, !7, !7} // CHECK:STDOUT: !29 = !{!30, !31} // CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !25, type: !7) // CHECK:STDOUT: !31 = !DILocalVariable(arg: 2, scope: !25, type: !7) -// CHECK:STDOUT: !32 = distinct !DILocation(line: 372, column: 5, scope: !33, inlinedAt: !38) -// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 370, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !32 = distinct !DILocation(line: 398, column: 5, scope: !33, inlinedAt: !38) +// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 396, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !34 = !DISubroutineType(types: !35) // CHECK:STDOUT: !35 = !{null, !7} // CHECK:STDOUT: !36 = !{!37} diff --git a/toolchain/driver/testdata/compile/optimize/optimize_default.carbon b/toolchain/driver/testdata/compile/optimize/optimize_default.carbon index fb77b825bd23..187b9239e300 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_default.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_default.carbon @@ -119,16 +119,16 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !19) // CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16) // CHECK:STDOUT: !23 = !DILocation(line: 19, column: 5, scope: !16) -// CHECK:STDOUT: !24 = !DILocation(line: 306, column: 3, scope: !25, inlinedAt: !32) -// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !26, line: 306, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) +// CHECK:STDOUT: !24 = !DILocation(line: 331, column: 3, scope: !25, inlinedAt: !32) +// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !26, line: 331, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) // CHECK:STDOUT: !26 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !27 = !DISubroutineType(types: !28) // CHECK:STDOUT: !28 = !{null, !7, !7} // CHECK:STDOUT: !29 = !{!30, !31} // CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !25, type: !7) // CHECK:STDOUT: !31 = !DILocalVariable(arg: 2, scope: !25, type: !7) -// CHECK:STDOUT: !32 = distinct !DILocation(line: 372, column: 5, scope: !33, inlinedAt: !38) -// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 370, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !32 = distinct !DILocation(line: 398, column: 5, scope: !33, inlinedAt: !38) +// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 396, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !34 = !DISubroutineType(types: !35) // CHECK:STDOUT: !35 = !{null, !7} // CHECK:STDOUT: !36 = !{!37} diff --git a/toolchain/driver/testdata/compile/optimize/optimize_none.carbon b/toolchain/driver/testdata/compile/optimize/optimize_none.carbon index 98e4bd887b7e..d1c8943b2d50 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_none.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_none.carbon @@ -158,28 +158,28 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !31 = !{!32} // CHECK:STDOUT: !32 = !DILocalVariable(arg: 1, scope: !28, type: !7) // CHECK:STDOUT: !33 = !DILocation(line: 17, column: 3, scope: !28) -// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 370, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 396, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !35 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !36 = !{!37} // CHECK:STDOUT: !37 = !DILocalVariable(arg: 1, scope: !34, type: !7) -// CHECK:STDOUT: !38 = !DILocation(line: 372, column: 5, scope: !34) -// CHECK:STDOUT: !39 = !DILocation(line: 370, column: 3, scope: !34) -// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !35, line: 306, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) +// CHECK:STDOUT: !38 = !DILocation(line: 398, column: 5, scope: !34) +// CHECK:STDOUT: !39 = !DILocation(line: 396, column: 3, scope: !34) +// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !35, line: 331, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) // CHECK:STDOUT: !41 = !DISubroutineType(types: !42) // CHECK:STDOUT: !42 = !{null, !7, !7} // CHECK:STDOUT: !43 = !{!44, !45} // CHECK:STDOUT: !44 = !DILocalVariable(arg: 1, scope: !40, type: !7) // CHECK:STDOUT: !45 = !DILocalVariable(arg: 2, scope: !40, type: !7) // CHECK:STDOUT: !46 = !DILocation(line: 4294967295, scope: !40) -// CHECK:STDOUT: !47 = !DILocation(line: 306, column: 3, scope: !40) -// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !35, line: 63, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) +// CHECK:STDOUT: !47 = !DILocation(line: 331, column: 3, scope: !40) +// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !35, line: 64, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) // CHECK:STDOUT: !49 = !DISubroutineType(types: !50) // CHECK:STDOUT: !50 = !{!7, !7} // CHECK:STDOUT: !51 = !{!52} // CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !48, type: !7) -// CHECK:STDOUT: !53 = !DILocation(line: 65, column: 17, scope: !48) -// CHECK:STDOUT: !54 = !DILocation(line: 65, column: 5, scope: !48) -// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 58, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) +// CHECK:STDOUT: !53 = !DILocation(line: 66, column: 17, scope: !48) +// CHECK:STDOUT: !54 = !DILocation(line: 66, column: 5, scope: !48) +// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 59, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) // CHECK:STDOUT: !56 = !{!57} // CHECK:STDOUT: !57 = !DILocalVariable(arg: 1, scope: !55, type: !7) -// CHECK:STDOUT: !58 = !DILocation(line: 58, column: 28, scope: !55) +// CHECK:STDOUT: !58 = !DILocation(line: 59, column: 28, scope: !55) diff --git a/toolchain/driver/testdata/compile/optimize/optimize_size.carbon b/toolchain/driver/testdata/compile/optimize/optimize_size.carbon index d32db0da3d72..5b0b09cd8eaa 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_size.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_size.carbon @@ -158,28 +158,28 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !31 = !{!32} // CHECK:STDOUT: !32 = !DILocalVariable(arg: 1, scope: !28, type: !7) // CHECK:STDOUT: !33 = !DILocation(line: 17, column: 3, scope: !28) -// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 370, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) +// CHECK:STDOUT: !34 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !35, line: 396, type: !29, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36) // CHECK:STDOUT: !35 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !36 = !{!37} // CHECK:STDOUT: !37 = !DILocalVariable(arg: 1, scope: !34, type: !7) -// CHECK:STDOUT: !38 = !DILocation(line: 372, column: 5, scope: !34) -// CHECK:STDOUT: !39 = !DILocation(line: 370, column: 3, scope: !34) -// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !35, line: 306, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) +// CHECK:STDOUT: !38 = !DILocation(line: 398, column: 5, scope: !34) +// CHECK:STDOUT: !39 = !DILocation(line: 396, column: 3, scope: !34) +// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !35, line: 331, type: !41, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !43) // CHECK:STDOUT: !41 = !DISubroutineType(types: !42) // CHECK:STDOUT: !42 = !{null, !7, !7} // CHECK:STDOUT: !43 = !{!44, !45} // CHECK:STDOUT: !44 = !DILocalVariable(arg: 1, scope: !40, type: !7) // CHECK:STDOUT: !45 = !DILocalVariable(arg: 2, scope: !40, type: !7) // CHECK:STDOUT: !46 = !DILocation(line: 4294967295, scope: !40) -// CHECK:STDOUT: !47 = !DILocation(line: 306, column: 3, scope: !40) -// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !35, line: 63, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) +// CHECK:STDOUT: !47 = !DILocation(line: 331, column: 3, scope: !40) +// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !35, line: 64, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) // CHECK:STDOUT: !49 = !DISubroutineType(types: !50) // CHECK:STDOUT: !50 = !{!7, !7} // CHECK:STDOUT: !51 = !{!52} // CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !48, type: !7) -// CHECK:STDOUT: !53 = !DILocation(line: 65, column: 17, scope: !48) -// CHECK:STDOUT: !54 = !DILocation(line: 65, column: 5, scope: !48) -// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 58, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) +// CHECK:STDOUT: !53 = !DILocation(line: 66, column: 17, scope: !48) +// CHECK:STDOUT: !54 = !DILocation(line: 66, column: 5, scope: !48) +// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !35, line: 59, type: !49, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) // CHECK:STDOUT: !56 = !{!57} // CHECK:STDOUT: !57 = !DILocalVariable(arg: 1, scope: !55, type: !7) -// CHECK:STDOUT: !58 = !DILocation(line: 58, column: 28, scope: !55) +// CHECK:STDOUT: !58 = !DILocation(line: 59, column: 28, scope: !55) diff --git a/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon b/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon index 47f155e33959..ea4cc75a1552 100644 --- a/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon +++ b/toolchain/driver/testdata/compile/optimize/optimize_speed.carbon @@ -134,16 +134,16 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) { // CHECK:STDOUT: !20 = !{!21} // CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !19) // CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16) -// CHECK:STDOUT: !23 = !DILocation(line: 306, column: 3, scope: !24, inlinedAt: !31) -// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !25, line: 306, type: !26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !28) +// CHECK:STDOUT: !23 = !DILocation(line: 331, column: 3, scope: !24, inlinedAt: !31) +// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !25, line: 331, type: !26, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !28) // CHECK:STDOUT: !25 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !26 = !DISubroutineType(types: !27) // CHECK:STDOUT: !27 = !{null, !7, !7} // CHECK:STDOUT: !28 = !{!29, !30} // CHECK:STDOUT: !29 = !DILocalVariable(arg: 1, scope: !24, type: !7) // CHECK:STDOUT: !30 = !DILocalVariable(arg: 2, scope: !24, type: !7) -// CHECK:STDOUT: !31 = distinct !DILocation(line: 372, column: 5, scope: !32, inlinedAt: !37) -// CHECK:STDOUT: !32 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !25, line: 370, type: !33, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !35) +// CHECK:STDOUT: !31 = distinct !DILocation(line: 398, column: 5, scope: !32, inlinedAt: !37) +// CHECK:STDOUT: !32 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !25, line: 396, type: !33, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !35) // CHECK:STDOUT: !33 = !DISubroutineType(types: !34) // CHECK:STDOUT: !34 = !{null, !7} // CHECK:STDOUT: !35 = !{!36} diff --git a/toolchain/lower/handle_call.cpp b/toolchain/lower/handle_call.cpp index 21b37af8ae24..b37fa1d078b7 100644 --- a/toolchain/lower/handle_call.cpp +++ b/toolchain/lower/handle_call.cpp @@ -574,8 +574,20 @@ static auto HandleBuiltinCall(FunctionContext& context, SemIR::InstId inst_id, return; } - case SemIR::BuiltinFunctionKind::CharConvertChecked: + case SemIR::BuiltinFunctionKind::CharLiteralAdd: + case SemIR::BuiltinFunctionKind::CharLiteralConvertChar: + case SemIR::BuiltinFunctionKind::CharLiteralConvertInt: + case SemIR::BuiltinFunctionKind::CharLiteralEq: + case SemIR::BuiltinFunctionKind::CharLiteralGreater: + case SemIR::BuiltinFunctionKind::CharLiteralGreaterEq: + case SemIR::BuiltinFunctionKind::CharLiteralLess: + case SemIR::BuiltinFunctionKind::CharLiteralLessEq: + case SemIR::BuiltinFunctionKind::CharLiteralNeq: + case SemIR::BuiltinFunctionKind::CharLiteralSubChar: + case SemIR::BuiltinFunctionKind::CharLiteralSubInt: case SemIR::BuiltinFunctionKind::FloatConvertChecked: + case SemIR::BuiltinFunctionKind::IntAddCharLiteral: + case SemIR::BuiltinFunctionKind::IntConvertCharLiteral: case SemIR::BuiltinFunctionKind::IntConvertChecked: case SemIR::BuiltinFunctionKind::IntConvertFloatChecked: { // TODO: Check this statically. diff --git a/toolchain/lower/testdata/array/iterate.carbon b/toolchain/lower/testdata/array/iterate.carbon index 77e6f3819c8e..9af1a236082a 100644 --- a/toolchain/lower/testdata/array/iterate.carbon +++ b/toolchain/lower/testdata/array/iterate.carbon @@ -305,12 +305,12 @@ fn F() { // CHECK:STDOUT: !78 = !DILocalVariable(arg: 1, scope: !76, type: !22) // CHECK:STDOUT: !79 = !DILocation(line: 40, column: 12, scope: !76) // CHECK:STDOUT: !80 = !DILocation(line: 40, column: 5, scope: !76) -// CHECK:STDOUT: !81 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !82, line: 370, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !83) +// CHECK:STDOUT: !81 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !82, line: 396, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !83) // CHECK:STDOUT: !82 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !83 = !{!84} // CHECK:STDOUT: !84 = !DILocalVariable(arg: 1, scope: !81, type: !15) -// CHECK:STDOUT: !85 = !DILocation(line: 372, column: 5, scope: !81) -// CHECK:STDOUT: !86 = !DILocation(line: 370, column: 3, scope: !81) +// CHECK:STDOUT: !85 = !DILocation(line: 398, column: 5, scope: !81) +// CHECK:STDOUT: !86 = !DILocation(line: 396, column: 3, scope: !81) // CHECK:STDOUT: !87 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.18012f5191ea64dc", scope: null, file: !69, line: 33, type: !88, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !90) // CHECK:STDOUT: !88 = !DISubroutineType(types: !89) // CHECK:STDOUT: !89 = !{!22, !15} @@ -333,14 +333,14 @@ fn F() { // CHECK:STDOUT: !106 = !DILocalVariable(arg: 1, scope: !104, type: !22) // CHECK:STDOUT: !107 = !DILocation(line: 145, column: 12, scope: !104) // CHECK:STDOUT: !108 = !DILocation(line: 145, column: 5, scope: !104) -// CHECK:STDOUT: !109 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !82, line: 306, type: !110, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !112) +// CHECK:STDOUT: !109 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !82, line: 331, type: !110, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !112) // CHECK:STDOUT: !110 = !DISubroutineType(types: !111) // CHECK:STDOUT: !111 = !{null, !15, !15} // CHECK:STDOUT: !112 = !{!113, !114} // CHECK:STDOUT: !113 = !DILocalVariable(arg: 1, scope: !109, type: !15) // CHECK:STDOUT: !114 = !DILocalVariable(arg: 2, scope: !109, type: !15) // CHECK:STDOUT: !115 = !DILocation(line: 4294967295, scope: !109) -// CHECK:STDOUT: !116 = !DILocation(line: 306, column: 3, scope: !109) +// CHECK:STDOUT: !116 = !DILocation(line: 331, column: 3, scope: !109) // CHECK:STDOUT: !117 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.5d6f3f3a4b44a8f1:OptionalStorage.Core.58016a73bff04416", scope: null, file: !69, line: 131, type: !88, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !118) // CHECK:STDOUT: !118 = !{!119} // CHECK:STDOUT: !119 = !DILocalVariable(arg: 1, scope: !117, type: !15) @@ -350,14 +350,14 @@ fn F() { // CHECK:STDOUT: !123 = distinct !DISubprogram(name: "None", linkageName: "_CNone.5d6f3f3a4b44a8f1:OptionalStorage.Core.58016a73bff04416", scope: null, file: !69, line: 125, type: !95, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !124 = !DILocation(line: 128, column: 5, scope: !123) // CHECK:STDOUT: !125 = !DILocation(line: 129, column: 5, scope: !123) -// CHECK:STDOUT: !126 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !82, line: 63, type: !127, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !129) +// CHECK:STDOUT: !126 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !82, line: 64, type: !127, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !129) // CHECK:STDOUT: !127 = !DISubroutineType(types: !128) // CHECK:STDOUT: !128 = !{!15, !15} // CHECK:STDOUT: !129 = !{!130} // CHECK:STDOUT: !130 = !DILocalVariable(arg: 1, scope: !126, type: !15) -// CHECK:STDOUT: !131 = !DILocation(line: 65, column: 17, scope: !126) -// CHECK:STDOUT: !132 = !DILocation(line: 65, column: 5, scope: !126) -// CHECK:STDOUT: !133 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !82, line: 58, type: !127, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !134) +// CHECK:STDOUT: !131 = !DILocation(line: 66, column: 17, scope: !126) +// CHECK:STDOUT: !132 = !DILocation(line: 66, column: 5, scope: !126) +// CHECK:STDOUT: !133 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !82, line: 59, type: !127, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !134) // CHECK:STDOUT: !134 = !{!135} // CHECK:STDOUT: !135 = !DILocalVariable(arg: 1, scope: !133, type: !15) -// CHECK:STDOUT: !136 = !DILocation(line: 58, column: 28, scope: !133) +// CHECK:STDOUT: !136 = !DILocation(line: 59, column: 28, scope: !133) diff --git a/toolchain/lower/testdata/for/break_continue.carbon b/toolchain/lower/testdata/for/break_continue.carbon index 5a4c71f404b1..1967c4de1ec9 100644 --- a/toolchain/lower/testdata/for/break_continue.carbon +++ b/toolchain/lower/testdata/for/break_continue.carbon @@ -350,12 +350,12 @@ fn For() { // CHECK:STDOUT: !91 = !DILocalVariable(arg: 1, scope: !89, type: !29) // CHECK:STDOUT: !92 = !DILocation(line: 40, column: 12, scope: !89) // CHECK:STDOUT: !93 = !DILocation(line: 40, column: 5, scope: !89) -// CHECK:STDOUT: !94 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !95, line: 370, type: !20, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !96) +// CHECK:STDOUT: !94 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !95, line: 396, type: !20, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !96) // CHECK:STDOUT: !95 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !96 = !{!97} // CHECK:STDOUT: !97 = !DILocalVariable(arg: 1, scope: !94, type: !22) -// CHECK:STDOUT: !98 = !DILocation(line: 372, column: 5, scope: !94) -// CHECK:STDOUT: !99 = !DILocation(line: 370, column: 3, scope: !94) +// CHECK:STDOUT: !98 = !DILocation(line: 398, column: 5, scope: !94) +// CHECK:STDOUT: !99 = !DILocation(line: 396, column: 3, scope: !94) // CHECK:STDOUT: !100 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.95ac245efc335d3f", scope: null, file: !82, line: 33, type: !101, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !103) // CHECK:STDOUT: !101 = !DISubroutineType(types: !102) // CHECK:STDOUT: !102 = !{!29, !22} @@ -378,14 +378,14 @@ fn For() { // CHECK:STDOUT: !119 = !DILocalVariable(arg: 1, scope: !117, type: !29) // CHECK:STDOUT: !120 = !DILocation(line: 145, column: 12, scope: !117) // CHECK:STDOUT: !121 = !DILocation(line: 145, column: 5, scope: !117) -// CHECK:STDOUT: !122 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.d395a13f81aa0e29.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !95, line: 306, type: !123, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !125) +// CHECK:STDOUT: !122 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.d395a13f81aa0e29.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !95, line: 331, type: !123, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !125) // CHECK:STDOUT: !123 = !DISubroutineType(types: !124) // CHECK:STDOUT: !124 = !{null, !22, !22} // CHECK:STDOUT: !125 = !{!126, !127} // CHECK:STDOUT: !126 = !DILocalVariable(arg: 1, scope: !122, type: !22) // CHECK:STDOUT: !127 = !DILocalVariable(arg: 2, scope: !122, type: !22) // CHECK:STDOUT: !128 = !DILocation(line: 4294967295, scope: !122) -// CHECK:STDOUT: !129 = !DILocation(line: 306, column: 3, scope: !122) +// CHECK:STDOUT: !129 = !DILocation(line: 331, column: 3, scope: !122) // CHECK:STDOUT: !130 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.5d6f3f3a4b44a8f1:OptionalStorage.Core.39417379e302314a", scope: null, file: !82, line: 131, type: !101, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !131) // CHECK:STDOUT: !131 = !{!132} // CHECK:STDOUT: !132 = !DILocalVariable(arg: 1, scope: !130, type: !22) @@ -395,14 +395,14 @@ fn For() { // CHECK:STDOUT: !136 = distinct !DISubprogram(name: "None", linkageName: "_CNone.5d6f3f3a4b44a8f1:OptionalStorage.Core.39417379e302314a", scope: null, file: !82, line: 125, type: !108, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !137 = !DILocation(line: 128, column: 5, scope: !136) // CHECK:STDOUT: !138 = !DILocation(line: 129, column: 5, scope: !136) -// CHECK:STDOUT: !139 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !95, line: 63, type: !140, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !142) +// CHECK:STDOUT: !139 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !95, line: 64, type: !140, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !142) // CHECK:STDOUT: !140 = !DISubroutineType(types: !141) // CHECK:STDOUT: !141 = !{!22, !22} // CHECK:STDOUT: !142 = !{!143} // CHECK:STDOUT: !143 = !DILocalVariable(arg: 1, scope: !139, type: !22) -// CHECK:STDOUT: !144 = !DILocation(line: 65, column: 17, scope: !139) -// CHECK:STDOUT: !145 = !DILocation(line: 65, column: 5, scope: !139) -// CHECK:STDOUT: !146 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !95, line: 58, type: !140, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !147) +// CHECK:STDOUT: !144 = !DILocation(line: 66, column: 17, scope: !139) +// CHECK:STDOUT: !145 = !DILocation(line: 66, column: 5, scope: !139) +// CHECK:STDOUT: !146 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !95, line: 59, type: !140, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !147) // CHECK:STDOUT: !147 = !{!148} // CHECK:STDOUT: !148 = !DILocalVariable(arg: 1, scope: !146, type: !22) -// CHECK:STDOUT: !149 = !DILocation(line: 58, column: 28, scope: !146) +// CHECK:STDOUT: !149 = !DILocation(line: 59, column: 28, scope: !146) diff --git a/toolchain/lower/testdata/for/for.carbon b/toolchain/lower/testdata/for/for.carbon index da2c720c0d7b..5ee397487a28 100644 --- a/toolchain/lower/testdata/for/for.carbon +++ b/toolchain/lower/testdata/for/for.carbon @@ -334,12 +334,12 @@ fn For() { // CHECK:STDOUT: !87 = !DILocalVariable(arg: 1, scope: !85, type: !25) // CHECK:STDOUT: !88 = !DILocation(line: 40, column: 12, scope: !85) // CHECK:STDOUT: !89 = !DILocation(line: 40, column: 5, scope: !85) -// CHECK:STDOUT: !90 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !91, line: 370, type: !16, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) +// CHECK:STDOUT: !90 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !91, line: 396, type: !16, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) // CHECK:STDOUT: !91 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !92 = !{!93} // CHECK:STDOUT: !93 = !DILocalVariable(arg: 1, scope: !90, type: !18) -// CHECK:STDOUT: !94 = !DILocation(line: 372, column: 5, scope: !90) -// CHECK:STDOUT: !95 = !DILocation(line: 370, column: 3, scope: !90) +// CHECK:STDOUT: !94 = !DILocation(line: 398, column: 5, scope: !90) +// CHECK:STDOUT: !95 = !DILocation(line: 396, column: 3, scope: !90) // CHECK:STDOUT: !96 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.95ac245efc335d3f", scope: null, file: !78, line: 33, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !99) // CHECK:STDOUT: !97 = !DISubroutineType(types: !98) // CHECK:STDOUT: !98 = !{!25, !18} @@ -362,14 +362,14 @@ fn For() { // CHECK:STDOUT: !115 = !DILocalVariable(arg: 1, scope: !113, type: !25) // CHECK:STDOUT: !116 = !DILocation(line: 145, column: 12, scope: !113) // CHECK:STDOUT: !117 = !DILocation(line: 145, column: 5, scope: !113) -// CHECK:STDOUT: !118 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.d395a13f81aa0e29.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !91, line: 306, type: !119, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !121) +// CHECK:STDOUT: !118 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.d395a13f81aa0e29.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !91, line: 331, type: !119, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !121) // CHECK:STDOUT: !119 = !DISubroutineType(types: !120) // CHECK:STDOUT: !120 = !{null, !18, !18} // CHECK:STDOUT: !121 = !{!122, !123} // CHECK:STDOUT: !122 = !DILocalVariable(arg: 1, scope: !118, type: !18) // CHECK:STDOUT: !123 = !DILocalVariable(arg: 2, scope: !118, type: !18) // CHECK:STDOUT: !124 = !DILocation(line: 4294967295, scope: !118) -// CHECK:STDOUT: !125 = !DILocation(line: 306, column: 3, scope: !118) +// CHECK:STDOUT: !125 = !DILocation(line: 331, column: 3, scope: !118) // CHECK:STDOUT: !126 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.5d6f3f3a4b44a8f1:OptionalStorage.Core.39417379e302314a", scope: null, file: !78, line: 131, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !127) // CHECK:STDOUT: !127 = !{!128} // CHECK:STDOUT: !128 = !DILocalVariable(arg: 1, scope: !126, type: !18) @@ -379,14 +379,14 @@ fn For() { // CHECK:STDOUT: !132 = distinct !DISubprogram(name: "None", linkageName: "_CNone.5d6f3f3a4b44a8f1:OptionalStorage.Core.39417379e302314a", scope: null, file: !78, line: 125, type: !104, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !133 = !DILocation(line: 128, column: 5, scope: !132) // CHECK:STDOUT: !134 = !DILocation(line: 129, column: 5, scope: !132) -// CHECK:STDOUT: !135 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !91, line: 63, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !138) +// CHECK:STDOUT: !135 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !91, line: 64, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !138) // CHECK:STDOUT: !136 = !DISubroutineType(types: !137) // CHECK:STDOUT: !137 = !{!18, !18} // CHECK:STDOUT: !138 = !{!139} // CHECK:STDOUT: !139 = !DILocalVariable(arg: 1, scope: !135, type: !18) -// CHECK:STDOUT: !140 = !DILocation(line: 65, column: 17, scope: !135) -// CHECK:STDOUT: !141 = !DILocation(line: 65, column: 5, scope: !135) -// CHECK:STDOUT: !142 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !91, line: 58, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !143) +// CHECK:STDOUT: !140 = !DILocation(line: 66, column: 17, scope: !135) +// CHECK:STDOUT: !141 = !DILocation(line: 66, column: 5, scope: !135) +// CHECK:STDOUT: !142 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !91, line: 59, type: !136, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !143) // CHECK:STDOUT: !143 = !{!144} // CHECK:STDOUT: !144 = !DILocalVariable(arg: 1, scope: !142, type: !18) -// CHECK:STDOUT: !145 = !DILocation(line: 58, column: 28, scope: !142) +// CHECK:STDOUT: !145 = !DILocation(line: 59, column: 28, scope: !142) diff --git a/toolchain/lower/testdata/operators/increment.carbon b/toolchain/lower/testdata/operators/increment.carbon index d283ad2d5ab2..13196ed4480a 100644 --- a/toolchain/lower/testdata/operators/increment.carbon +++ b/toolchain/lower/testdata/operators/increment.carbon @@ -92,28 +92,28 @@ fn IncrSigned() { // CHECK:STDOUT: !14 = !{!15} // CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !10, type: !13) // CHECK:STDOUT: !16 = !DILocation(line: 5, column: 3, scope: !10) -// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !18, line: 370, type: !11, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !19) +// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !18, line: 396, type: !11, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !19) // CHECK:STDOUT: !18 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !19 = !{!20} // CHECK:STDOUT: !20 = !DILocalVariable(arg: 1, scope: !17, type: !13) -// CHECK:STDOUT: !21 = !DILocation(line: 372, column: 5, scope: !17) -// CHECK:STDOUT: !22 = !DILocation(line: 370, column: 3, scope: !17) -// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !18, line: 306, type: !24, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !26) +// CHECK:STDOUT: !21 = !DILocation(line: 398, column: 5, scope: !17) +// CHECK:STDOUT: !22 = !DILocation(line: 396, column: 3, scope: !17) +// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:AddAssignWith.6f9e8c1abf8bb3ea.Core:Int.9452f4c51951679b.Core:AddAssignWith.bcc2a64c00f3554f.Core.44914b6ff6901661", scope: null, file: !18, line: 331, type: !24, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !26) // CHECK:STDOUT: !24 = !DISubroutineType(types: !25) // CHECK:STDOUT: !25 = !{null, !13, !13} // CHECK:STDOUT: !26 = !{!27, !28} // CHECK:STDOUT: !27 = !DILocalVariable(arg: 1, scope: !23, type: !13) // CHECK:STDOUT: !28 = !DILocalVariable(arg: 2, scope: !23, type: !13) // CHECK:STDOUT: !29 = !DILocation(line: 4294967295, scope: !23) -// CHECK:STDOUT: !30 = !DILocation(line: 306, column: 3, scope: !23) -// CHECK:STDOUT: !31 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !18, line: 63, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !34) +// CHECK:STDOUT: !30 = !DILocation(line: 331, column: 3, scope: !23) +// CHECK:STDOUT: !31 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !18, line: 64, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !34) // CHECK:STDOUT: !32 = !DISubroutineType(types: !33) // CHECK:STDOUT: !33 = !{!13, !13} // CHECK:STDOUT: !34 = !{!35} // CHECK:STDOUT: !35 = !DILocalVariable(arg: 1, scope: !31, type: !13) -// CHECK:STDOUT: !36 = !DILocation(line: 65, column: 17, scope: !31) -// CHECK:STDOUT: !37 = !DILocation(line: 65, column: 5, scope: !31) -// CHECK:STDOUT: !38 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !18, line: 58, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !39) +// CHECK:STDOUT: !36 = !DILocation(line: 66, column: 17, scope: !31) +// CHECK:STDOUT: !37 = !DILocation(line: 66, column: 5, scope: !31) +// CHECK:STDOUT: !38 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !18, line: 59, type: !32, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !39) // CHECK:STDOUT: !39 = !{!40} // CHECK:STDOUT: !40 = !DILocalVariable(arg: 1, scope: !38, type: !13) -// CHECK:STDOUT: !41 = !DILocation(line: 58, column: 28, scope: !38) +// CHECK:STDOUT: !41 = !DILocation(line: 59, column: 28, scope: !38) diff --git a/toolchain/lower/testdata/primitives/char.carbon b/toolchain/lower/testdata/primitives/char.carbon index 98e39b1ae4e6..5bd8aec79c32 100644 --- a/toolchain/lower/testdata/primitives/char.carbon +++ b/toolchain/lower/testdata/primitives/char.carbon @@ -753,261 +753,261 @@ fn AddSubUInt32(c: char, i: u32) { // CHECK:STDOUT: !193 = !{!194} // CHECK:STDOUT: !194 = !DILocalVariable(arg: 1, scope: !190, type: !7) // CHECK:STDOUT: !195 = !DILocation(line: 19, column: 1, scope: !190) -// CHECK:STDOUT: !196 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.dbe0a954f4d47a23", scope: null, file: !197, line: 47, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !200) +// CHECK:STDOUT: !196 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.dbe0a954f4d47a23", scope: null, file: !197, line: 42, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !200) // CHECK:STDOUT: !197 = !DIFile(filename: "{{.*}}/prelude/types/char.carbon", directory: "") // CHECK:STDOUT: !198 = !DISubroutineType(types: !199) // CHECK:STDOUT: !199 = !{!165, !7} // CHECK:STDOUT: !200 = !{!201} // CHECK:STDOUT: !201 = !DILocalVariable(arg: 1, scope: !196, type: !7) -// CHECK:STDOUT: !202 = !DILocation(line: 48, column: 5, scope: !196) +// CHECK:STDOUT: !202 = !DILocation(line: 43, column: 5, scope: !196) // CHECK:STDOUT: !203 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.147e0bd019a31663", scope: null, file: !3, line: 19, type: !204, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !206) // CHECK:STDOUT: !204 = !DISubroutineType(types: !205) // CHECK:STDOUT: !205 = !{null, !165} // CHECK:STDOUT: !206 = !{!207} // CHECK:STDOUT: !207 = !DILocalVariable(arg: 1, scope: !203, type: !165) // CHECK:STDOUT: !208 = !DILocation(line: 19, column: 1, scope: !203) -// CHECK:STDOUT: !209 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.691b43fb97812586", scope: null, file: !197, line: 47, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !212) +// CHECK:STDOUT: !209 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.691b43fb97812586", scope: null, file: !197, line: 42, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !212) // CHECK:STDOUT: !210 = !DISubroutineType(types: !211) // CHECK:STDOUT: !211 = !{!179, !7} // CHECK:STDOUT: !212 = !{!213} // CHECK:STDOUT: !213 = !DILocalVariable(arg: 1, scope: !209, type: !7) -// CHECK:STDOUT: !214 = !DILocation(line: 48, column: 5, scope: !209) +// CHECK:STDOUT: !214 = !DILocation(line: 43, column: 5, scope: !209) // CHECK:STDOUT: !215 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.eadca4a969cf6f21", scope: null, file: !3, line: 19, type: !216, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !218) // CHECK:STDOUT: !216 = !DISubroutineType(types: !217) // CHECK:STDOUT: !217 = !{null, !179} // CHECK:STDOUT: !218 = !{!219} // CHECK:STDOUT: !219 = !DILocalVariable(arg: 1, scope: !215, type: !179) // CHECK:STDOUT: !220 = !DILocation(line: 19, column: 1, scope: !215) -// CHECK:STDOUT: !221 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.48e83ee0f3ef2ee8", scope: null, file: !197, line: 47, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !224) +// CHECK:STDOUT: !221 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.48e83ee0f3ef2ee8", scope: null, file: !197, line: 42, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !224) // CHECK:STDOUT: !222 = !DISubroutineType(types: !223) // CHECK:STDOUT: !223 = !{!126, !7} // CHECK:STDOUT: !224 = !{!225} // CHECK:STDOUT: !225 = !DILocalVariable(arg: 1, scope: !221, type: !7) -// CHECK:STDOUT: !226 = !DILocation(line: 48, column: 5, scope: !221) -// CHECK:STDOUT: !227 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.8da8ddbe24cfd39a", scope: null, file: !197, line: 47, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !230) +// CHECK:STDOUT: !226 = !DILocation(line: 43, column: 5, scope: !221) +// CHECK:STDOUT: !227 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.8da8ddbe24cfd39a", scope: null, file: !197, line: 42, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !230) // CHECK:STDOUT: !228 = !DISubroutineType(types: !229) // CHECK:STDOUT: !229 = !{!140, !7} // CHECK:STDOUT: !230 = !{!231} // CHECK:STDOUT: !231 = !DILocalVariable(arg: 1, scope: !227, type: !7) -// CHECK:STDOUT: !232 = !DILocation(line: 48, column: 5, scope: !227) +// CHECK:STDOUT: !232 = !DILocation(line: 43, column: 5, scope: !227) // CHECK:STDOUT: !233 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.a4c7fafe8a72cac4", scope: null, file: !3, line: 19, type: !234, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !236) // CHECK:STDOUT: !234 = !DISubroutineType(types: !235) // CHECK:STDOUT: !235 = !{null, !8} // CHECK:STDOUT: !236 = !{!237} // CHECK:STDOUT: !237 = !DILocalVariable(arg: 1, scope: !233, type: !8) // CHECK:STDOUT: !238 = !DILocation(line: 19, column: 1, scope: !233) -// CHECK:STDOUT: !239 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.7c3e388e0087434a.Core.ab8531ca840d1501", scope: null, file: !197, line: 134, type: !240, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !242) +// CHECK:STDOUT: !239 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.7c3e388e0087434a.Core.ab8531ca840d1501", scope: null, file: !197, line: 129, type: !240, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !242) // CHECK:STDOUT: !240 = !DISubroutineType(types: !241) // CHECK:STDOUT: !241 = !{!140, !7, !7} // CHECK:STDOUT: !242 = !{!243, !244} // CHECK:STDOUT: !243 = !DILocalVariable(arg: 1, scope: !239, type: !7) // CHECK:STDOUT: !244 = !DILocalVariable(arg: 2, scope: !239, type: !7) -// CHECK:STDOUT: !245 = !DILocation(line: 135, column: 13, scope: !239) -// CHECK:STDOUT: !246 = !DILocation(line: 135, column: 29, scope: !239) -// CHECK:STDOUT: !247 = !DILocation(line: 135, column: 12, scope: !239) -// CHECK:STDOUT: !248 = !DILocation(line: 135, column: 5, scope: !239) -// CHECK:STDOUT: !249 = distinct !DISubprogram(name: "Op", linkageName: "_COp.b27934686504f96c:SubWith.295cf9b677564c5c.Core.ab8531ca840d1501", scope: null, file: !197, line: 128, type: !240, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !250) +// CHECK:STDOUT: !245 = !DILocation(line: 130, column: 13, scope: !239) +// CHECK:STDOUT: !246 = !DILocation(line: 130, column: 29, scope: !239) +// CHECK:STDOUT: !247 = !DILocation(line: 130, column: 12, scope: !239) +// CHECK:STDOUT: !248 = !DILocation(line: 130, column: 5, scope: !239) +// CHECK:STDOUT: !249 = distinct !DISubprogram(name: "Op", linkageName: "_COp.b27934686504f96c:SubWith.295cf9b677564c5c.Core.ab8531ca840d1501", scope: null, file: !197, line: 123, type: !240, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !250) // CHECK:STDOUT: !250 = !{!251, !252} // CHECK:STDOUT: !251 = !DILocalVariable(arg: 1, scope: !249, type: !7) // CHECK:STDOUT: !252 = !DILocalVariable(arg: 2, scope: !249, type: !7) -// CHECK:STDOUT: !253 = !DILocation(line: 129, column: 13, scope: !249) -// CHECK:STDOUT: !254 = !DILocation(line: 129, column: 29, scope: !249) -// CHECK:STDOUT: !255 = !DILocation(line: 129, column: 12, scope: !249) -// CHECK:STDOUT: !256 = !DILocation(line: 129, column: 5, scope: !249) -// CHECK:STDOUT: !257 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.852ed75bdc952b41", scope: null, file: !197, line: 99, type: !258, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !260) +// CHECK:STDOUT: !253 = !DILocation(line: 124, column: 13, scope: !249) +// CHECK:STDOUT: !254 = !DILocation(line: 124, column: 29, scope: !249) +// CHECK:STDOUT: !255 = !DILocation(line: 124, column: 12, scope: !249) +// CHECK:STDOUT: !256 = !DILocation(line: 124, column: 5, scope: !249) +// CHECK:STDOUT: !257 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.852ed75bdc952b41", scope: null, file: !197, line: 94, type: !258, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !260) // CHECK:STDOUT: !258 = !DISubroutineType(types: !259) // CHECK:STDOUT: !259 = !{!7, !7, !112} // CHECK:STDOUT: !260 = !{!261, !262} // CHECK:STDOUT: !261 = !DILocalVariable(arg: 1, scope: !257, type: !7) // CHECK:STDOUT: !262 = !DILocalVariable(arg: 2, scope: !257, type: !112) -// CHECK:STDOUT: !263 = !DILocation(line: 101, column: 13, scope: !257) -// CHECK:STDOUT: !264 = !DILocation(line: 101, column: 5, scope: !257) -// CHECK:STDOUT: !265 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.852ed75bdc952b41", scope: null, file: !197, line: 107, type: !266, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !268) +// CHECK:STDOUT: !263 = !DILocation(line: 96, column: 13, scope: !257) +// CHECK:STDOUT: !264 = !DILocation(line: 96, column: 5, scope: !257) +// CHECK:STDOUT: !265 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.852ed75bdc952b41", scope: null, file: !197, line: 102, type: !266, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !268) // CHECK:STDOUT: !266 = !DISubroutineType(types: !267) // CHECK:STDOUT: !267 = !{!7, !112, !7} // CHECK:STDOUT: !268 = !{!269, !270} // CHECK:STDOUT: !269 = !DILocalVariable(arg: 1, scope: !265, type: !112) // CHECK:STDOUT: !270 = !DILocalVariable(arg: 2, scope: !265, type: !7) -// CHECK:STDOUT: !271 = !DILocation(line: 109, column: 13, scope: !265) -// CHECK:STDOUT: !272 = !DILocation(line: 109, column: 5, scope: !265) -// CHECK:STDOUT: !273 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.852ed75bdc952b41", scope: null, file: !197, line: 115, type: !258, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !274) +// CHECK:STDOUT: !271 = !DILocation(line: 104, column: 13, scope: !265) +// CHECK:STDOUT: !272 = !DILocation(line: 104, column: 5, scope: !265) +// CHECK:STDOUT: !273 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.852ed75bdc952b41", scope: null, file: !197, line: 110, type: !258, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !274) // CHECK:STDOUT: !274 = !{!275, !276} // CHECK:STDOUT: !275 = !DILocalVariable(arg: 1, scope: !273, type: !7) // CHECK:STDOUT: !276 = !DILocalVariable(arg: 2, scope: !273, type: !112) -// CHECK:STDOUT: !277 = !DILocation(line: 117, column: 13, scope: !273) -// CHECK:STDOUT: !278 = !DILocation(line: 117, column: 5, scope: !273) -// CHECK:STDOUT: !279 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.4de33f895b808f69", scope: null, file: !197, line: 99, type: !280, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !282) +// CHECK:STDOUT: !277 = !DILocation(line: 112, column: 13, scope: !273) +// CHECK:STDOUT: !278 = !DILocation(line: 112, column: 5, scope: !273) +// CHECK:STDOUT: !279 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.4de33f895b808f69", scope: null, file: !197, line: 94, type: !280, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !282) // CHECK:STDOUT: !280 = !DISubroutineType(types: !281) // CHECK:STDOUT: !281 = !{!7, !7, !126} // CHECK:STDOUT: !282 = !{!283, !284} // CHECK:STDOUT: !283 = !DILocalVariable(arg: 1, scope: !279, type: !7) // CHECK:STDOUT: !284 = !DILocalVariable(arg: 2, scope: !279, type: !126) -// CHECK:STDOUT: !285 = !DILocation(line: 101, column: 29, scope: !279) -// CHECK:STDOUT: !286 = !DILocation(line: 101, column: 13, scope: !279) -// CHECK:STDOUT: !287 = !DILocation(line: 101, column: 5, scope: !279) -// CHECK:STDOUT: !288 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.4de33f895b808f69", scope: null, file: !197, line: 107, type: !289, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !291) +// CHECK:STDOUT: !285 = !DILocation(line: 96, column: 29, scope: !279) +// CHECK:STDOUT: !286 = !DILocation(line: 96, column: 13, scope: !279) +// CHECK:STDOUT: !287 = !DILocation(line: 96, column: 5, scope: !279) +// CHECK:STDOUT: !288 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.4de33f895b808f69", scope: null, file: !197, line: 102, type: !289, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !291) // CHECK:STDOUT: !289 = !DISubroutineType(types: !290) // CHECK:STDOUT: !290 = !{!7, !126, !7} // CHECK:STDOUT: !291 = !{!292, !293} // CHECK:STDOUT: !292 = !DILocalVariable(arg: 1, scope: !288, type: !126) // CHECK:STDOUT: !293 = !DILocalVariable(arg: 2, scope: !288, type: !7) -// CHECK:STDOUT: !294 = !DILocation(line: 109, column: 14, scope: !288) -// CHECK:STDOUT: !295 = !DILocation(line: 109, column: 13, scope: !288) -// CHECK:STDOUT: !296 = !DILocation(line: 109, column: 5, scope: !288) -// CHECK:STDOUT: !297 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.4de33f895b808f69", scope: null, file: !197, line: 115, type: !280, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !298) +// CHECK:STDOUT: !294 = !DILocation(line: 104, column: 14, scope: !288) +// CHECK:STDOUT: !295 = !DILocation(line: 104, column: 13, scope: !288) +// CHECK:STDOUT: !296 = !DILocation(line: 104, column: 5, scope: !288) +// CHECK:STDOUT: !297 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.4de33f895b808f69", scope: null, file: !197, line: 110, type: !280, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !298) // CHECK:STDOUT: !298 = !{!299, !300} // CHECK:STDOUT: !299 = !DILocalVariable(arg: 1, scope: !297, type: !7) // CHECK:STDOUT: !300 = !DILocalVariable(arg: 2, scope: !297, type: !126) -// CHECK:STDOUT: !301 = !DILocation(line: 117, column: 29, scope: !297) -// CHECK:STDOUT: !302 = !DILocation(line: 117, column: 13, scope: !297) -// CHECK:STDOUT: !303 = !DILocation(line: 117, column: 5, scope: !297) -// CHECK:STDOUT: !304 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.ae42bf297a1ee9b6", scope: null, file: !197, line: 99, type: !305, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !307) +// CHECK:STDOUT: !301 = !DILocation(line: 112, column: 29, scope: !297) +// CHECK:STDOUT: !302 = !DILocation(line: 112, column: 13, scope: !297) +// CHECK:STDOUT: !303 = !DILocation(line: 112, column: 5, scope: !297) +// CHECK:STDOUT: !304 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.ae42bf297a1ee9b6", scope: null, file: !197, line: 94, type: !305, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !307) // CHECK:STDOUT: !305 = !DISubroutineType(types: !306) // CHECK:STDOUT: !306 = !{!7, !7, !140} // CHECK:STDOUT: !307 = !{!308, !309} // CHECK:STDOUT: !308 = !DILocalVariable(arg: 1, scope: !304, type: !7) // CHECK:STDOUT: !309 = !DILocalVariable(arg: 2, scope: !304, type: !140) -// CHECK:STDOUT: !310 = !DILocation(line: 101, column: 29, scope: !304) -// CHECK:STDOUT: !311 = !DILocation(line: 101, column: 13, scope: !304) -// CHECK:STDOUT: !312 = !DILocation(line: 101, column: 5, scope: !304) -// CHECK:STDOUT: !313 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.ae42bf297a1ee9b6", scope: null, file: !197, line: 107, type: !314, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !316) +// CHECK:STDOUT: !310 = !DILocation(line: 96, column: 29, scope: !304) +// CHECK:STDOUT: !311 = !DILocation(line: 96, column: 13, scope: !304) +// CHECK:STDOUT: !312 = !DILocation(line: 96, column: 5, scope: !304) +// CHECK:STDOUT: !313 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.ae42bf297a1ee9b6", scope: null, file: !197, line: 102, type: !314, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !316) // CHECK:STDOUT: !314 = !DISubroutineType(types: !315) // CHECK:STDOUT: !315 = !{!7, !140, !7} // CHECK:STDOUT: !316 = !{!317, !318} // CHECK:STDOUT: !317 = !DILocalVariable(arg: 1, scope: !313, type: !140) // CHECK:STDOUT: !318 = !DILocalVariable(arg: 2, scope: !313, type: !7) -// CHECK:STDOUT: !319 = !DILocation(line: 109, column: 14, scope: !313) -// CHECK:STDOUT: !320 = !DILocation(line: 109, column: 13, scope: !313) -// CHECK:STDOUT: !321 = !DILocation(line: 109, column: 5, scope: !313) -// CHECK:STDOUT: !322 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.ae42bf297a1ee9b6", scope: null, file: !197, line: 115, type: !305, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !323) +// CHECK:STDOUT: !319 = !DILocation(line: 104, column: 14, scope: !313) +// CHECK:STDOUT: !320 = !DILocation(line: 104, column: 13, scope: !313) +// CHECK:STDOUT: !321 = !DILocation(line: 104, column: 5, scope: !313) +// CHECK:STDOUT: !322 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.ae42bf297a1ee9b6", scope: null, file: !197, line: 110, type: !305, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !323) // CHECK:STDOUT: !323 = !{!324, !325} // CHECK:STDOUT: !324 = !DILocalVariable(arg: 1, scope: !322, type: !7) // CHECK:STDOUT: !325 = !DILocalVariable(arg: 2, scope: !322, type: !140) -// CHECK:STDOUT: !326 = !DILocation(line: 117, column: 29, scope: !322) -// CHECK:STDOUT: !327 = !DILocation(line: 117, column: 13, scope: !322) -// CHECK:STDOUT: !328 = !DILocation(line: 117, column: 5, scope: !322) -// CHECK:STDOUT: !329 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.3ff23939bf07ad5f", scope: null, file: !197, line: 99, type: !330, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !332) +// CHECK:STDOUT: !326 = !DILocation(line: 112, column: 29, scope: !322) +// CHECK:STDOUT: !327 = !DILocation(line: 112, column: 13, scope: !322) +// CHECK:STDOUT: !328 = !DILocation(line: 112, column: 5, scope: !322) +// CHECK:STDOUT: !329 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.3ff23939bf07ad5f", scope: null, file: !197, line: 94, type: !330, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !332) // CHECK:STDOUT: !330 = !DISubroutineType(types: !331) // CHECK:STDOUT: !331 = !{!7, !7, !7} // CHECK:STDOUT: !332 = !{!333, !334} // CHECK:STDOUT: !333 = !DILocalVariable(arg: 1, scope: !329, type: !7) // CHECK:STDOUT: !334 = !DILocalVariable(arg: 2, scope: !329, type: !7) -// CHECK:STDOUT: !335 = !DILocation(line: 101, column: 13, scope: !329) -// CHECK:STDOUT: !336 = !DILocation(line: 101, column: 5, scope: !329) -// CHECK:STDOUT: !337 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.3ff23939bf07ad5f", scope: null, file: !197, line: 107, type: !330, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !338) +// CHECK:STDOUT: !335 = !DILocation(line: 96, column: 13, scope: !329) +// CHECK:STDOUT: !336 = !DILocation(line: 96, column: 5, scope: !329) +// CHECK:STDOUT: !337 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.3ff23939bf07ad5f", scope: null, file: !197, line: 102, type: !330, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !338) // CHECK:STDOUT: !338 = !{!339, !340} // CHECK:STDOUT: !339 = !DILocalVariable(arg: 1, scope: !337, type: !7) // CHECK:STDOUT: !340 = !DILocalVariable(arg: 2, scope: !337, type: !7) -// CHECK:STDOUT: !341 = !DILocation(line: 109, column: 13, scope: !337) -// CHECK:STDOUT: !342 = !DILocation(line: 109, column: 5, scope: !337) -// CHECK:STDOUT: !343 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.3ff23939bf07ad5f", scope: null, file: !197, line: 115, type: !330, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !344) +// CHECK:STDOUT: !341 = !DILocation(line: 104, column: 13, scope: !337) +// CHECK:STDOUT: !342 = !DILocation(line: 104, column: 5, scope: !337) +// CHECK:STDOUT: !343 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.3ff23939bf07ad5f", scope: null, file: !197, line: 110, type: !330, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !344) // CHECK:STDOUT: !344 = !{!345, !346} // CHECK:STDOUT: !345 = !DILocalVariable(arg: 1, scope: !343, type: !7) // CHECK:STDOUT: !346 = !DILocalVariable(arg: 2, scope: !343, type: !7) -// CHECK:STDOUT: !347 = !DILocation(line: 117, column: 13, scope: !343) -// CHECK:STDOUT: !348 = !DILocation(line: 117, column: 5, scope: !343) -// CHECK:STDOUT: !349 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.a374c478e4368fa7", scope: null, file: !197, line: 99, type: !350, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !352) +// CHECK:STDOUT: !347 = !DILocation(line: 112, column: 13, scope: !343) +// CHECK:STDOUT: !348 = !DILocation(line: 112, column: 5, scope: !343) +// CHECK:STDOUT: !349 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.a374c478e4368fa7", scope: null, file: !197, line: 94, type: !350, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !352) // CHECK:STDOUT: !350 = !DISubroutineType(types: !351) // CHECK:STDOUT: !351 = !{!7, !7, !165} // CHECK:STDOUT: !352 = !{!353, !354} // CHECK:STDOUT: !353 = !DILocalVariable(arg: 1, scope: !349, type: !7) // CHECK:STDOUT: !354 = !DILocalVariable(arg: 2, scope: !349, type: !165) -// CHECK:STDOUT: !355 = !DILocation(line: 101, column: 29, scope: !349) -// CHECK:STDOUT: !356 = !DILocation(line: 101, column: 13, scope: !349) -// CHECK:STDOUT: !357 = !DILocation(line: 101, column: 5, scope: !349) -// CHECK:STDOUT: !358 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.a374c478e4368fa7", scope: null, file: !197, line: 107, type: !359, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !361) +// CHECK:STDOUT: !355 = !DILocation(line: 96, column: 29, scope: !349) +// CHECK:STDOUT: !356 = !DILocation(line: 96, column: 13, scope: !349) +// CHECK:STDOUT: !357 = !DILocation(line: 96, column: 5, scope: !349) +// CHECK:STDOUT: !358 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.a374c478e4368fa7", scope: null, file: !197, line: 102, type: !359, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !361) // CHECK:STDOUT: !359 = !DISubroutineType(types: !360) // CHECK:STDOUT: !360 = !{!7, !165, !7} // CHECK:STDOUT: !361 = !{!362, !363} // CHECK:STDOUT: !362 = !DILocalVariable(arg: 1, scope: !358, type: !165) // CHECK:STDOUT: !363 = !DILocalVariable(arg: 2, scope: !358, type: !7) -// CHECK:STDOUT: !364 = !DILocation(line: 109, column: 14, scope: !358) -// CHECK:STDOUT: !365 = !DILocation(line: 109, column: 13, scope: !358) -// CHECK:STDOUT: !366 = !DILocation(line: 109, column: 5, scope: !358) -// CHECK:STDOUT: !367 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.a374c478e4368fa7", scope: null, file: !197, line: 115, type: !350, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !368) +// CHECK:STDOUT: !364 = !DILocation(line: 104, column: 14, scope: !358) +// CHECK:STDOUT: !365 = !DILocation(line: 104, column: 13, scope: !358) +// CHECK:STDOUT: !366 = !DILocation(line: 104, column: 5, scope: !358) +// CHECK:STDOUT: !367 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.a374c478e4368fa7", scope: null, file: !197, line: 110, type: !350, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !368) // CHECK:STDOUT: !368 = !{!369, !370} // CHECK:STDOUT: !369 = !DILocalVariable(arg: 1, scope: !367, type: !7) // CHECK:STDOUT: !370 = !DILocalVariable(arg: 2, scope: !367, type: !165) -// CHECK:STDOUT: !371 = !DILocation(line: 117, column: 29, scope: !367) -// CHECK:STDOUT: !372 = !DILocation(line: 117, column: 13, scope: !367) -// CHECK:STDOUT: !373 = !DILocation(line: 117, column: 5, scope: !367) -// CHECK:STDOUT: !374 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.bca5dfe49de51c76", scope: null, file: !197, line: 99, type: !375, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !377) +// CHECK:STDOUT: !371 = !DILocation(line: 112, column: 29, scope: !367) +// CHECK:STDOUT: !372 = !DILocation(line: 112, column: 13, scope: !367) +// CHECK:STDOUT: !373 = !DILocation(line: 112, column: 5, scope: !367) +// CHECK:STDOUT: !374 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:AddWith.d9344a06b22b3b94.Core.bca5dfe49de51c76", scope: null, file: !197, line: 94, type: !375, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !377) // CHECK:STDOUT: !375 = !DISubroutineType(types: !376) // CHECK:STDOUT: !376 = !{!7, !7, !179} // CHECK:STDOUT: !377 = !{!378, !379} // CHECK:STDOUT: !378 = !DILocalVariable(arg: 1, scope: !374, type: !7) // CHECK:STDOUT: !379 = !DILocalVariable(arg: 2, scope: !374, type: !179) -// CHECK:STDOUT: !380 = !DILocation(line: 101, column: 29, scope: !374) -// CHECK:STDOUT: !381 = !DILocation(line: 101, column: 13, scope: !374) -// CHECK:STDOUT: !382 = !DILocation(line: 101, column: 5, scope: !374) -// CHECK:STDOUT: !383 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.bca5dfe49de51c76", scope: null, file: !197, line: 107, type: !384, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !386) +// CHECK:STDOUT: !380 = !DILocation(line: 96, column: 29, scope: !374) +// CHECK:STDOUT: !381 = !DILocation(line: 96, column: 13, scope: !374) +// CHECK:STDOUT: !382 = !DILocation(line: 96, column: 5, scope: !374) +// CHECK:STDOUT: !383 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fdd9948a9ef8c6e5:AddWith.295cf9b677564c5c.Core.bca5dfe49de51c76", scope: null, file: !197, line: 102, type: !384, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !386) // CHECK:STDOUT: !384 = !DISubroutineType(types: !385) // CHECK:STDOUT: !385 = !{!7, !179, !7} // CHECK:STDOUT: !386 = !{!387, !388} // CHECK:STDOUT: !387 = !DILocalVariable(arg: 1, scope: !383, type: !179) // CHECK:STDOUT: !388 = !DILocalVariable(arg: 2, scope: !383, type: !7) -// CHECK:STDOUT: !389 = !DILocation(line: 109, column: 14, scope: !383) -// CHECK:STDOUT: !390 = !DILocation(line: 109, column: 13, scope: !383) -// CHECK:STDOUT: !391 = !DILocation(line: 109, column: 5, scope: !383) -// CHECK:STDOUT: !392 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.bca5dfe49de51c76", scope: null, file: !197, line: 115, type: !375, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !393) +// CHECK:STDOUT: !389 = !DILocation(line: 104, column: 14, scope: !383) +// CHECK:STDOUT: !390 = !DILocation(line: 104, column: 13, scope: !383) +// CHECK:STDOUT: !391 = !DILocation(line: 104, column: 5, scope: !383) +// CHECK:STDOUT: !392 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.d9344a06b22b3b94.Core.bca5dfe49de51c76", scope: null, file: !197, line: 110, type: !375, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !393) // CHECK:STDOUT: !393 = !{!394, !395} // CHECK:STDOUT: !394 = !DILocalVariable(arg: 1, scope: !392, type: !7) // CHECK:STDOUT: !395 = !DILocalVariable(arg: 2, scope: !392, type: !179) -// CHECK:STDOUT: !396 = !DILocation(line: 117, column: 29, scope: !392) -// CHECK:STDOUT: !397 = !DILocation(line: 117, column: 13, scope: !392) -// CHECK:STDOUT: !398 = !DILocation(line: 117, column: 5, scope: !392) -// CHECK:STDOUT: !399 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b906c5940adce8f0", scope: null, file: !400, line: 87, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !401) +// CHECK:STDOUT: !396 = !DILocation(line: 112, column: 29, scope: !392) +// CHECK:STDOUT: !397 = !DILocation(line: 112, column: 13, scope: !392) +// CHECK:STDOUT: !398 = !DILocation(line: 112, column: 5, scope: !392) +// CHECK:STDOUT: !399 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b906c5940adce8f0", scope: null, file: !400, line: 88, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !401) // CHECK:STDOUT: !400 = !DIFile(filename: "{{.*}}/prelude/types/uint.carbon", directory: "") // CHECK:STDOUT: !401 = !{!402} // CHECK:STDOUT: !402 = !DILocalVariable(arg: 1, scope: !399, type: !7) -// CHECK:STDOUT: !403 = !DILocation(line: 88, column: 12, scope: !399) -// CHECK:STDOUT: !404 = !DILocation(line: 88, column: 5, scope: !399) -// CHECK:STDOUT: !405 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.dbd6eca082a732b7", scope: null, file: !400, line: 87, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !406) +// CHECK:STDOUT: !403 = !DILocation(line: 89, column: 12, scope: !399) +// CHECK:STDOUT: !404 = !DILocation(line: 89, column: 5, scope: !399) +// CHECK:STDOUT: !405 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.dbd6eca082a732b7", scope: null, file: !400, line: 88, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !406) // CHECK:STDOUT: !406 = !{!407} // CHECK:STDOUT: !407 = !DILocalVariable(arg: 1, scope: !405, type: !7) -// CHECK:STDOUT: !408 = !DILocation(line: 88, column: 12, scope: !405) -// CHECK:STDOUT: !409 = !DILocation(line: 88, column: 5, scope: !405) -// CHECK:STDOUT: !410 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.dc14f658d346b3e8", scope: null, file: !400, line: 87, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !411) +// CHECK:STDOUT: !408 = !DILocation(line: 89, column: 12, scope: !405) +// CHECK:STDOUT: !409 = !DILocation(line: 89, column: 5, scope: !405) +// CHECK:STDOUT: !410 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.dc14f658d346b3e8", scope: null, file: !400, line: 88, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !411) // CHECK:STDOUT: !411 = !{!412} // CHECK:STDOUT: !412 = !DILocalVariable(arg: 1, scope: !410, type: !7) -// CHECK:STDOUT: !413 = !DILocation(line: 88, column: 12, scope: !410) -// CHECK:STDOUT: !414 = !DILocation(line: 88, column: 5, scope: !410) -// CHECK:STDOUT: !415 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b26071071fee62b9", scope: null, file: !400, line: 87, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !416) +// CHECK:STDOUT: !413 = !DILocation(line: 89, column: 12, scope: !410) +// CHECK:STDOUT: !414 = !DILocation(line: 89, column: 5, scope: !410) +// CHECK:STDOUT: !415 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b26071071fee62b9", scope: null, file: !400, line: 88, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !416) // CHECK:STDOUT: !416 = !{!417} // CHECK:STDOUT: !417 = !DILocalVariable(arg: 1, scope: !415, type: !7) -// CHECK:STDOUT: !418 = !DILocation(line: 88, column: 12, scope: !415) -// CHECK:STDOUT: !419 = !DILocation(line: 88, column: 5, scope: !415) -// CHECK:STDOUT: !420 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee", scope: null, file: !197, line: 47, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !421) +// CHECK:STDOUT: !418 = !DILocation(line: 89, column: 12, scope: !415) +// CHECK:STDOUT: !419 = !DILocation(line: 89, column: 5, scope: !415) +// CHECK:STDOUT: !420 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee", scope: null, file: !197, line: 42, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !421) // CHECK:STDOUT: !421 = !{!422} // CHECK:STDOUT: !422 = !DILocalVariable(arg: 1, scope: !420, type: !7) -// CHECK:STDOUT: !423 = !DILocation(line: 48, column: 5, scope: !420) -// CHECK:STDOUT: !424 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.c3acaf94968d88d2", scope: null, file: !400, line: 71, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !425) +// CHECK:STDOUT: !423 = !DILocation(line: 43, column: 5, scope: !420) +// CHECK:STDOUT: !424 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.c3acaf94968d88d2", scope: null, file: !400, line: 72, type: !198, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !425) // CHECK:STDOUT: !425 = !{!426} // CHECK:STDOUT: !426 = !DILocalVariable(arg: 1, scope: !424, type: !7) -// CHECK:STDOUT: !427 = !DILocation(line: 73, column: 17, scope: !424) -// CHECK:STDOUT: !428 = !DILocation(line: 73, column: 12, scope: !424) -// CHECK:STDOUT: !429 = !DILocation(line: 73, column: 5, scope: !424) -// CHECK:STDOUT: !430 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.d93106ca8c7912cd", scope: null, file: !400, line: 71, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !431) +// CHECK:STDOUT: !427 = !DILocation(line: 74, column: 17, scope: !424) +// CHECK:STDOUT: !428 = !DILocation(line: 74, column: 12, scope: !424) +// CHECK:STDOUT: !429 = !DILocation(line: 74, column: 5, scope: !424) +// CHECK:STDOUT: !430 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.d93106ca8c7912cd", scope: null, file: !400, line: 72, type: !210, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !431) // CHECK:STDOUT: !431 = !{!432} // CHECK:STDOUT: !432 = !DILocalVariable(arg: 1, scope: !430, type: !7) -// CHECK:STDOUT: !433 = !DILocation(line: 73, column: 17, scope: !430) -// CHECK:STDOUT: !434 = !DILocation(line: 73, column: 12, scope: !430) -// CHECK:STDOUT: !435 = !DILocation(line: 73, column: 5, scope: !430) -// CHECK:STDOUT: !436 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.8d84eea89906cfec", scope: null, file: !400, line: 79, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !437) +// CHECK:STDOUT: !433 = !DILocation(line: 74, column: 17, scope: !430) +// CHECK:STDOUT: !434 = !DILocation(line: 74, column: 12, scope: !430) +// CHECK:STDOUT: !435 = !DILocation(line: 74, column: 5, scope: !430) +// CHECK:STDOUT: !436 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.8d84eea89906cfec", scope: null, file: !400, line: 80, type: !222, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !437) // CHECK:STDOUT: !437 = !{!438} // CHECK:STDOUT: !438 = !DILocalVariable(arg: 1, scope: !436, type: !7) -// CHECK:STDOUT: !439 = !DILocation(line: 81, column: 17, scope: !436) -// CHECK:STDOUT: !440 = !DILocation(line: 81, column: 12, scope: !436) -// CHECK:STDOUT: !441 = !DILocation(line: 81, column: 5, scope: !436) -// CHECK:STDOUT: !442 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.1d53f86bcab954ee", scope: null, file: !400, line: 79, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !443) +// CHECK:STDOUT: !439 = !DILocation(line: 82, column: 17, scope: !436) +// CHECK:STDOUT: !440 = !DILocation(line: 82, column: 12, scope: !436) +// CHECK:STDOUT: !441 = !DILocation(line: 82, column: 5, scope: !436) +// CHECK:STDOUT: !442 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.1d53f86bcab954ee", scope: null, file: !400, line: 80, type: !228, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !443) // CHECK:STDOUT: !443 = !{!444} // CHECK:STDOUT: !444 = !DILocalVariable(arg: 1, scope: !442, type: !7) -// CHECK:STDOUT: !445 = !DILocation(line: 81, column: 17, scope: !442) -// CHECK:STDOUT: !446 = !DILocation(line: 81, column: 12, scope: !442) -// CHECK:STDOUT: !447 = !DILocation(line: 81, column: 5, scope: !442) -// CHECK:STDOUT: !448 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !400, line: 59, type: !449, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !451) +// CHECK:STDOUT: !445 = !DILocation(line: 82, column: 17, scope: !442) +// CHECK:STDOUT: !446 = !DILocation(line: 82, column: 12, scope: !442) +// CHECK:STDOUT: !447 = !DILocation(line: 82, column: 5, scope: !442) +// CHECK:STDOUT: !448 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !400, line: 60, type: !449, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !451) // CHECK:STDOUT: !449 = !DISubroutineType(types: !450) // CHECK:STDOUT: !450 = !{!7, !7} // CHECK:STDOUT: !451 = !{!452} // CHECK:STDOUT: !452 = !DILocalVariable(arg: 1, scope: !448, type: !7) -// CHECK:STDOUT: !453 = !DILocation(line: 59, column: 29, scope: !448) +// CHECK:STDOUT: !453 = !DILocation(line: 60, column: 29, scope: !448) diff --git a/toolchain/lower/testdata/primitives/char_literals.carbon b/toolchain/lower/testdata/primitives/char_literals.carbon new file mode 100644 index 000000000000..ec1451841cb0 --- /dev/null +++ b/toolchain/lower/testdata/primitives/char_literals.carbon @@ -0,0 +1,405 @@ +// 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/lower/testdata/primitives/char_literals.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/primitives/char_literals.carbon + +class CharLike { + impl as Core.ImplicitAs(char) { + fn Convert(unused self) -> char { return 'x'; } + } +} + +fn Discard[T:! type](unused x: T) {} + +fn Convert() { + Discard('x' as u8); + Discard('x' as u16); + Discard('x' as u32); + Discard('x' as i8); + Discard('x' as i16); + Discard('x' as i32); +} + +fn ConvertConstant() { + Discard('x' as u8); + Discard('x' as u16); + Discard('x' as u32); + Discard('x' as i16); + Discard('x' as i32); +} + +fn CompareChar(b: char) { + // TODO: Should we support CharLiteral vs CharLiteral comparisons? + + Discard('x' == b); + Discard('x' != b); + Discard('x' < b); + Discard('x' <= b); + Discard('x' > b); + Discard('x' >= b); + + Discard(b == 'x'); + Discard(b != 'x'); + Discard(b < 'x'); + Discard(b <= 'x'); + Discard(b > 'x'); + Discard(b >= 'x'); +} + +fn SubCharChar(c: char) { + Discard('x' - 'y'); + Discard(c - 'x'); + Discard('x' - c); +} + +fn AddSubIntLiteral() { + // TODO: Should we support arithmetic with non-constant integers? + // We currently require a cast to `char` first. + + Discard('x' + 1); + Discard(1 + 'x'); + Discard('x' - 1); +} + +fn AddSubInt8() { + // TODO: Should we support arithmetic with non-constant integers? + // We currently require a cast to `char` first. + + Discard('x' + (1 as i8)); + Discard((1 as i8) + 'x'); + Discard('x' - (1 as i8)); +} + +// CHECK:STDOUT: ; ModuleID = 'char_literals.carbon' +// CHECK:STDOUT: source_filename = "char_literals.carbon" +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define i8 @"_CConvert.CharLike.Main:ImplicitAs.295cf9b677564c5c.Core"(ptr %self) #0 !dbg !4 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret i8 120, !dbg !11 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CConvert.Main() #0 !dbg !12 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: call void @_CDiscard.Main.15688e19507865c6(i8 120), !dbg !15 +// CHECK:STDOUT: call void @_CDiscard.Main.147e0bd019a31663(i16 120), !dbg !16 +// CHECK:STDOUT: call void @_CDiscard.Main.eadca4a969cf6f21(i32 120), !dbg !17 +// CHECK:STDOUT: call void @_CDiscard.Main.15688e19507865c6(i8 120), !dbg !18 +// CHECK:STDOUT: call void @_CDiscard.Main.147e0bd019a31663(i16 120), !dbg !19 +// CHECK:STDOUT: call void @_CDiscard.Main.eadca4a969cf6f21(i32 120), !dbg !20 +// CHECK:STDOUT: ret void, !dbg !21 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CConvertConstant.Main() #0 !dbg !22 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: call void @_CDiscard.Main.15688e19507865c6(i8 120), !dbg !23 +// CHECK:STDOUT: call void @_CDiscard.Main.147e0bd019a31663(i16 120), !dbg !24 +// CHECK:STDOUT: call void @_CDiscard.Main.eadca4a969cf6f21(i32 120), !dbg !25 +// CHECK:STDOUT: call void @_CDiscard.Main.147e0bd019a31663(i16 120), !dbg !26 +// CHECK:STDOUT: call void @_CDiscard.Main.eadca4a969cf6f21(i32 120), !dbg !27 +// CHECK:STDOUT: ret void, !dbg !28 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CCompareChar.Main(i8 %b) #0 !dbg !29 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: %T.as_type.as.EqWith.impl.Equal.call = icmp eq i8 120, %b, !dbg !34 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %T.as_type.as.EqWith.impl.Equal.call), !dbg !35 +// CHECK:STDOUT: %T.as_type.as.EqWith.impl.NotEqual.call = icmp ne i8 120, %b, !dbg !36 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %T.as_type.as.EqWith.impl.NotEqual.call), !dbg !37 +// CHECK:STDOUT: %T.as_type.as.OrderedWith.impl.Less.call = icmp ult i8 120, %b, !dbg !38 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %T.as_type.as.OrderedWith.impl.Less.call), !dbg !39 +// CHECK:STDOUT: %T.as_type.as.OrderedWith.impl.LessOrEquivalent.call = icmp ule i8 120, %b, !dbg !40 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %T.as_type.as.OrderedWith.impl.LessOrEquivalent.call), !dbg !41 +// CHECK:STDOUT: %T.as_type.as.OrderedWith.impl.Greater.call = icmp ugt i8 120, %b, !dbg !42 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %T.as_type.as.OrderedWith.impl.Greater.call), !dbg !43 +// CHECK:STDOUT: %T.as_type.as.OrderedWith.impl.GreaterOrEquivalent.call = icmp uge i8 120, %b, !dbg !44 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %T.as_type.as.OrderedWith.impl.GreaterOrEquivalent.call), !dbg !45 +// CHECK:STDOUT: %char.as.EqWith.impl.Equal.call = icmp eq i8 %b, 120, !dbg !46 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %char.as.EqWith.impl.Equal.call), !dbg !47 +// CHECK:STDOUT: %char.as.EqWith.impl.NotEqual.call = icmp ne i8 %b, 120, !dbg !48 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %char.as.EqWith.impl.NotEqual.call), !dbg !49 +// CHECK:STDOUT: %char.as.OrderedWith.impl.Less.call = icmp ult i8 %b, 120, !dbg !50 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %char.as.OrderedWith.impl.Less.call), !dbg !51 +// CHECK:STDOUT: %char.as.OrderedWith.impl.LessOrEquivalent.call = icmp ule i8 %b, 120, !dbg !52 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %char.as.OrderedWith.impl.LessOrEquivalent.call), !dbg !53 +// CHECK:STDOUT: %char.as.OrderedWith.impl.Greater.call = icmp ugt i8 %b, 120, !dbg !54 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %char.as.OrderedWith.impl.Greater.call), !dbg !55 +// CHECK:STDOUT: %char.as.OrderedWith.impl.GreaterOrEquivalent.call = icmp uge i8 %b, 120, !dbg !56 +// CHECK:STDOUT: call void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %char.as.OrderedWith.impl.GreaterOrEquivalent.call), !dbg !57 +// CHECK:STDOUT: ret void, !dbg !58 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CSubCharChar.Main(i8 %c) #0 !dbg !59 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: call void @_CDiscard.Main.084a2801e0f5d754({} zeroinitializer), !dbg !62 +// CHECK:STDOUT: %char.as.SubWith.impl.Op.call = call i32 @"_COp.Char.Core:SubWith.7c3e388e0087434a.Core.f0dfac78fde8177c"(i8 %c, i8 120), !dbg !63 +// CHECK:STDOUT: call void @_CDiscard.Main.eadca4a969cf6f21(i32 %char.as.SubWith.impl.Op.call), !dbg !64 +// CHECK:STDOUT: %T.as_type.as.SubWith.impl.Op.call = call i32 @"_COp.b27934686504f96c:SubWith.295cf9b677564c5c.Core.f0dfac78fde8177c"(i8 120, i8 %c), !dbg !65 +// CHECK:STDOUT: call void @_CDiscard.Main.eadca4a969cf6f21(i32 %T.as_type.as.SubWith.impl.Op.call), !dbg !66 +// CHECK:STDOUT: ret void, !dbg !67 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CAddSubIntLiteral.Main() #0 !dbg !68 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: call void @_CDiscard.Main.084a2801e0f5d754({} zeroinitializer), !dbg !69 +// CHECK:STDOUT: call void @_CDiscard.Main.084a2801e0f5d754({} zeroinitializer), !dbg !70 +// CHECK:STDOUT: call void @_CDiscard.Main.084a2801e0f5d754({} zeroinitializer), !dbg !71 +// CHECK:STDOUT: ret void, !dbg !72 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define void @_CAddSubInt8.Main() #0 !dbg !73 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: call void @_CDiscard.Main.084a2801e0f5d754({} zeroinitializer), !dbg !74 +// CHECK:STDOUT: call void @_CDiscard.Main.084a2801e0f5d754({} zeroinitializer), !dbg !75 +// CHECK:STDOUT: call void @_CDiscard.Main.084a2801e0f5d754({} zeroinitializer), !dbg !76 +// CHECK:STDOUT: ret void, !dbg !77 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr void @_CDiscard.Main.15688e19507865c6(i8 %x) #0 !dbg !78 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret void, !dbg !81 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr void @_CDiscard.Main.147e0bd019a31663(i16 %x) #0 !dbg !82 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret void, !dbg !88 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr void @_CDiscard.Main.eadca4a969cf6f21(i32 %x) #0 !dbg !89 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret void, !dbg !95 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr void @_CDiscard.Main.a4c7fafe8a72cac4(i1 %x) #0 !dbg !96 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret void, !dbg !101 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr void @_CDiscard.Main.084a2801e0f5d754({} %x) #0 !dbg !102 { +// CHECK:STDOUT: entry: +// CHECK:STDOUT: ret void, !dbg !105 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr i32 @"_COp.Char.Core:SubWith.7c3e388e0087434a.Core.f0dfac78fde8177c"(i8 %self, i8 %other) #0 !dbg !106 { +// CHECK:STDOUT: %1 = call i32 @"_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee"(i8 %self), !dbg !114 +// CHECK:STDOUT: %2 = call i32 @"_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee"(i8 %other), !dbg !115 +// CHECK:STDOUT: %3 = sub i32 %1, %2, !dbg !116 +// CHECK:STDOUT: ret i32 %3, !dbg !117 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr i32 @"_COp.b27934686504f96c:SubWith.295cf9b677564c5c.Core.f0dfac78fde8177c"(i8 %self, i8 %other) #0 !dbg !118 { +// CHECK:STDOUT: %1 = call i32 @"_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee"(i8 %self), !dbg !122 +// CHECK:STDOUT: %2 = call i32 @"_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee"(i8 %other), !dbg !123 +// CHECK:STDOUT: %3 = sub i32 %1, %2, !dbg !124 +// CHECK:STDOUT: ret i32 %3, !dbg !125 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: declare i32 @"_COp.Char.Core:SubWith.295cf9b677564c5c.Core"(i8, i8) +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr i32 @"_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee"(i8 %self) #0 !dbg !126 { +// CHECK:STDOUT: %1 = call i32 @"_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b26071071fee62b9"(i8 %self), !dbg !131 +// CHECK:STDOUT: ret i32 %1, !dbg !131 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr i32 @"_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b26071071fee62b9"(i8 %self) #0 !dbg !132 { +// CHECK:STDOUT: %1 = call i32 @"_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.1d53f86bcab954ee"(i8 %self), !dbg !136 +// CHECK:STDOUT: ret i32 %1, !dbg !137 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr i32 @"_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.1d53f86bcab954ee"(i8 %from) #0 !dbg !138 { +// CHECK:STDOUT: %1 = call i8 @"_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8"(i8 %from), !dbg !141 +// CHECK:STDOUT: %2 = zext i8 %1 to i32, !dbg !142 +// CHECK:STDOUT: ret i32 %2, !dbg !143 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; Function Attrs: nounwind +// CHECK:STDOUT: define linkonce_odr i8 @"_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8"(i8 %self) #0 !dbg !144 { +// CHECK:STDOUT: ret i8 %self, !dbg !149 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: ; uselistorder directives +// CHECK:STDOUT: uselistorder ptr @_CDiscard.Main.15688e19507865c6, { 2, 0, 1 } +// CHECK:STDOUT: uselistorder ptr @_CDiscard.Main.147e0bd019a31663, { 3, 0, 2, 1 } +// CHECK:STDOUT: uselistorder ptr @_CDiscard.Main.eadca4a969cf6f21, { 5, 0, 4, 1, 2, 3 } +// CHECK:STDOUT: uselistorder ptr @_CDiscard.Main.a4c7fafe8a72cac4, { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } +// CHECK:STDOUT: uselistorder ptr @_CDiscard.Main.084a2801e0f5d754, { 6, 0, 1, 2, 3, 4, 5 } +// CHECK:STDOUT: uselistorder ptr @"_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee", { 3, 2, 1, 0 } +// CHECK:STDOUT: +// CHECK:STDOUT: attributes #0 = { nounwind } +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.module.flags = !{!0, !1} +// CHECK:STDOUT: !llvm.dbg.cu = !{!2} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !3 = !DIFile(filename: "char_literals.carbon", directory: "") +// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.CharLike.Main:ImplicitAs.295cf9b677564c5c.Core", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !9) +// CHECK:STDOUT: !5 = !DISubroutineType(types: !6) +// CHECK:STDOUT: !6 = !{!7, !8} +// CHECK:STDOUT: !7 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_unsigned) +// CHECK:STDOUT: !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) +// CHECK:STDOUT: !9 = !{!10} +// CHECK:STDOUT: !10 = !DILocalVariable(arg: 1, scope: !4, type: !8) +// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 39, scope: !4) +// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Main", scope: null, file: !3, line: 21, type: !13, spFlags: DISPFlagDefinition, unit: !2) +// CHECK:STDOUT: !13 = !DISubroutineType(types: !14) +// CHECK:STDOUT: !14 = !{null} +// CHECK:STDOUT: !15 = !DILocation(line: 22, column: 3, scope: !12) +// CHECK:STDOUT: !16 = !DILocation(line: 23, column: 3, scope: !12) +// CHECK:STDOUT: !17 = !DILocation(line: 24, column: 3, scope: !12) +// CHECK:STDOUT: !18 = !DILocation(line: 25, column: 3, scope: !12) +// CHECK:STDOUT: !19 = !DILocation(line: 26, column: 3, scope: !12) +// CHECK:STDOUT: !20 = !DILocation(line: 27, column: 3, scope: !12) +// CHECK:STDOUT: !21 = !DILocation(line: 21, column: 1, scope: !12) +// CHECK:STDOUT: !22 = distinct !DISubprogram(name: "ConvertConstant", linkageName: "_CConvertConstant.Main", scope: null, file: !3, line: 30, type: !13, spFlags: DISPFlagDefinition, unit: !2) +// CHECK:STDOUT: !23 = !DILocation(line: 31, column: 3, scope: !22) +// CHECK:STDOUT: !24 = !DILocation(line: 32, column: 3, scope: !22) +// CHECK:STDOUT: !25 = !DILocation(line: 33, column: 3, scope: !22) +// CHECK:STDOUT: !26 = !DILocation(line: 34, column: 3, scope: !22) +// CHECK:STDOUT: !27 = !DILocation(line: 35, column: 3, scope: !22) +// CHECK:STDOUT: !28 = !DILocation(line: 30, column: 1, scope: !22) +// CHECK:STDOUT: !29 = distinct !DISubprogram(name: "CompareChar", linkageName: "_CCompareChar.Main", scope: null, file: !3, line: 38, type: !30, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !32) +// CHECK:STDOUT: !30 = !DISubroutineType(types: !31) +// CHECK:STDOUT: !31 = !{null, !7} +// CHECK:STDOUT: !32 = !{!33} +// CHECK:STDOUT: !33 = !DILocalVariable(arg: 1, scope: !29, type: !7) +// CHECK:STDOUT: !34 = !DILocation(line: 41, column: 11, scope: !29) +// CHECK:STDOUT: !35 = !DILocation(line: 41, column: 3, scope: !29) +// CHECK:STDOUT: !36 = !DILocation(line: 42, column: 11, scope: !29) +// CHECK:STDOUT: !37 = !DILocation(line: 42, column: 3, scope: !29) +// CHECK:STDOUT: !38 = !DILocation(line: 43, column: 11, scope: !29) +// CHECK:STDOUT: !39 = !DILocation(line: 43, column: 3, scope: !29) +// CHECK:STDOUT: !40 = !DILocation(line: 44, column: 11, scope: !29) +// CHECK:STDOUT: !41 = !DILocation(line: 44, column: 3, scope: !29) +// CHECK:STDOUT: !42 = !DILocation(line: 45, column: 11, scope: !29) +// CHECK:STDOUT: !43 = !DILocation(line: 45, column: 3, scope: !29) +// CHECK:STDOUT: !44 = !DILocation(line: 46, column: 11, scope: !29) +// CHECK:STDOUT: !45 = !DILocation(line: 46, column: 3, scope: !29) +// CHECK:STDOUT: !46 = !DILocation(line: 48, column: 11, scope: !29) +// CHECK:STDOUT: !47 = !DILocation(line: 48, column: 3, scope: !29) +// CHECK:STDOUT: !48 = !DILocation(line: 49, column: 11, scope: !29) +// CHECK:STDOUT: !49 = !DILocation(line: 49, column: 3, scope: !29) +// CHECK:STDOUT: !50 = !DILocation(line: 50, column: 11, scope: !29) +// CHECK:STDOUT: !51 = !DILocation(line: 50, column: 3, scope: !29) +// CHECK:STDOUT: !52 = !DILocation(line: 51, column: 11, scope: !29) +// CHECK:STDOUT: !53 = !DILocation(line: 51, column: 3, scope: !29) +// CHECK:STDOUT: !54 = !DILocation(line: 52, column: 11, scope: !29) +// CHECK:STDOUT: !55 = !DILocation(line: 52, column: 3, scope: !29) +// CHECK:STDOUT: !56 = !DILocation(line: 53, column: 11, scope: !29) +// CHECK:STDOUT: !57 = !DILocation(line: 53, column: 3, scope: !29) +// CHECK:STDOUT: !58 = !DILocation(line: 38, column: 1, scope: !29) +// CHECK:STDOUT: !59 = distinct !DISubprogram(name: "SubCharChar", linkageName: "_CSubCharChar.Main", scope: null, file: !3, line: 56, type: !30, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !60) +// CHECK:STDOUT: !60 = !{!61} +// CHECK:STDOUT: !61 = !DILocalVariable(arg: 1, scope: !59, type: !7) +// CHECK:STDOUT: !62 = !DILocation(line: 57, column: 3, scope: !59) +// CHECK:STDOUT: !63 = !DILocation(line: 58, column: 11, scope: !59) +// CHECK:STDOUT: !64 = !DILocation(line: 58, column: 3, scope: !59) +// CHECK:STDOUT: !65 = !DILocation(line: 59, column: 11, scope: !59) +// CHECK:STDOUT: !66 = !DILocation(line: 59, column: 3, scope: !59) +// CHECK:STDOUT: !67 = !DILocation(line: 56, column: 1, scope: !59) +// CHECK:STDOUT: !68 = distinct !DISubprogram(name: "AddSubIntLiteral", linkageName: "_CAddSubIntLiteral.Main", scope: null, file: !3, line: 62, type: !13, spFlags: DISPFlagDefinition, unit: !2) +// CHECK:STDOUT: !69 = !DILocation(line: 66, column: 3, scope: !68) +// CHECK:STDOUT: !70 = !DILocation(line: 67, column: 3, scope: !68) +// CHECK:STDOUT: !71 = !DILocation(line: 68, column: 3, scope: !68) +// CHECK:STDOUT: !72 = !DILocation(line: 62, column: 1, scope: !68) +// CHECK:STDOUT: !73 = distinct !DISubprogram(name: "AddSubInt8", linkageName: "_CAddSubInt8.Main", scope: null, file: !3, line: 71, type: !13, spFlags: DISPFlagDefinition, unit: !2) +// CHECK:STDOUT: !74 = !DILocation(line: 75, column: 3, scope: !73) +// CHECK:STDOUT: !75 = !DILocation(line: 76, column: 3, scope: !73) +// CHECK:STDOUT: !76 = !DILocation(line: 77, column: 3, scope: !73) +// CHECK:STDOUT: !77 = !DILocation(line: 71, column: 1, scope: !73) +// CHECK:STDOUT: !78 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.15688e19507865c6", scope: null, file: !3, line: 19, type: !30, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !79) +// CHECK:STDOUT: !79 = !{!80} +// CHECK:STDOUT: !80 = !DILocalVariable(arg: 1, scope: !78, type: !7) +// CHECK:STDOUT: !81 = !DILocation(line: 19, column: 1, scope: !78) +// CHECK:STDOUT: !82 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.147e0bd019a31663", scope: null, file: !3, line: 19, type: !83, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !86) +// CHECK:STDOUT: !83 = !DISubroutineType(types: !84) +// CHECK:STDOUT: !84 = !{null, !85} +// CHECK:STDOUT: !85 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_unsigned) +// CHECK:STDOUT: !86 = !{!87} +// CHECK:STDOUT: !87 = !DILocalVariable(arg: 1, scope: !82, type: !85) +// CHECK:STDOUT: !88 = !DILocation(line: 19, column: 1, scope: !82) +// CHECK:STDOUT: !89 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.eadca4a969cf6f21", scope: null, file: !3, line: 19, type: !90, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !93) +// CHECK:STDOUT: !90 = !DISubroutineType(types: !91) +// CHECK:STDOUT: !91 = !{null, !92} +// CHECK:STDOUT: !92 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_unsigned) +// CHECK:STDOUT: !93 = !{!94} +// CHECK:STDOUT: !94 = !DILocalVariable(arg: 1, scope: !89, type: !92) +// CHECK:STDOUT: !95 = !DILocation(line: 19, column: 1, scope: !89) +// CHECK:STDOUT: !96 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.a4c7fafe8a72cac4", scope: null, file: !3, line: 19, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !99) +// CHECK:STDOUT: !97 = !DISubroutineType(types: !98) +// CHECK:STDOUT: !98 = !{null, !8} +// CHECK:STDOUT: !99 = !{!100} +// CHECK:STDOUT: !100 = !DILocalVariable(arg: 1, scope: !96, type: !8) +// CHECK:STDOUT: !101 = !DILocation(line: 19, column: 1, scope: !96) +// CHECK:STDOUT: !102 = distinct !DISubprogram(name: "Discard", linkageName: "_CDiscard.Main.084a2801e0f5d754", scope: null, file: !3, line: 19, type: !97, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !103) +// CHECK:STDOUT: !103 = !{!104} +// CHECK:STDOUT: !104 = !DILocalVariable(arg: 1, scope: !102, type: !8) +// CHECK:STDOUT: !105 = !DILocation(line: 19, column: 1, scope: !102) +// CHECK:STDOUT: !106 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Char.Core:SubWith.7c3e388e0087434a.Core.f0dfac78fde8177c", scope: null, file: !107, line: 129, type: !108, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !111) +// CHECK:STDOUT: !107 = !DIFile(filename: "{{.*}}/prelude/types/char.carbon", directory: "") +// CHECK:STDOUT: !108 = !DISubroutineType(types: !109) +// CHECK:STDOUT: !109 = !{!110, !7, !7} +// CHECK:STDOUT: !110 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +// CHECK:STDOUT: !111 = !{!112, !113} +// CHECK:STDOUT: !112 = !DILocalVariable(arg: 1, scope: !106, type: !7) +// CHECK:STDOUT: !113 = !DILocalVariable(arg: 2, scope: !106, type: !7) +// CHECK:STDOUT: !114 = !DILocation(line: 130, column: 13, scope: !106) +// CHECK:STDOUT: !115 = !DILocation(line: 130, column: 29, scope: !106) +// CHECK:STDOUT: !116 = !DILocation(line: 130, column: 12, scope: !106) +// CHECK:STDOUT: !117 = !DILocation(line: 130, column: 5, scope: !106) +// CHECK:STDOUT: !118 = distinct !DISubprogram(name: "Op", linkageName: "_COp.b27934686504f96c:SubWith.295cf9b677564c5c.Core.f0dfac78fde8177c", scope: null, file: !107, line: 123, type: !108, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !119) +// CHECK:STDOUT: !119 = !{!120, !121} +// CHECK:STDOUT: !120 = !DILocalVariable(arg: 1, scope: !118, type: !7) +// CHECK:STDOUT: !121 = !DILocalVariable(arg: 2, scope: !118, type: !7) +// CHECK:STDOUT: !122 = !DILocation(line: 124, column: 13, scope: !118) +// CHECK:STDOUT: !123 = !DILocation(line: 124, column: 29, scope: !118) +// CHECK:STDOUT: !124 = !DILocation(line: 124, column: 12, scope: !118) +// CHECK:STDOUT: !125 = !DILocation(line: 124, column: 5, scope: !118) +// CHECK:STDOUT: !126 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Char.Core:As.5d7343568c0b5715.Core.db6d5218df1134ee", scope: null, file: !107, line: 42, type: !127, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !129) +// CHECK:STDOUT: !127 = !DISubroutineType(types: !128) +// CHECK:STDOUT: !128 = !{!110, !7} +// CHECK:STDOUT: !129 = !{!130} +// CHECK:STDOUT: !130 = !DILocalVariable(arg: 1, scope: !126, type: !7) +// CHECK:STDOUT: !131 = !DILocation(line: 43, column: 5, scope: !126) +// CHECK:STDOUT: !132 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b26071071fee62b9", scope: null, file: !133, line: 88, type: !127, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !134) +// CHECK:STDOUT: !133 = !DIFile(filename: "{{.*}}/prelude/types/uint.carbon", directory: "") +// CHECK:STDOUT: !134 = !{!135} +// CHECK:STDOUT: !135 = !DILocalVariable(arg: 1, scope: !132, type: !7) +// CHECK:STDOUT: !136 = !DILocation(line: 89, column: 12, scope: !132) +// CHECK:STDOUT: !137 = !DILocation(line: 89, column: 5, scope: !132) +// CHECK:STDOUT: !138 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.1d53f86bcab954ee", scope: null, file: !133, line: 80, type: !127, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !139) +// CHECK:STDOUT: !139 = !{!140} +// CHECK:STDOUT: !140 = !DILocalVariable(arg: 1, scope: !138, type: !7) +// CHECK:STDOUT: !141 = !DILocation(line: 82, column: 17, scope: !138) +// CHECK:STDOUT: !142 = !DILocation(line: 82, column: 12, scope: !138) +// CHECK:STDOUT: !143 = !DILocation(line: 82, column: 5, scope: !138) +// CHECK:STDOUT: !144 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !133, line: 60, type: !145, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !147) +// CHECK:STDOUT: !145 = !DISubroutineType(types: !146) +// CHECK:STDOUT: !146 = !{!7, !7} +// CHECK:STDOUT: !147 = !{!148} +// CHECK:STDOUT: !148 = !DILocalVariable(arg: 1, scope: !144, type: !7) +// CHECK:STDOUT: !149 = !DILocation(line: 60, column: 29, scope: !144) diff --git a/toolchain/lower/testdata/primitives/int_types.carbon b/toolchain/lower/testdata/primitives/int_types.carbon index d5eb4f487f7f..fdaf902a4a9c 100644 --- a/toolchain/lower/testdata/primitives/int_types.carbon +++ b/toolchain/lower/testdata/primitives/int_types.carbon @@ -321,74 +321,74 @@ fn ImplicitWidenUnsignedCustom(a: Core.UInt(4)) -> Core.UInt(5) { return a; } // CHECK:STDOUT: !39 = !{!40} // CHECK:STDOUT: !40 = !DILocalVariable(arg: 1, scope: !34, type: !38) // CHECK:STDOUT: !41 = !DILocation(line: 8, column: 67, scope: !34) -// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.211c7f442b391488", scope: null, file: !43, line: 63, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !44) +// CHECK:STDOUT: !42 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.211c7f442b391488", scope: null, file: !43, line: 64, type: !5, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !44) // CHECK:STDOUT: !43 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !44 = !{!45} // CHECK:STDOUT: !45 = !DILocalVariable(arg: 1, scope: !42, type: !8) -// CHECK:STDOUT: !46 = !DILocation(line: 65, column: 17, scope: !42) -// CHECK:STDOUT: !47 = !DILocation(line: 65, column: 12, scope: !42) -// CHECK:STDOUT: !48 = !DILocation(line: 65, column: 5, scope: !42) -// CHECK:STDOUT: !49 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.dbd6eca082a732b7", scope: null, file: !50, line: 87, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) +// CHECK:STDOUT: !46 = !DILocation(line: 66, column: 17, scope: !42) +// CHECK:STDOUT: !47 = !DILocation(line: 66, column: 12, scope: !42) +// CHECK:STDOUT: !48 = !DILocation(line: 66, column: 5, scope: !42) +// CHECK:STDOUT: !49 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.dbd6eca082a732b7", scope: null, file: !50, line: 88, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !51) // CHECK:STDOUT: !50 = !DIFile(filename: "{{.*}}/prelude/types/uint.carbon", directory: "") // CHECK:STDOUT: !51 = !{!52} // CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !49, type: !16) -// CHECK:STDOUT: !53 = !DILocation(line: 88, column: 12, scope: !49) -// CHECK:STDOUT: !54 = !DILocation(line: 88, column: 5, scope: !49) -// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b26071071fee62b9", scope: null, file: !50, line: 87, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) +// CHECK:STDOUT: !53 = !DILocation(line: 89, column: 12, scope: !49) +// CHECK:STDOUT: !54 = !DILocation(line: 89, column: 5, scope: !49) +// CHECK:STDOUT: !55 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.b26071071fee62b9", scope: null, file: !50, line: 88, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !56) // CHECK:STDOUT: !56 = !{!57} // CHECK:STDOUT: !57 = !DILocalVariable(arg: 1, scope: !55, type: !16) -// CHECK:STDOUT: !58 = !DILocation(line: 88, column: 12, scope: !55) -// CHECK:STDOUT: !59 = !DILocation(line: 88, column: 5, scope: !55) -// CHECK:STDOUT: !60 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.913488c3cb524db0", scope: null, file: !43, line: 63, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !61) +// CHECK:STDOUT: !58 = !DILocation(line: 89, column: 12, scope: !55) +// CHECK:STDOUT: !59 = !DILocation(line: 89, column: 5, scope: !55) +// CHECK:STDOUT: !60 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.913488c3cb524db0", scope: null, file: !43, line: 64, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !61) // CHECK:STDOUT: !61 = !{!62} // CHECK:STDOUT: !62 = !DILocalVariable(arg: 1, scope: !60, type: !30) -// CHECK:STDOUT: !63 = !DILocation(line: 65, column: 17, scope: !60) -// CHECK:STDOUT: !64 = !DILocation(line: 65, column: 12, scope: !60) -// CHECK:STDOUT: !65 = !DILocation(line: 65, column: 5, scope: !60) -// CHECK:STDOUT: !66 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.4c1b8e556dc24c05", scope: null, file: !50, line: 87, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) +// CHECK:STDOUT: !63 = !DILocation(line: 66, column: 17, scope: !60) +// CHECK:STDOUT: !64 = !DILocation(line: 66, column: 12, scope: !60) +// CHECK:STDOUT: !65 = !DILocation(line: 66, column: 5, scope: !60) +// CHECK:STDOUT: !66 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:ImplicitAs.f48df0d8add56b17.Core.4c1b8e556dc24c05", scope: null, file: !50, line: 88, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !67) // CHECK:STDOUT: !67 = !{!68} // CHECK:STDOUT: !68 = !DILocalVariable(arg: 1, scope: !66, type: !38) -// CHECK:STDOUT: !69 = !DILocation(line: 88, column: 12, scope: !66) -// CHECK:STDOUT: !70 = !DILocation(line: 88, column: 5, scope: !66) -// CHECK:STDOUT: !71 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !43, line: 58, type: !72, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) +// CHECK:STDOUT: !69 = !DILocation(line: 89, column: 12, scope: !66) +// CHECK:STDOUT: !70 = !DILocation(line: 89, column: 5, scope: !66) +// CHECK:STDOUT: !71 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !43, line: 59, type: !72, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !74) // CHECK:STDOUT: !72 = !DISubroutineType(types: !73) // CHECK:STDOUT: !73 = !{!8, !8} // CHECK:STDOUT: !74 = !{!75} // CHECK:STDOUT: !75 = !DILocalVariable(arg: 1, scope: !71, type: !8) -// CHECK:STDOUT: !76 = !DILocation(line: 58, column: 28, scope: !71) -// CHECK:STDOUT: !77 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.d93106ca8c7912cd", scope: null, file: !50, line: 71, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !78) +// CHECK:STDOUT: !76 = !DILocation(line: 59, column: 28, scope: !71) +// CHECK:STDOUT: !77 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.d93106ca8c7912cd", scope: null, file: !50, line: 72, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !78) // CHECK:STDOUT: !78 = !{!79} // CHECK:STDOUT: !79 = !DILocalVariable(arg: 1, scope: !77, type: !16) -// CHECK:STDOUT: !80 = !DILocation(line: 73, column: 17, scope: !77) -// CHECK:STDOUT: !81 = !DILocation(line: 73, column: 12, scope: !77) -// CHECK:STDOUT: !82 = !DILocation(line: 73, column: 5, scope: !77) -// CHECK:STDOUT: !83 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.1d53f86bcab954ee", scope: null, file: !50, line: 79, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) +// CHECK:STDOUT: !80 = !DILocation(line: 74, column: 17, scope: !77) +// CHECK:STDOUT: !81 = !DILocation(line: 74, column: 12, scope: !77) +// CHECK:STDOUT: !82 = !DILocation(line: 74, column: 5, scope: !77) +// CHECK:STDOUT: !83 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Int.9452f4c51951679b.Core:FromUInt.94db85caea4a44af.Core.1d53f86bcab954ee", scope: null, file: !50, line: 80, type: !21, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !84) // CHECK:STDOUT: !84 = !{!85} // CHECK:STDOUT: !85 = !DILocalVariable(arg: 1, scope: !83, type: !16) -// CHECK:STDOUT: !86 = !DILocation(line: 81, column: 17, scope: !83) -// CHECK:STDOUT: !87 = !DILocation(line: 81, column: 12, scope: !83) -// CHECK:STDOUT: !88 = !DILocation(line: 81, column: 5, scope: !83) -// CHECK:STDOUT: !89 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.044c7d430ddd4fd6", scope: null, file: !43, line: 58, type: !90, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) +// CHECK:STDOUT: !86 = !DILocation(line: 82, column: 17, scope: !83) +// CHECK:STDOUT: !87 = !DILocation(line: 82, column: 12, scope: !83) +// CHECK:STDOUT: !88 = !DILocation(line: 82, column: 5, scope: !83) +// CHECK:STDOUT: !89 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.044c7d430ddd4fd6", scope: null, file: !43, line: 59, type: !90, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !92) // CHECK:STDOUT: !90 = !DISubroutineType(types: !91) // CHECK:STDOUT: !91 = !{!30, !30} // CHECK:STDOUT: !92 = !{!93} // CHECK:STDOUT: !93 = !DILocalVariable(arg: 1, scope: !89, type: !30) -// CHECK:STDOUT: !94 = !DILocation(line: 58, column: 28, scope: !89) -// CHECK:STDOUT: !95 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.cc82cccb0d5a8ccf", scope: null, file: !50, line: 71, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !96) +// CHECK:STDOUT: !94 = !DILocation(line: 59, column: 28, scope: !89) +// CHECK:STDOUT: !95 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.UInt.9452f4c51951679b.Core:FromUInt.a1a82301830d1e08.Core.cc82cccb0d5a8ccf", scope: null, file: !50, line: 72, type: !35, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !96) // CHECK:STDOUT: !96 = !{!97} // CHECK:STDOUT: !97 = !DILocalVariable(arg: 1, scope: !95, type: !38) -// CHECK:STDOUT: !98 = !DILocation(line: 73, column: 17, scope: !95) -// CHECK:STDOUT: !99 = !DILocation(line: 73, column: 12, scope: !95) -// CHECK:STDOUT: !100 = !DILocation(line: 73, column: 5, scope: !95) -// CHECK:STDOUT: !101 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !50, line: 59, type: !102, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !104) +// CHECK:STDOUT: !98 = !DILocation(line: 74, column: 17, scope: !95) +// CHECK:STDOUT: !99 = !DILocation(line: 74, column: 12, scope: !95) +// CHECK:STDOUT: !100 = !DILocation(line: 74, column: 5, scope: !95) +// CHECK:STDOUT: !101 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.ca1ac10d3fc7c1a8", scope: null, file: !50, line: 60, type: !102, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !104) // CHECK:STDOUT: !102 = !DISubroutineType(types: !103) // CHECK:STDOUT: !103 = !{!16, !16} // CHECK:STDOUT: !104 = !{!105} // CHECK:STDOUT: !105 = !DILocalVariable(arg: 1, scope: !101, type: !16) -// CHECK:STDOUT: !106 = !DILocation(line: 59, column: 29, scope: !101) -// CHECK:STDOUT: !107 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.044c7d430ddd4fd6", scope: null, file: !50, line: 59, type: !108, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !110) +// CHECK:STDOUT: !106 = !DILocation(line: 60, column: 29, scope: !101) +// CHECK:STDOUT: !107 = distinct !DISubprogram(name: "AsUInt", linkageName: "_CAsUInt.UInt.9452f4c51951679b.Core:AnyUInt.Core.044c7d430ddd4fd6", scope: null, file: !50, line: 60, type: !108, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !110) // CHECK:STDOUT: !108 = !DISubroutineType(types: !109) // CHECK:STDOUT: !109 = !{!38, !38} // CHECK:STDOUT: !110 = !{!111} // CHECK:STDOUT: !111 = !DILocalVariable(arg: 1, scope: !107, type: !38) -// CHECK:STDOUT: !112 = !DILocation(line: 59, column: 29, scope: !107) +// CHECK:STDOUT: !112 = !DILocation(line: 60, column: 29, scope: !107) diff --git a/toolchain/lower/testdata/primitives/optional.carbon b/toolchain/lower/testdata/primitives/optional.carbon index f9c61ec30576..921219cc8230 100644 --- a/toolchain/lower/testdata/primitives/optional.carbon +++ b/toolchain/lower/testdata/primitives/optional.carbon @@ -488,42 +488,42 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !113 = !{!14} // CHECK:STDOUT: !114 = !DILocation(line: 31, column: 12, scope: !111) // CHECK:STDOUT: !115 = !DILocation(line: 31, column: 5, scope: !111) -// CHECK:STDOUT: !116 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.ef077c075a7e2432:ImplicitAs.ad22d1bbc0605210.Core.36d191ed69f42abb", scope: null, file: !117, line: 42, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !118) +// CHECK:STDOUT: !116 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.ef077c075a7e2432:ImplicitAs.ad22d1bbc0605210.Core.36d191ed69f42abb", scope: null, file: !117, line: 43, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !118) // CHECK:STDOUT: !117 = !DIFile(filename: "{{.*}}/prelude/operators/as.carbon", directory: "") // CHECK:STDOUT: !118 = !{!119} // CHECK:STDOUT: !119 = !DILocalVariable(arg: 1, scope: !116, type: !7) -// CHECK:STDOUT: !120 = !DILocation(line: 42, column: 40, scope: !116) -// CHECK:STDOUT: !121 = !DILocation(line: 42, column: 33, scope: !116) +// CHECK:STDOUT: !120 = !DILocation(line: 43, column: 40, scope: !116) +// CHECK:STDOUT: !121 = !DILocation(line: 43, column: 33, scope: !116) // CHECK:STDOUT: !122 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.6f97602f44c068f9", scope: null, file: !94, line: 105, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !123) // CHECK:STDOUT: !123 = !{!124} // CHECK:STDOUT: !124 = !DILocalVariable(arg: 1, scope: !122, type: !7) // CHECK:STDOUT: !125 = !DILocation(line: 106, column: 12, scope: !122) // CHECK:STDOUT: !126 = !DILocation(line: 106, column: 5, scope: !122) -// CHECK:STDOUT: !127 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.ef077c075a7e2432:ImplicitAs.ad22d1bbc0605210.Core.7e715d26c6bb9daa", scope: null, file: !117, line: 42, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !128) +// CHECK:STDOUT: !127 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.ef077c075a7e2432:ImplicitAs.ad22d1bbc0605210.Core.7e715d26c6bb9daa", scope: null, file: !117, line: 43, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !128) // CHECK:STDOUT: !128 = !{!129} // CHECK:STDOUT: !129 = !DILocalVariable(arg: 1, scope: !127, type: !7) -// CHECK:STDOUT: !130 = !DILocation(line: 42, column: 40, scope: !127) -// CHECK:STDOUT: !131 = !DILocation(line: 42, column: 33, scope: !127) -// CHECK:STDOUT: !132 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.36d191ed69f42abb", scope: null, file: !117, line: 46, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !133) +// CHECK:STDOUT: !130 = !DILocation(line: 43, column: 40, scope: !127) +// CHECK:STDOUT: !131 = !DILocation(line: 43, column: 33, scope: !127) +// CHECK:STDOUT: !132 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.36d191ed69f42abb", scope: null, file: !117, line: 47, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !133) // CHECK:STDOUT: !133 = !{!134} // CHECK:STDOUT: !134 = !DILocalVariable(arg: 1, scope: !132, type: !7) -// CHECK:STDOUT: !135 = !DILocation(line: 46, column: 34, scope: !132) -// CHECK:STDOUT: !136 = !DILocation(line: 46, column: 27, scope: !132) -// CHECK:STDOUT: !137 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.bd2b2818aef220bf", scope: null, file: !117, line: 46, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !138) +// CHECK:STDOUT: !135 = !DILocation(line: 47, column: 34, scope: !132) +// CHECK:STDOUT: !136 = !DILocation(line: 47, column: 27, scope: !132) +// CHECK:STDOUT: !137 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.bd2b2818aef220bf", scope: null, file: !117, line: 47, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !138) // CHECK:STDOUT: !138 = !{!139} // CHECK:STDOUT: !139 = !DILocalVariable(arg: 1, scope: !137, type: !7) -// CHECK:STDOUT: !140 = !DILocation(line: 46, column: 34, scope: !137) -// CHECK:STDOUT: !141 = !DILocation(line: 46, column: 27, scope: !137) -// CHECK:STDOUT: !142 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.7e715d26c6bb9daa", scope: null, file: !117, line: 46, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !143) +// CHECK:STDOUT: !140 = !DILocation(line: 47, column: 34, scope: !137) +// CHECK:STDOUT: !141 = !DILocation(line: 47, column: 27, scope: !137) +// CHECK:STDOUT: !142 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.7e715d26c6bb9daa", scope: null, file: !117, line: 47, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !143) // CHECK:STDOUT: !143 = !{!144} // CHECK:STDOUT: !144 = !DILocalVariable(arg: 1, scope: !142, type: !7) -// CHECK:STDOUT: !145 = !DILocation(line: 46, column: 34, scope: !142) -// CHECK:STDOUT: !146 = !DILocation(line: 46, column: 27, scope: !142) -// CHECK:STDOUT: !147 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.7f331ac9d2b85055", scope: null, file: !117, line: 46, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !148) +// CHECK:STDOUT: !145 = !DILocation(line: 47, column: 34, scope: !142) +// CHECK:STDOUT: !146 = !DILocation(line: 47, column: 27, scope: !142) +// CHECK:STDOUT: !147 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.c18e58a62bf591fb:ImplicitAs.eb057aa32837c84e.Core.7f331ac9d2b85055", scope: null, file: !117, line: 47, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !148) // CHECK:STDOUT: !148 = !{!149} // CHECK:STDOUT: !149 = !DILocalVariable(arg: 1, scope: !147, type: !7) -// CHECK:STDOUT: !150 = !DILocation(line: 46, column: 34, scope: !147) -// CHECK:STDOUT: !151 = !DILocation(line: 46, column: 27, scope: !147) +// CHECK:STDOUT: !150 = !DILocation(line: 47, column: 34, scope: !147) +// CHECK:STDOUT: !151 = !DILocation(line: 47, column: 27, scope: !147) // CHECK:STDOUT: !152 = distinct !DISubprogram(name: "Has", linkageName: "_CHas.e8f8f92d3d08d149:OptionalStorage.Core.84588f41d61dafba", scope: null, file: !94, line: 172, type: !12, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !153) // CHECK:STDOUT: !153 = !{!154} // CHECK:STDOUT: !154 = !DILocalVariable(arg: 1, scope: !152, type: !14) @@ -553,11 +553,11 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !178 = !DILocalVariable(arg: 1, scope: !176, type: !7) // CHECK:STDOUT: !179 = !DILocation(line: 34, column: 12, scope: !176) // CHECK:STDOUT: !180 = !DILocation(line: 34, column: 5, scope: !176) -// CHECK:STDOUT: !181 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.ef077c075a7e2432:ImplicitAs.ad22d1bbc0605210.Core.a1e92423fb5cda0f", scope: null, file: !117, line: 42, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !182) +// CHECK:STDOUT: !181 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.ef077c075a7e2432:ImplicitAs.ad22d1bbc0605210.Core.a1e92423fb5cda0f", scope: null, file: !117, line: 43, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !182) // CHECK:STDOUT: !182 = !{!183} // CHECK:STDOUT: !183 = !DILocalVariable(arg: 1, scope: !181, type: !7) -// CHECK:STDOUT: !184 = !DILocation(line: 42, column: 40, scope: !181) -// CHECK:STDOUT: !185 = !DILocation(line: 42, column: 33, scope: !181) +// CHECK:STDOUT: !184 = !DILocation(line: 43, column: 40, scope: !181) +// CHECK:STDOUT: !185 = !DILocation(line: 43, column: 33, scope: !181) // CHECK:STDOUT: !186 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.442ff502447e2586", scope: null, file: !94, line: 33, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !187) // CHECK:STDOUT: !187 = !{!188} // CHECK:STDOUT: !188 = !DILocalVariable(arg: 1, scope: !186, type: !7) @@ -569,14 +569,14 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !194 = !DILocation(line: 137, column: 5, scope: !191) // CHECK:STDOUT: !195 = !DILocation(line: 138, column: 5, scope: !191) // CHECK:STDOUT: !196 = !DILocation(line: 139, column: 5, scope: !191) -// CHECK:STDOUT: !197 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !198, line: 63, type: !199, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !201) +// CHECK:STDOUT: !197 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.45e1f8de18643ddf:ImplicitAs.0bc6489996802dd4.Core.40372ba0ea03ef47", scope: null, file: !198, line: 64, type: !199, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !201) // CHECK:STDOUT: !198 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "") // CHECK:STDOUT: !199 = !DISubroutineType(types: !200) // CHECK:STDOUT: !200 = !{!7, !7} // CHECK:STDOUT: !201 = !{!202} // CHECK:STDOUT: !202 = !DILocalVariable(arg: 1, scope: !197, type: !7) -// CHECK:STDOUT: !203 = !DILocation(line: 65, column: 17, scope: !197) -// CHECK:STDOUT: !204 = !DILocation(line: 65, column: 5, scope: !197) +// CHECK:STDOUT: !203 = !DILocation(line: 66, column: 17, scope: !197) +// CHECK:STDOUT: !204 = !DILocation(line: 66, column: 5, scope: !197) // CHECK:STDOUT: !205 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.74becf39533834ee:OptionalStorage.Core.9e376a14fbf8fb3d", scope: null, file: !94, line: 131, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !206) // CHECK:STDOUT: !206 = !{!207} // CHECK:STDOUT: !207 = !DILocalVariable(arg: 1, scope: !205, type: !7) @@ -584,10 +584,10 @@ fn F(c: Core.Optional(C*)) -> Core.Optional(C*) { // CHECK:STDOUT: !209 = !DILocation(line: 137, column: 28, scope: !205) // CHECK:STDOUT: !210 = !DILocation(line: 138, column: 5, scope: !205) // CHECK:STDOUT: !211 = !DILocation(line: 139, column: 5, scope: !205) -// CHECK:STDOUT: !212 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !198, line: 58, type: !199, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !213) +// CHECK:STDOUT: !212 = distinct !DISubprogram(name: "AsInt", linkageName: "_CAsInt.Int.9452f4c51951679b.Core:AnyInt.Core.be1e879c1ad406d8", scope: null, file: !198, line: 59, type: !199, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !213) // CHECK:STDOUT: !213 = !{!214} // CHECK:STDOUT: !214 = !DILocalVariable(arg: 1, scope: !212, type: !7) -// CHECK:STDOUT: !215 = !DILocation(line: 58, column: 28, scope: !212) +// CHECK:STDOUT: !215 = !DILocation(line: 59, column: 28, scope: !212) // CHECK:STDOUT: !216 = distinct !DISubprogram(name: "Op", linkageName: "_COp.a7c16f707f533a23:Copy.Core.5bd8d5767580997a", scope: null, file: !217, line: 23, type: !105, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !218) // CHECK:STDOUT: !217 = !DIFile(filename: "{{.*}}/prelude/copy.carbon", directory: "") // CHECK:STDOUT: !218 = !{!219} diff --git a/toolchain/sem_ir/builtin_function_kind.cpp b/toolchain/sem_ir/builtin_function_kind.cpp index 0638cc2d7bbf..79e62a63f16b 100644 --- a/toolchain/sem_ir/builtin_function_kind.cpp +++ b/toolchain/sem_ir/builtin_function_kind.cpp @@ -461,11 +461,76 @@ constexpr BuiltinInfo MaybeUnformedMakeType = { constexpr BuiltinInfo FormMakeType = {"form.make_type", ValidateSignatureType>}; -// Converts between char types, with a diagnostic if the value doesn't fit. -constexpr BuiltinInfo CharConvertChecked = { - "char.convert_checked", +// Converts a character literal to a character type, with a diagnostic if the +// value doesn't fit. +constexpr BuiltinInfo CharLiteralConvertChar = { + "char_literal.convert_char", ValidateSignatureCharCompatible>}; +// Converts a character literal to a sized integer type, with a diagnostic if +// the value doesn't fit. +constexpr BuiltinInfo CharLiteralConvertInt = { + "char_literal.convert_int", + ValidateSignatureAnySizedInt>}; + +// Converts an integer type to a character literal, with a diagnostic if the +// value is not a valid Unicode code point. +constexpr BuiltinInfo IntConvertCharLiteral = { + "int.convert_char_literal", ValidateSignatureCharLiteral>}; + +// Determines if two character literals are equal. +constexpr BuiltinInfo CharLiteralEq = { + "char_literal.eq", ValidateSignatureBool>}; + +// Determines if two character literals are not equal. +constexpr BuiltinInfo CharLiteralNeq = { + "char_literal.neq", + ValidateSignatureBool>}; + +// Determines if one character literal is less than another. +constexpr BuiltinInfo CharLiteralLess = { + "char_literal.less", + ValidateSignatureBool>}; + +// Determines if one character literal is less than or equal to another. +constexpr BuiltinInfo CharLiteralLessEq = { + "char_literal.less_eq", + ValidateSignatureBool>}; + +// Determines if one character literal is greater than another. +constexpr BuiltinInfo CharLiteralGreater = { + "char_literal.greater", + ValidateSignatureBool>}; + +// Determines if one character literal is greater than or equal to another. +constexpr BuiltinInfo CharLiteralGreaterEq = { + "char_literal.greater_eq", + ValidateSignatureBool>}; + +// Adds an integer to a character literal, with a diagnostic on overflow or +// if the result is not a valid Unicode code point. +constexpr BuiltinInfo CharLiteralAdd = { + "char_literal.add", + ValidateSignatureCharLiteral>}; + +// Adds a character literal to an integer, with a diagnostic on overflow or +// if the result is not a valid Unicode code point. +constexpr BuiltinInfo IntAddCharLiteral = { + "int.add_char_literal", + ValidateSignatureCharLiteral>}; + +// Subtracts an integer from a character literal, with a diagnostic on +// overflow or if the result is not a valid Unicode code point. +constexpr BuiltinInfo CharLiteralSubInt = { + "char_literal.sub_int", + ValidateSignatureCharLiteral>}; + +// Subtracts one character literal from another, returning the distance as +// an integer. +constexpr BuiltinInfo CharLiteralSubChar = { + "char_literal.sub_char", + ValidateSignatureAnyInt>}; + // Converts from an integer type to a char-compatible type (u8/adapted Char). constexpr BuiltinInfo IntConvertChar = { "int.convert_char", ValidateSignatureCharCompatible>}; @@ -812,7 +877,8 @@ static auto IsLiteralType(const File& sem_ir, TypeId type_id) -> bool { // Unwrap adapters. type_id = sem_ir.types().GetTransitiveAdaptedType(type_id); auto type_inst_id = sem_ir.types().GetAsInst(type_id); - return type_inst_id.IsOneOf(); + return type_inst_id + .IsOneOf(); } // Determines whether a builtin call involves an integer or floating-point @@ -856,13 +922,29 @@ auto BuiltinFunctionKind::IsCompTimeOnly(const File& sem_ir, llvm::ArrayRef arg_ids, TypeId return_type_id) const -> bool { switch (*this) { - case CharConvertChecked: case FloatConvertChecked: case IntConvertChecked: case IntConvertFloatChecked: // Checked conversions are compile-time only. return true; + case CharLiteralAdd: + case CharLiteralConvertChar: + case CharLiteralConvertInt: + case CharLiteralEq: + case CharLiteralGreater: + case CharLiteralGreaterEq: + case CharLiteralLess: + case CharLiteralLessEq: + case CharLiteralNeq: + case CharLiteralSubChar: + case CharLiteralSubInt: + case IntAddCharLiteral: + case IntConvertCharLiteral: + // These operations always involve a literal type. + // See AnyLiteralTypes comment for explanation. + return true; + case FloatConvert: case FloatConvertInt: case IntConvert: diff --git a/toolchain/sem_ir/builtin_function_kind.def b/toolchain/sem_ir/builtin_function_kind.def index 4ff7fd588ff9..41b469f1bd94 100644 --- a/toolchain/sem_ir/builtin_function_kind.def +++ b/toolchain/sem_ir/builtin_function_kind.def @@ -47,11 +47,25 @@ CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(MaybeUnformedMakeType) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(FormMakeType) // Character conversion. -CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharConvertChecked) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralConvertChar) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralConvertInt) + +// Character literal arithmetic. +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralEq) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralNeq) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralLess) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralLessEq) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralGreater) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralGreaterEq) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralAdd) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntAddCharLiteral) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralSubInt) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(CharLiteralSubChar) // Integer conversion. CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvert) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertChar) +CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertCharLiteral) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertChecked) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertFloat) CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(IntConvertFloatChecked) diff --git a/toolchain/sem_ir/ids.cpp b/toolchain/sem_ir/ids.cpp index 48b45caeca53..9804a51b215b 100644 --- a/toolchain/sem_ir/ids.cpp +++ b/toolchain/sem_ir/ids.cpp @@ -4,6 +4,7 @@ #include "toolchain/sem_ir/ids.h" +#include "llvm/ADT/APInt.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/NativeFormatting.h" #include "toolchain/base/value_ids.h" @@ -86,6 +87,18 @@ auto CharId::Print(llvm::raw_ostream& out) const -> void { llvm::write_hex(out, index, llvm::HexPrintStyle::Upper, 4); } +auto CharId::ForCodePoint(const llvm::APInt& code_point) + -> std::optional { + if (code_point.isNegative() || code_point.ugt(0x10FFFF)) { + return std::nullopt; + } + uint64_t value = code_point.getZExtValue(); + if (value >= 0xD800 && value <= 0xDFFF) { + return std::nullopt; + } + return CharId(value); +} + auto IntKind::Print(llvm::raw_ostream& out) const -> void { if (*this == Unsigned) { out << "unsigned"; diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index 7dc70ed38821..63018f35724e 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -6,10 +6,12 @@ #define CARBON_TOOLCHAIN_SEM_IR_IDS_H_ #include +#include #include "common/check.h" #include "common/ostream.h" #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" #include "toolchain/base/index_base.h" #include "toolchain/base/value_ids.h" #include "toolchain/diagnostics/emitter.h" @@ -532,6 +534,12 @@ struct CharId : public IdBase { using IdBase::IdBase; auto Print(llvm::raw_ostream& out) const -> void; + + // Returns the CharId corresponding to a particular Unicode code point, + // or std::nullopt if the value is not a valid Unicode code point. Assumes + // `code_point` is signed. + static auto ForCodePoint(const llvm::APInt& code_point) + -> std::optional; }; // An integer kind value -- either "signed" or "unsigned". diff --git a/toolchain/testing/testdata/min_prelude/parts/char.carbon b/toolchain/testing/testdata/min_prelude/parts/char.carbon index 8f458d278784..4f4cc6e7575a 100644 --- a/toolchain/testing/testdata/min_prelude/parts/char.carbon +++ b/toolchain/testing/testdata/min_prelude/parts/char.carbon @@ -18,5 +18,5 @@ class Char { } impl CharLiteral as ImplicitAs(Char) { - fn Convert(self) -> Char = "char.convert_checked"; + fn Convert(self) -> Char = "char_literal.convert_char"; }