imported_package_mangle.carbon 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/packages/imported_package_mangle.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/packages/imported_package_mangle.carbon
  12. // --- a.carbon
  13. package A;
  14. class C {}
  15. interface I {
  16. fn F() {}
  17. }
  18. impl array(C, 1) as I {
  19. fn F() {}
  20. }
  21. // --- b.carbon
  22. package B;
  23. import A;
  24. fn G() {
  25. // This causes a declaration of `A._CF` which should have the same name
  26. // mangling across both files.
  27. // TODO: At present this still doesn't mangle consistently (`064474b8d2c44cac`
  28. // vs `a858cd05051f8b61`).
  29. (array(A.C, 1) as A.I).F();
  30. }
  31. // CHECK:STDOUT: ; ModuleID = 'a.carbon'
  32. // CHECK:STDOUT: source_filename = "a.carbon"
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: ; Function Attrs: nounwind
  35. // CHECK:STDOUT: define void @"_CF.064474b8d2c44cac:I.A"() #0 !dbg !4 {
  36. // CHECK:STDOUT: entry:
  37. // CHECK:STDOUT: ret void, !dbg !7
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: attributes #0 = { nounwind }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  43. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  46. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  47. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  48. // CHECK:STDOUT: !3 = !DIFile(filename: "a.carbon", directory: "")
  49. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.064474b8d2c44cac:I.A", scope: null, file: !3, line: 10, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  50. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  51. // CHECK:STDOUT: !6 = !{null}
  52. // CHECK:STDOUT: !7 = !DILocation(line: 10, column: 3, scope: !4)
  53. // CHECK:STDOUT: ; ModuleID = 'b.carbon'
  54. // CHECK:STDOUT: source_filename = "b.carbon"
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: ; Function Attrs: nounwind
  57. // CHECK:STDOUT: define void @_CG.B() #0 !dbg !4 {
  58. // CHECK:STDOUT: entry:
  59. // CHECK:STDOUT: call void @"_CF.a858cd05051f8b61:I.A"(), !dbg !7
  60. // CHECK:STDOUT: ret void, !dbg !8
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: declare void @"_CF.a858cd05051f8b61:I.A"()
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: attributes #0 = { nounwind }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  68. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  71. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  72. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  73. // CHECK:STDOUT: !3 = !DIFile(filename: "b.carbon", directory: "")
  74. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.B", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  75. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  76. // CHECK:STDOUT: !6 = !{null}
  77. // CHECK:STDOUT: !7 = !DILocation(line: 9, column: 3, scope: !4)
  78. // CHECK:STDOUT: !8 = !DILocation(line: 4, column: 1, scope: !4)