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

@@ -562,7 +562,7 @@ fn PassConstRef(ref x: const XByRef) {
}
// CHECK:STDOUT: --- call_param_lvalue_ref.carbon
// CHECK:STDOUT: --- call_param_lvalue_ref.carbon = $call_param_lvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -638,7 +638,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_param_lvalue_ref.carbon
// CHECK:STDOUT: --- fail_param_lvalue_ref.carbon = $fail_param_lvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -818,7 +818,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- call_param_rvalue_ref.carbon
// CHECK:STDOUT: --- call_param_rvalue_ref.carbon = $call_param_rvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -865,7 +865,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_param_rvalue_ref.carbon
// CHECK:STDOUT: --- fail_param_rvalue_ref.carbon = $fail_param_rvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1009,7 +1009,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- call_param_const_lvalue_ref_with_ref.carbon
// CHECK:STDOUT: --- call_param_const_lvalue_ref_with_ref.carbon = $call_param_const_lvalue_ref_with_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1108,7 +1108,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- call_param_const_lvalue_ref_with_value.carbon
// CHECK:STDOUT: --- call_param_const_lvalue_ref_with_value.carbon = $call_param_const_lvalue_ref_with_value
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1205,7 +1205,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- param_value_arg_for_const_rvalue_ref.carbon
// CHECK:STDOUT: --- param_value_arg_for_const_rvalue_ref.carbon = $param_value_arg_for_const_rvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1258,7 +1258,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_param_lvalue_ref_arg_const_rvalue_ref.carbon
// CHECK:STDOUT: --- fail_param_lvalue_ref_arg_const_rvalue_ref.carbon = $fail_param_lvalue_ref_arg_const_rvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1384,7 +1384,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- call_return_lvalue_ref.carbon
// CHECK:STDOUT: --- call_return_lvalue_ref.carbon = $call_return_lvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1424,7 +1424,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- call_return_rvalue_ref.carbon
// CHECK:STDOUT: --- call_return_rvalue_ref.carbon = $call_return_rvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1464,7 +1464,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- call_return_const_lvalue_ref.carbon
// CHECK:STDOUT: --- call_return_const_lvalue_ref.carbon = $call_return_const_lvalue_ref
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -1506,7 +1506,7 @@ fn PassConstRef(ref x: const XByRef) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- forwarding_reference.carbon
// CHECK:STDOUT: --- forwarding_reference.carbon = $forwarding_reference
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]