mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 22:02:51 +01:00
Use it in the instruction namer to make instruction names more stable across unrelated changes to the toolchain or the prelude. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
203 lines
7.4 KiB
Plaintext
203 lines
7.4 KiB
Plaintext
// 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
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/namespace/merging.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/merging.carbon
|
|
|
|
// --- a.carbon
|
|
|
|
package Example library "[[@TEST_NAME]]";
|
|
|
|
namespace NS;
|
|
|
|
fn NS.A() {}
|
|
|
|
// --- b.carbon
|
|
|
|
package Example library "[[@TEST_NAME]]";
|
|
|
|
namespace NS;
|
|
|
|
fn NS.B1() {}
|
|
|
|
namespace NS;
|
|
|
|
fn NS.B2() {}
|
|
|
|
// --- c.carbon
|
|
|
|
package Example library "[[@TEST_NAME]]";
|
|
|
|
import library "a";
|
|
import library "b";
|
|
|
|
namespace NS;
|
|
|
|
fn NS.C() {}
|
|
|
|
fn Run() {
|
|
NS.A();
|
|
NS.B1();
|
|
NS.B2();
|
|
NS.C();
|
|
}
|
|
|
|
// CHECK:STDOUT: --- a.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %A.type: type = fn_type @A [template]
|
|
// CHECK:STDOUT: %A: %A.type = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .NS = %NS
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %NS: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .A = %A.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @A() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- b.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %B1.type: type = fn_type @B1 [template]
|
|
// CHECK:STDOUT: %B1: %B1.type = struct_value () [template]
|
|
// CHECK:STDOUT: %B2.type: type = fn_type @B2 [template]
|
|
// CHECK:STDOUT: %B2: %B2.type = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .NS = %NS.loc4
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %NS.loc4: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .B1 = %B1.decl
|
|
// CHECK:STDOUT: .B2 = %B2.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %B1.decl: %B1.type = fn_decl @B1 [template = constants.%B1] {} {}
|
|
// CHECK:STDOUT: %NS.loc8: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .B1 = %B1.decl
|
|
// CHECK:STDOUT: .B2 = %B2.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %B2.decl: %B2.type = fn_decl @B2 [template = constants.%B2] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @B1() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @B2() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- c.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %C.type: type = fn_type @C [template]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %C: %C.type = struct_value () [template]
|
|
// CHECK:STDOUT: %Run.type: type = fn_type @Run [template]
|
|
// CHECK:STDOUT: %Run: %Run.type = struct_value () [template]
|
|
// CHECK:STDOUT: %A.type: type = fn_type @A [template]
|
|
// CHECK:STDOUT: %A: %A.type = struct_value () [template]
|
|
// CHECK:STDOUT: %B1.type: type = fn_type @B1 [template]
|
|
// CHECK:STDOUT: %B1: %B1.type = struct_value () [template]
|
|
// CHECK:STDOUT: %B2.type: type = fn_type @B2 [template]
|
|
// CHECK:STDOUT: %B2: %B2.type = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Example//a, NS, loaded
|
|
// CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
|
|
// CHECK:STDOUT: .A = %import_ref.5d2
|
|
// CHECK:STDOUT: .B1 = %import_ref.436
|
|
// CHECK:STDOUT: .B2 = %import_ref.fde
|
|
// CHECK:STDOUT: .C = file.%C.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %import_ref.5d2: %A.type = import_ref Example//a, A, loaded [template = constants.%A]
|
|
// CHECK:STDOUT: %import_ref.436: %B1.type = import_ref Example//b, B1, loaded [template = constants.%B1]
|
|
// CHECK:STDOUT: %import_ref.fde: %B2.type = import_ref Example//b, B2, loaded [template = constants.%B2]
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .NS = imports.%NS
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Run = %Run.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %default.import = import <invalid>
|
|
// CHECK:STDOUT: %NS: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .A = imports.%import_ref.5d2
|
|
// CHECK:STDOUT: .B1 = imports.%import_ref.436
|
|
// CHECK:STDOUT: .B2 = imports.%import_ref.fde
|
|
// CHECK:STDOUT: .C = %C.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} {}
|
|
// CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [template = constants.%Run] {} {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @C() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Run() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %NS.ref.loc12: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.5d2 [template = constants.%A]
|
|
// CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
|
|
// CHECK:STDOUT: %NS.ref.loc13: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %B1.ref: %B1.type = name_ref B1, imports.%import_ref.436 [template = constants.%B1]
|
|
// CHECK:STDOUT: %B1.call: init %empty_tuple.type = call %B1.ref()
|
|
// CHECK:STDOUT: %NS.ref.loc14: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %B2.ref: %B2.type = name_ref B2, imports.%import_ref.fde [template = constants.%B2]
|
|
// CHECK:STDOUT: %B2.call: init %empty_tuple.type = call %B2.ref()
|
|
// CHECK:STDOUT: %NS.ref.loc15: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
|
|
// CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
|
|
// CHECK:STDOUT: %C.call: init %empty_tuple.type = call %C.ref()
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @A() [from "a.carbon"];
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @B1() [from "b.carbon"];
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @B2() [from "b.carbon"];
|
|
// CHECK:STDOUT:
|