export_name.carbon 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/export_name.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/export_name.carbon
  14. // ============================================================================
  15. // Setup files
  16. // ============================================================================
  17. // --- base.carbon
  18. library "[[@TEST_NAME]]";
  19. interface I {}
  20. // --- export.carbon
  21. library "[[@TEST_NAME]]";
  22. import library "base";
  23. export I;
  24. // ============================================================================
  25. // Test files
  26. // ============================================================================
  27. // --- use_export.carbon
  28. library "[[@TEST_NAME]]";
  29. import library "export";
  30. fn UseEmpty(i: I) {}
  31. // CHECK:STDOUT: --- base.carbon
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: constants {
  34. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  35. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  40. // CHECK:STDOUT: .I = %I.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: interface @I {
  46. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: !members:
  49. // CHECK:STDOUT: .Self = %Self
  50. // CHECK:STDOUT: witness = ()
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: --- export.carbon
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: constants {
  56. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: imports {
  60. // CHECK:STDOUT: %Main.I: type = import_ref Main//base, I, loaded [concrete = constants.%I.type]
  61. // CHECK:STDOUT: %Main.import_ref = import_ref Main//base, inst17 [no loc], unloaded
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: file {
  65. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  66. // CHECK:STDOUT: .I = %I
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %default.import = import <none>
  69. // CHECK:STDOUT: %I: type = export I, imports.%Main.I [concrete = constants.%I.type]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: interface @I [from "base.carbon"] {
  73. // CHECK:STDOUT: !members:
  74. // CHECK:STDOUT: .Self = imports.%Main.import_ref
  75. // CHECK:STDOUT: witness = ()
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: --- use_export.carbon
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: constants {
  81. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  82. // CHECK:STDOUT: %pattern_type: type = pattern_type %I.type [concrete]
  83. // CHECK:STDOUT: %UseEmpty.type: type = fn_type @UseEmpty [concrete]
  84. // CHECK:STDOUT: %UseEmpty: %UseEmpty.type = struct_value () [concrete]
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: imports {
  88. // CHECK:STDOUT: %Main.I: type = import_ref Main//export, I, loaded [concrete = constants.%I.type]
  89. // CHECK:STDOUT: %Main.import_ref = import_ref Main//export, inst20 [indirect], unloaded
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: file {
  93. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  94. // CHECK:STDOUT: .I = imports.%Main.I
  95. // CHECK:STDOUT: .UseEmpty = %UseEmpty.decl
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT: %default.import = import <none>
  98. // CHECK:STDOUT: %UseEmpty.decl: %UseEmpty.type = fn_decl @UseEmpty [concrete = constants.%UseEmpty] {
  99. // CHECK:STDOUT: %i.patt: %pattern_type = binding_pattern i [concrete]
  100. // CHECK:STDOUT: %i.param_patt: %pattern_type = value_param_pattern %i.patt, call_param0 [concrete]
  101. // CHECK:STDOUT: } {
  102. // CHECK:STDOUT: %i.param: %I.type = value_param call_param0
  103. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  104. // CHECK:STDOUT: %i: %I.type = bind_name i, %i.param
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: interface @I [from "export.carbon"] {
  109. // CHECK:STDOUT: !members:
  110. // CHECK:STDOUT: .Self = imports.%Main.import_ref
  111. // CHECK:STDOUT: witness = ()
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: fn @UseEmpty(%i.param: %I.type) {
  115. // CHECK:STDOUT: !entry:
  116. // CHECK:STDOUT: return
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT: