merging.carbon 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. // --- a.carbon
  7. package Example library "a" api;
  8. namespace NS;
  9. fn NS.A() {}
  10. // --- b.carbon
  11. package Example library "b" api;
  12. namespace NS;
  13. fn NS.B1() {}
  14. namespace NS;
  15. fn NS.B2() {}
  16. // --- c.carbon
  17. package Example library "c" api;
  18. import library "a";
  19. import library "b";
  20. namespace NS;
  21. fn NS.C() {}
  22. fn Run() {
  23. NS.A();
  24. NS.B1();
  25. NS.B2();
  26. NS.C();
  27. }
  28. // CHECK:STDOUT: --- a.carbon
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: constants {
  31. // CHECK:STDOUT: %A: type = fn_type @A [template]
  32. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  33. // CHECK:STDOUT: %struct: A = struct_value () [template]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = %Core
  39. // CHECK:STDOUT: .NS = %NS
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  42. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .A = %A.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %A.decl: A = fn_decl @A [template = constants.%struct] {}
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @A() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: return
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: --- b.carbon
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: constants {
  56. // CHECK:STDOUT: %B1: type = fn_type @B1 [template]
  57. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  58. // CHECK:STDOUT: %struct.1: B1 = struct_value () [template]
  59. // CHECK:STDOUT: %B2: type = fn_type @B2 [template]
  60. // CHECK:STDOUT: %struct.2: B2 = struct_value () [template]
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: file {
  64. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  65. // CHECK:STDOUT: .Core = %Core
  66. // CHECK:STDOUT: .NS = %NS
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  69. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  70. // CHECK:STDOUT: .B1 = %B1.decl
  71. // CHECK:STDOUT: .B2 = %B2.decl
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %B1.decl: B1 = fn_decl @B1 [template = constants.%struct.1] {}
  74. // CHECK:STDOUT: %.loc8: <namespace> = namespace [template] {}
  75. // CHECK:STDOUT: %B2.decl: B2 = fn_decl @B2 [template = constants.%struct.2] {}
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: fn @B1() {
  79. // CHECK:STDOUT: !entry:
  80. // CHECK:STDOUT: return
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: fn @B2() {
  84. // CHECK:STDOUT: !entry:
  85. // CHECK:STDOUT: return
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: --- c.carbon
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: constants {
  91. // CHECK:STDOUT: %C: type = fn_type @C [template]
  92. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  93. // CHECK:STDOUT: %struct.1: C = struct_value () [template]
  94. // CHECK:STDOUT: %Run: type = fn_type @Run [template]
  95. // CHECK:STDOUT: %struct.2: Run = struct_value () [template]
  96. // CHECK:STDOUT: %A: type = fn_type @A [template]
  97. // CHECK:STDOUT: %struct.3: A = struct_value () [template]
  98. // CHECK:STDOUT: %B1: type = fn_type @B1 [template]
  99. // CHECK:STDOUT: %struct.4: B1 = struct_value () [template]
  100. // CHECK:STDOUT: %B2: type = fn_type @B2 [template]
  101. // CHECK:STDOUT: %struct.5: B2 = struct_value () [template]
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: file {
  105. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  106. // CHECK:STDOUT: .NS = %NS
  107. // CHECK:STDOUT: .Core = %Core
  108. // CHECK:STDOUT: .Run = %Run.decl
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %import_ref.1: <namespace> = import_ref ir1, inst+2, loaded
  111. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.1, [template] {
  112. // CHECK:STDOUT: .A = %import_ref.2
  113. // CHECK:STDOUT: .B1 = %import_ref.3
  114. // CHECK:STDOUT: .B2 = %import_ref.4
  115. // CHECK:STDOUT: .C = %C.decl
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: %import_ref.2: A = import_ref ir1, inst+3, loaded [template = constants.%struct.3]
  118. // CHECK:STDOUT: %import_ref.3: B1 = import_ref ir2, inst+3, loaded [template = constants.%struct.4]
  119. // CHECK:STDOUT: %import_ref.4: B2 = import_ref ir2, inst+9, loaded [template = constants.%struct.5]
  120. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  121. // CHECK:STDOUT: %.loc7: <namespace> = namespace [template] {}
  122. // CHECK:STDOUT: %C.decl: C = fn_decl @C [template = constants.%struct.1] {}
  123. // CHECK:STDOUT: %Run.decl: Run = fn_decl @Run [template = constants.%struct.2] {}
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: fn @C() {
  127. // CHECK:STDOUT: !entry:
  128. // CHECK:STDOUT: return
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: fn @Run() {
  132. // CHECK:STDOUT: !entry:
  133. // CHECK:STDOUT: %NS.ref.loc12: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  134. // CHECK:STDOUT: %A.ref: A = name_ref A, file.%import_ref.2 [template = constants.%struct.3]
  135. // CHECK:STDOUT: %A.call: init () = call %A.ref()
  136. // CHECK:STDOUT: %NS.ref.loc13: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  137. // CHECK:STDOUT: %B1.ref: B1 = name_ref B1, file.%import_ref.3 [template = constants.%struct.4]
  138. // CHECK:STDOUT: %B1.call: init () = call %B1.ref()
  139. // CHECK:STDOUT: %NS.ref.loc14: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  140. // CHECK:STDOUT: %B2.ref: B2 = name_ref B2, file.%import_ref.4 [template = constants.%struct.5]
  141. // CHECK:STDOUT: %B2.call: init () = call %B2.ref()
  142. // CHECK:STDOUT: %NS.ref.loc15: <namespace> = name_ref NS, file.%NS [template = file.%NS]
  143. // CHECK:STDOUT: %C.ref: C = name_ref C, file.%C.decl [template = constants.%struct.1]
  144. // CHECK:STDOUT: %C.call: init () = call %C.ref()
  145. // CHECK:STDOUT: return
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: fn @A();
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: fn @B1();
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: fn @B2();
  153. // CHECK:STDOUT: