export_name.carbon 4.5 KB

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