cross_package_call.carbon 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/packages/cross_package_call.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/packages/cross_package_call.carbon
  10. // --- a.carbon
  11. package A;
  12. namespace NS;
  13. fn NS.F() {}
  14. fn NS.G(x: i32) -> i32 { return x; }
  15. // --- b.carbon
  16. import A;
  17. fn F() { A.NS.F(); }
  18. fn G() -> i32 { return A.NS.G(1); }
  19. // CHECK:STDOUT: ; ModuleID = 'a.carbon'
  20. // CHECK:STDOUT: source_filename = "a.carbon"
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: define void @_CF.NS.A() !dbg !4 {
  23. // CHECK:STDOUT: entry:
  24. // CHECK:STDOUT: ret void, !dbg !7
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: define i32 @_CG.NS.A(i32 %x) !dbg !8 {
  28. // CHECK:STDOUT: entry:
  29. // CHECK:STDOUT: ret i32 %x, !dbg !9
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  33. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  36. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  37. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  38. // CHECK:STDOUT: !3 = !DIFile(filename: "a.carbon", directory: "")
  39. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.NS.A", scope: null, file: !3, line: 5, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  40. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  41. // CHECK:STDOUT: !6 = !{}
  42. // CHECK:STDOUT: !7 = !DILocation(line: 5, column: 1, scope: !4)
  43. // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", linkageName: "_CG.NS.A", scope: null, file: !3, line: 7, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  44. // CHECK:STDOUT: !9 = !DILocation(line: 7, column: 26, scope: !8)
  45. // CHECK:STDOUT: ; ModuleID = 'b.carbon'
  46. // CHECK:STDOUT: source_filename = "b.carbon"
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: define void @_CF.Main() !dbg !4 {
  49. // CHECK:STDOUT: entry:
  50. // CHECK:STDOUT: call void @_CF.NS.A(), !dbg !7
  51. // CHECK:STDOUT: ret void, !dbg !8
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: declare void @_CF.NS.A()
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: define i32 @_CG.Main() !dbg !9 {
  57. // CHECK:STDOUT: entry:
  58. // CHECK:STDOUT: %G.call = call i32 @_CG.NS.A(i32 1), !dbg !10
  59. // CHECK:STDOUT: ret i32 %G.call, !dbg !11
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: declare i32 @_CG.NS.A(i32)
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  65. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  68. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  69. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  70. // CHECK:STDOUT: !3 = !DIFile(filename: "b.carbon", directory: "")
  71. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  72. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  73. // CHECK:STDOUT: !6 = !{}
  74. // CHECK:STDOUT: !7 = !DILocation(line: 4, column: 10, scope: !4)
  75. // CHECK:STDOUT: !8 = !DILocation(line: 4, column: 1, scope: !4)
  76. // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 6, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  77. // CHECK:STDOUT: !10 = !DILocation(line: 6, column: 24, scope: !9)
  78. // CHECK:STDOUT: !11 = !DILocation(line: 6, column: 17, scope: !9)