export_name.carbon 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 "base";
  15. interface I {}
  16. // --- export.carbon
  17. library "export";
  18. import library "base";
  19. export I;
  20. // ============================================================================
  21. // Test files
  22. // ============================================================================
  23. // --- use_export.carbon
  24. library "use_export";
  25. import library "export";
  26. fn UseEmpty(i: I) {}
  27. // CHECK:STDOUT: --- base.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  31. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .I = %I.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {}
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: interface @I {
  42. // CHECK:STDOUT: %Self: %.1 = 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: %.1: type = interface_type @I [template]
  53. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  58. // CHECK:STDOUT: .I = %I
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%.1]
  61. // CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+3, unloaded
  62. // CHECK:STDOUT: %I: type = export I, %import_ref.1 [template = constants.%.1]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: interface @I {
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = file.%import_ref.2
  68. // CHECK:STDOUT: witness = ()
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: --- use_export.carbon
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: constants {
  74. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  75. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic]
  76. // CHECK:STDOUT: %UseEmpty.type: type = fn_type @UseEmpty [template]
  77. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  78. // CHECK:STDOUT: %UseEmpty: %UseEmpty.type = struct_value () [template]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: file {
  82. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  83. // CHECK:STDOUT: .I = %import_ref.1
  84. // CHECK:STDOUT: .UseEmpty = %UseEmpty.decl
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+6, loaded [template = constants.%.1]
  87. // CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+5, unloaded
  88. // CHECK:STDOUT: %UseEmpty.decl: %UseEmpty.type = fn_decl @UseEmpty [template = constants.%UseEmpty] {
  89. // CHECK:STDOUT: %I.ref: type = name_ref I, %import_ref.1 [template = constants.%.1]
  90. // CHECK:STDOUT: %i.loc6_13.1: %.1 = param i
  91. // CHECK:STDOUT: @UseEmpty.%i: %.1 = bind_name i, %i.loc6_13.1
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: interface @I {
  96. // CHECK:STDOUT: !members:
  97. // CHECK:STDOUT: .Self = file.%import_ref.2
  98. // CHECK:STDOUT: witness = ()
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: fn @UseEmpty(%i: %.1) {
  102. // CHECK:STDOUT: !entry:
  103. // CHECK:STDOUT: return
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: