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

@@ -220,7 +220,7 @@ fn G() -> i32 {
// TODO: Add a test per unsupported return type. See https://github.com/carbon-language/carbon-lang/pull/5477/files/4321e21ed27d987fd71be182d292973fd9849df8#r2094655176
// CHECK:STDOUT: --- import_global.carbon
// CHECK:STDOUT: --- import_global.carbon = $import_global
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -248,7 +248,7 @@ fn G() -> i32 {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- import_special_name_call_escaped.carbon
// CHECK:STDOUT: --- import_special_name_call_escaped.carbon = $import_special_name_call_escaped
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -276,7 +276,7 @@ fn G() -> i32 {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- import_overloaded.carbon
// CHECK:STDOUT: --- import_overloaded.carbon = $import_overloaded
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -304,7 +304,7 @@ fn G() -> i32 {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_todo_import_variadic.carbon
// CHECK:STDOUT: --- fail_todo_import_variadic.carbon = $fail_todo_import_variadic
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -329,7 +329,7 @@ fn G() -> i32 {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- todo_fail_import_static.carbon
// CHECK:STDOUT: --- todo_fail_import_static.carbon = $todo_fail_import_static
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -357,7 +357,7 @@ fn G() -> i32 {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- import_template_function.carbon
// CHECK:STDOUT: --- import_template_function.carbon = $import_template_function
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]