Give files shorthand names in textual SemIR (#8104)

Shorthand names are intended to be used in the textual format of
references to instructions in another IR (which can't happen now, but
will be possible in a forthcoming PR). The shorthand name uses the file
name (minus the `.carbon` suffix) as a base, and if that base name is
ambiguous within the compilation, it is given a numerical suffix `.N`,
just like other textual IR names. Shorthand names are prefixed with `$`
in the textual format, to distinguish them from inst and scope names.

For example, a file `foo/bar.carbon` has the shorthand name `$bar`, and
an instruction `@baz.%qux` in that file can be referenced from another
file as `$bar.@baz.%qux`.

This PR adds `toolchain/check/testdata/basics/file_name.carbon` to test
this behavior. All other test changes are just applying this change to
the existing textual SemIR dumps.

---------

Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
Geoff RomerandDana Jansens authored and GitHub committed 2026-11-12 23:34:32 +00:00
1 parent 54728e47fe
commit e67b6db910
790 files changed
+2398 -2479

No files matched your search

+3 -3
View File
@@ -136,7 +136,7 @@ fn ConversionExplicit(s: Cpp.ConditionallyExplicitFalse) {
//@dump-sem-ir-end
}
// CHECK:STDOUT: --- conversions.carbon
// CHECK:STDOUT: --- conversions.carbon = $conversions
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -309,7 +309,7 @@ fn ConversionExplicit(s: Cpp.ConditionallyExplicitFalse) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- conditionally_explicit.carbon
// CHECK:STDOUT: --- conditionally_explicit.carbon = $conditionally_explicit
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -518,7 +518,7 @@ fn ConversionExplicit(s: Cpp.ConditionallyExplicitFalse) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_conditionally_explicit_implicit.carbon
// CHECK:STDOUT: --- fail_conditionally_explicit_implicit.carbon = $fail_conditionally_explicit_implicit
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
+2 -2
View File
@@ -221,7 +221,7 @@ fn EqualWitnesses(p: Wrap(Cpp.Copyable)*) -> Wrap(Cpp.Copyable)* {
//@dump-sem-ir-end
}
// CHECK:STDOUT: --- copy_copyable.carbon
// CHECK:STDOUT: --- copy_copyable.carbon = $copy_copyable
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -318,7 +318,7 @@ fn EqualWitnesses(p: Wrap(Cpp.Copyable)*) -> Wrap(Cpp.Copyable)* {
// CHECK:STDOUT: return %.loc14_10.5 to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- copy_generically.carbon
// CHECK:STDOUT: --- copy_generically.carbon = $copy_generically
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
+3 -3
View File
@@ -307,7 +307,7 @@ fn F() {
var _: AdaptNoDestroy = Make();
}
// CHECK:STDOUT: --- destroy_destroyable.carbon
// CHECK:STDOUT: --- destroy_destroyable.carbon = $destroy_destroyable
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -482,7 +482,7 @@ fn F() {
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_todo_destroy_protected_base_destructor.carbon
// CHECK:STDOUT: --- fail_todo_destroy_protected_base_destructor.carbon = $fail_todo_destroy_protected_base_destructor
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -578,7 +578,7 @@ fn F() {
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_destroy_private_base_destructor.carbon
// CHECK:STDOUT: --- fail_destroy_private_base_destructor.carbon = $fail_destroy_private_base_destructor
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
+13 -13
View File
@@ -499,7 +499,7 @@ fn InitFromStruct() {
//@dump-sem-ir-end
}
// CHECK:STDOUT: --- implicit_conversions.carbon
// CHECK:STDOUT: --- implicit_conversions.carbon = $implicit_conversions
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -657,7 +657,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_expr_category.carbon
// CHECK:STDOUT: --- fail_expr_category.carbon = $fail_expr_category
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -692,7 +692,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_access.carbon
// CHECK:STDOUT: --- fail_access.carbon = $fail_access
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -813,7 +813,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_deleted.carbon
// CHECK:STDOUT: --- fail_deleted.carbon = $fail_deleted
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -871,7 +871,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_explicit.carbon
// CHECK:STDOUT: --- fail_explicit.carbon = $fail_explicit
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -929,7 +929,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- i32_to_int.carbon
// CHECK:STDOUT: --- i32_to_int.carbon = $i32_to_int
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -997,7 +997,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_no_u32_to_int_conversion_in_carbon.carbon
// CHECK:STDOUT: --- fail_no_u32_to_int_conversion_in_carbon.carbon = $fail_no_u32_to_int_conversion_in_carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1067,7 +1067,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- default_constructor.carbon
// CHECK:STDOUT: --- default_constructor.carbon = $default_constructor
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1134,7 +1134,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- construct_multi_argument.carbon
// CHECK:STDOUT: --- construct_multi_argument.carbon = $construct_multi_argument
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1357,7 +1357,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_todo_aggregate_from_tuple.carbon
// CHECK:STDOUT: --- fail_todo_aggregate_from_tuple.carbon = $fail_todo_aggregate_from_tuple
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1420,7 +1420,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_todo_aggregate_from_struct.carbon
// CHECK:STDOUT: --- fail_todo_aggregate_from_struct.carbon = $fail_todo_aggregate_from_struct
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1483,7 +1483,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- non_aggregate_from_tuple.carbon
// CHECK:STDOUT: --- non_aggregate_from_tuple.carbon = $non_aggregate_from_tuple
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1659,7 +1659,7 @@ fn InitFromStruct() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_non_aggregate_from_struct.carbon
// CHECK:STDOUT: --- fail_non_aggregate_from_struct.carbon = $fail_non_aggregate_from_struct
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]