imported.carbon 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. // --- implicit.carbon
  7. package Implicit api;
  8. namespace NS;
  9. namespace NS.ChildNS;
  10. fn NS.A();
  11. fn NS.ChildNS.B();
  12. // --- implicit.impl.carbon
  13. package Implicit impl;
  14. var a: () = NS.A();
  15. var b: () = NS.ChildNS.B();
  16. var package_a: () = package.NS.A();
  17. var package_b: () = package.NS.ChildNS.B();
  18. // CHECK:STDOUT: --- implicit.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %A: type = fn_type @A [template]
  22. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  23. // CHECK:STDOUT: %struct.1: A = struct_value () [template]
  24. // CHECK:STDOUT: %B: type = fn_type @B [template]
  25. // CHECK:STDOUT: %struct.2: B = struct_value () [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = %Core
  31. // CHECK:STDOUT: .NS = %NS
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  34. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .ChildNS = %ChildNS
  36. // CHECK:STDOUT: .A = %A.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %ChildNS: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .B = %B.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %A.decl: A = fn_decl @A [template = constants.%struct.1] {}
  42. // CHECK:STDOUT: %B.decl: B = fn_decl @B [template = constants.%struct.2] {}
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: fn @A();
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @B();
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: --- implicit.impl.carbon
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: constants {
  52. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  53. // CHECK:STDOUT: %A: type = fn_type @A [template]
  54. // CHECK:STDOUT: %struct.1: A = struct_value () [template]
  55. // CHECK:STDOUT: %B: type = fn_type @B [template]
  56. // CHECK:STDOUT: %struct.2: B = struct_value () [template]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: file {
  60. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  61. // CHECK:STDOUT: .NS = %NS
  62. // CHECK:STDOUT: .Core = %Core
  63. // CHECK:STDOUT: .a = %a
  64. // CHECK:STDOUT: .b = %b
  65. // CHECK:STDOUT: .package_a = %package_a
  66. // CHECK:STDOUT: .package_b = %package_b
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %import_ref.1: <namespace> = import_ref ir0, inst+2, loaded
  69. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.1, [template] {
  70. // CHECK:STDOUT: .ChildNS = %ChildNS
  71. // CHECK:STDOUT: .A = %import_ref.3
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %import_ref.2: <namespace> = import_ref ir0, inst+3, loaded
  74. // CHECK:STDOUT: %ChildNS: <namespace> = namespace %import_ref.2, [template] {
  75. // CHECK:STDOUT: .B = %import_ref.4
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %import_ref.3: A = import_ref ir0, inst+4, loaded [template = constants.%struct.1]
  78. // CHECK:STDOUT: %import_ref.4: B = import_ref ir0, inst+8, loaded [template = constants.%struct.2]
  79. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  80. // CHECK:STDOUT: %.loc4_9.1: () = tuple_literal ()
  81. // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1]
  82. // CHECK:STDOUT: %a.var: ref () = var a
  83. // CHECK:STDOUT: %a: ref () = bind_name a, %a.var
  84. // CHECK:STDOUT: %.loc5_9.1: () = tuple_literal ()
  85. // CHECK:STDOUT: %.loc5_9.2: type = converted %.loc5_9.1, constants.%.1 [template = constants.%.1]
  86. // CHECK:STDOUT: %b.var: ref () = var b
  87. // CHECK:STDOUT: %b: ref () = bind_name b, %b.var
  88. // CHECK:STDOUT: %.loc7_17.1: () = tuple_literal ()
  89. // CHECK:STDOUT: %.loc7_17.2: type = converted %.loc7_17.1, constants.%.1 [template = constants.%.1]
  90. // CHECK:STDOUT: %package_a.var: ref () = var package_a
  91. // CHECK:STDOUT: %package_a: ref () = bind_name package_a, %package_a.var
  92. // CHECK:STDOUT: %.loc8_17.1: () = tuple_literal ()
  93. // CHECK:STDOUT: %.loc8_17.2: type = converted %.loc8_17.1, constants.%.1 [template = constants.%.1]
  94. // CHECK:STDOUT: %package_b.var: ref () = var package_b
  95. // CHECK:STDOUT: %package_b: ref () = bind_name package_b, %package_b.var
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: fn @A();
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: fn @B();
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: fn @__global_init() {
  103. // CHECK:STDOUT: !entry:
  104. // CHECK:STDOUT: %NS.ref.loc4: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  105. // CHECK:STDOUT: %A.ref.loc4: A = name_ref A, file.%import_ref.3 [template = constants.%struct.1]
  106. // CHECK:STDOUT: %A.call.loc4: init () = call %A.ref.loc4()
  107. // CHECK:STDOUT: assign file.%a.var, %A.call.loc4
  108. // CHECK:STDOUT: %NS.ref.loc5: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  109. // CHECK:STDOUT: %ChildNS.ref.loc5: <namespace> = name_ref ChildNS, file.%ChildNS [template = file.%ChildNS]
  110. // CHECK:STDOUT: %B.ref.loc5: B = name_ref B, file.%import_ref.4 [template = constants.%struct.2]
  111. // CHECK:STDOUT: %B.call.loc5: init () = call %B.ref.loc5()
  112. // CHECK:STDOUT: assign file.%b.var, %B.call.loc5
  113. // CHECK:STDOUT: %package.ref.loc7: <namespace> = name_ref package, package [template = package]
  114. // CHECK:STDOUT: %NS.ref.loc7: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  115. // CHECK:STDOUT: %A.ref.loc7: A = name_ref A, file.%import_ref.3 [template = constants.%struct.1]
  116. // CHECK:STDOUT: %A.call.loc7: init () = call %A.ref.loc7()
  117. // CHECK:STDOUT: assign file.%package_a.var, %A.call.loc7
  118. // CHECK:STDOUT: %package.ref.loc8: <namespace> = name_ref package, package [template = package]
  119. // CHECK:STDOUT: %NS.ref.loc8: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  120. // CHECK:STDOUT: %ChildNS.ref.loc8: <namespace> = name_ref ChildNS, file.%ChildNS [template = file.%ChildNS]
  121. // CHECK:STDOUT: %B.ref.loc8: B = name_ref B, file.%import_ref.4 [template = constants.%struct.2]
  122. // CHECK:STDOUT: %B.call.loc8: init () = call %B.ref.loc8()
  123. // CHECK:STDOUT: assign file.%package_b.var, %B.call.loc8
  124. // CHECK:STDOUT: return
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: