mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 13:14:57 +01:00
Fixes link failures when referencing a symbol involving a fingerprint from a different package. Previously we included the `Namespace`'s `import_id` as part of its fingerprint, which caused local and imported namespaces to get different fingerprints. We now store the `import_id` on the `NameScope` instead of on the `Namespace` inst to avoid this problem. Also, when we reach a package-level `NameScopeId`, consistently fingerprint it as a (package name, library name) pair. Previously the fingerprinting depended on whether it was imported or not, as an imported `NameScopeId` had a parent scope (the current package). We need to include the library name here so that private entities with the same name in different libraries have different fingerprints.
157 lines
7.3 KiB
Plaintext
157 lines
7.3 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
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/destroy.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/var/param.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/var/param.carbon
|
|
|
|
// --- with_cleanup.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class C {
|
|
// TODO: Change to Core.Destructor when possible.
|
|
impl as Core.Destroy {
|
|
fn Op[ref self: Self]();
|
|
}
|
|
|
|
fn Make() -> Self;
|
|
}
|
|
|
|
fn F(var c: C);
|
|
|
|
fn G() {
|
|
F(C.Make());
|
|
}
|
|
|
|
// --- struct_literal_cleanup.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
class C {
|
|
// TODO: Change to Core.Destructor when possible.
|
|
impl as Core.Destroy {
|
|
fn Op[ref self: Self]();
|
|
}
|
|
}
|
|
|
|
fn F(var c: C);
|
|
|
|
fn G() {
|
|
F({});
|
|
}
|
|
|
|
// CHECK:STDOUT: ; ModuleID = 'with_cleanup.carbon'
|
|
// CHECK:STDOUT: source_filename = "with_cleanup.carbon"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: declare void @"_COp.C.Main:Destroy.Core"(ptr)
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: declare void @_CMake.C.Main(ptr sret({}))
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: declare void @_CF.Main(ptr)
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define void @_CG.Main() #0 !dbg !4 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !7
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !7
|
|
// CHECK:STDOUT: call void @_CMake.C.Main(ptr %c.var), !dbg !8
|
|
// CHECK:STDOUT: call void @_CF.Main(ptr %c.var), !dbg !9
|
|
// CHECK:STDOUT: call void @"_COp.bb4015b09b4ec8d8:core.Destroy.Core"(ptr %c.var), !dbg !7
|
|
// CHECK:STDOUT: ret void, !dbg !10
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define weak_odr void @"_COp.bb4015b09b4ec8d8:core.Destroy.Core"(ptr %self) #0 !dbg !11 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: ret void, !dbg !17
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
|
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: attributes #0 = { nounwind }
|
|
// CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
|
|
// CHECK:STDOUT: !llvm.dbg.cu = !{!2}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
|
|
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
|
|
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
|
// CHECK:STDOUT: !3 = !DIFile(filename: "with_cleanup.carbon", directory: "")
|
|
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
|
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
|
|
// CHECK:STDOUT: !6 = !{null}
|
|
// CHECK:STDOUT: !7 = !DILocation(line: 13, column: 6, scope: !4)
|
|
// CHECK:STDOUT: !8 = !DILocation(line: 16, column: 5, scope: !4)
|
|
// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 3, scope: !4)
|
|
// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 1, scope: !4)
|
|
// CHECK:STDOUT: !11 = distinct !DISubprogram(name: "Op", linkageName: "_COp.bb4015b09b4ec8d8:core.Destroy.Core", scope: null, file: !3, line: 13, type: !12, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
|
|
// CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
|
|
// CHECK:STDOUT: !13 = !{null, !14}
|
|
// CHECK:STDOUT: !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
|
// CHECK:STDOUT: !15 = !{!16}
|
|
// CHECK:STDOUT: !16 = !DILocalVariable(arg: 1, scope: !11, type: !14)
|
|
// CHECK:STDOUT: !17 = !DILocation(line: 13, column: 6, scope: !11)
|
|
// CHECK:STDOUT: ; ModuleID = 'struct_literal_cleanup.carbon'
|
|
// CHECK:STDOUT: source_filename = "struct_literal_cleanup.carbon"
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: @C.val.loc11 = internal constant {} zeroinitializer
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: declare void @"_COp.C.Main:Destroy.Core"(ptr)
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: declare void @_CF.Main(ptr)
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define void @_CG.Main() #0 !dbg !4 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !7
|
|
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !7
|
|
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc11, i64 0, i1 false), !dbg !7
|
|
// CHECK:STDOUT: call void @_CF.Main(ptr %c.var), !dbg !8
|
|
// CHECK:STDOUT: call void @"_COp.ad7e2d77f29afefe:core.Destroy.Core"(ptr %c.var), !dbg !7
|
|
// CHECK:STDOUT: ret void, !dbg !9
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nounwind
|
|
// CHECK:STDOUT: define weak_odr void @"_COp.ad7e2d77f29afefe:core.Destroy.Core"(ptr %self) #0 !dbg !10 {
|
|
// CHECK:STDOUT: entry:
|
|
// CHECK:STDOUT: ret void, !dbg !16
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
|
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
|
// CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #1
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: attributes #0 = { nounwind }
|
|
// CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
|
|
// CHECK:STDOUT: !llvm.dbg.cu = !{!2}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
|
|
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
|
|
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
|
// CHECK:STDOUT: !3 = !DIFile(filename: "struct_literal_cleanup.carbon", directory: "")
|
|
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
|
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
|
|
// CHECK:STDOUT: !6 = !{null}
|
|
// CHECK:STDOUT: !7 = !DILocation(line: 11, column: 6, scope: !4)
|
|
// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4)
|
|
// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 1, scope: !4)
|
|
// CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Op", linkageName: "_COp.ad7e2d77f29afefe:core.Destroy.Core", scope: null, file: !3, line: 11, type: !11, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !14)
|
|
// CHECK:STDOUT: !11 = !DISubroutineType(types: !12)
|
|
// CHECK:STDOUT: !12 = !{null, !13}
|
|
// CHECK:STDOUT: !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
|
// CHECK:STDOUT: !14 = !{!15}
|
|
// CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !10, type: !13)
|
|
// CHECK:STDOUT: !16 = !DILocation(line: 11, column: 6, scope: !10)
|