// 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 "a"; namespace NS; fn NS.A() {} // --- b.carbon package Example library "b"; namespace NS; fn NS.B1() {} namespace NS; fn NS.B2() {} // --- c.carbon package Example library "c"; 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: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %NS: = 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: %.1: type = tuple_type () [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: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: } // CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %NS: = 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: %.loc8: = namespace [template] {} // 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: %.1: 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: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .NS = %NS // CHECK:STDOUT: .Core = %Core // CHECK:STDOUT: .Run = %Run.decl // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: = import_ref ir1, inst+2, loaded // CHECK:STDOUT: %NS: = namespace %import_ref.1, [template] { // CHECK:STDOUT: .A = %import_ref.2 // CHECK:STDOUT: .B1 = %import_ref.3 // CHECK:STDOUT: .B2 = %import_ref.4 // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.2: %A.type = import_ref ir1, inst+3, loaded [template = constants.%A] // CHECK:STDOUT: %import_ref.3: %B1.type = import_ref ir2, inst+3, loaded [template = constants.%B1] // CHECK:STDOUT: %import_ref.4: %B2.type = import_ref ir2, inst+9, loaded [template = constants.%B2] // CHECK:STDOUT: %Core: = namespace [template] {} // CHECK:STDOUT: %.loc7: = namespace [template] {} // 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: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%import_ref.2 [template = constants.%A] // CHECK:STDOUT: %A.call: init %.1 = call %A.ref() // CHECK:STDOUT: %NS.ref.loc13: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %B1.ref: %B1.type = name_ref B1, file.%import_ref.3 [template = constants.%B1] // CHECK:STDOUT: %B1.call: init %.1 = call %B1.ref() // CHECK:STDOUT: %NS.ref.loc14: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %B2.ref: %B2.type = name_ref B2, file.%import_ref.4 [template = constants.%B2] // CHECK:STDOUT: %B2.call: init %.1 = call %B2.ref() // CHECK:STDOUT: %NS.ref.loc15: = name_ref NS, file.%NS [template = file.%NS] // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %C.call: init %.1 = call %C.ref() // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @A(); // CHECK:STDOUT: // CHECK:STDOUT: fn @B1(); // CHECK:STDOUT: // CHECK:STDOUT: fn @B2(); // CHECK:STDOUT: