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

@@ -79,7 +79,7 @@ impl library "[[@TEST_NAME]]";
// CHECK:STDERR:
extern fn A();
// CHECK:STDOUT: --- basic.carbon
// CHECK:STDOUT: --- basic.carbon = $basic
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -96,7 +96,7 @@ extern fn A();
// CHECK:STDOUT:
// CHECK:STDOUT: fn @A();
// CHECK:STDOUT:
// CHECK:STDOUT: --- basic.impl.carbon
// CHECK:STDOUT: --- basic.impl.carbon = $basic.impl
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -118,7 +118,7 @@ extern fn A();
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- extern_api.carbon
// CHECK:STDOUT: --- extern_api.carbon = $extern_api
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -135,7 +135,7 @@ extern fn A();
// CHECK:STDOUT:
// CHECK:STDOUT: extern fn @A();
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_extern_api.impl.carbon
// CHECK:STDOUT: --- fail_extern_api.impl.carbon = $fail_extern_api.impl
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -154,7 +154,7 @@ extern fn A();
// CHECK:STDOUT:
// CHECK:STDOUT: extern fn @A [from "extern_api.carbon"];
// CHECK:STDOUT:
// CHECK:STDOUT: --- extern_impl.carbon
// CHECK:STDOUT: --- extern_impl.carbon = $extern_impl
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
@@ -171,7 +171,7 @@ extern fn A();
// CHECK:STDOUT:
// CHECK:STDOUT: fn @A();
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_extern_impl.impl.carbon
// CHECK:STDOUT: --- fail_extern_impl.impl.carbon = $fail_extern_impl.impl
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]