multifile.carbon 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. // EXTRA-ARGS: --dump-raw-sem-ir --no-dump-sem-ir
  7. //
  8. // Check that raw IR dumping works as expected.
  9. //
  10. // AUTOUPDATE
  11. // TIP: To test this file alone, run:
  12. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon
  13. // TIP: To dump output, run:
  14. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon
  15. // --- a.carbon
  16. package A;
  17. fn A() {}
  18. // --- b.carbon
  19. package B;
  20. import A;
  21. fn B() {
  22. A.A();
  23. }
  24. // CHECK:STDOUT: ---
  25. // CHECK:STDOUT: filename: a.carbon
  26. // CHECK:STDOUT: sem_ir:
  27. // CHECK:STDOUT: names:
  28. // CHECK:STDOUT: name0: A
  29. // CHECK:STDOUT: import_irs:
  30. // CHECK:STDOUT: 'import_ir(ApiForImpl)': {decl_id: inst<none>, is_export: false}
  31. // CHECK:STDOUT: 'import_ir(Cpp)': {decl_id: inst<none>, is_export: false}
  32. // CHECK:STDOUT: import_ir_insts: {}
  33. // CHECK:STDOUT: clang_decls: {}
  34. // CHECK:STDOUT: name_scopes:
  35. // CHECK:STDOUT: name_scope0: {inst: instF, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name0: inst50000010}}
  36. // CHECK:STDOUT: entity_names: {}
  37. // CHECK:STDOUT: cpp_global_vars: {}
  38. // CHECK:STDOUT: functions:
  39. // CHECK:STDOUT: function50000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block_empty, call_params_id: inst_block_empty, body: [inst_block50000006]}
  40. // CHECK:STDOUT: classes: {}
  41. // CHECK:STDOUT: interfaces: {}
  42. // CHECK:STDOUT: associated_constants: {}
  43. // CHECK:STDOUT: impls: {}
  44. // CHECK:STDOUT: generics: {}
  45. // CHECK:STDOUT: specifics: {}
  46. // CHECK:STDOUT: specific_interfaces: {}
  47. // CHECK:STDOUT: struct_type_fields:
  48. // CHECK:STDOUT: struct_type_fields_empty: {}
  49. // CHECK:STDOUT: types:
  50. // CHECK:STDOUT: 'type(TypeType)':
  51. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  52. // CHECK:STDOUT: 'type(inst(FormType))':
  53. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(FormType))}
  54. // CHECK:STDOUT: 'type(Error)':
  55. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  56. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  57. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  58. // CHECK:STDOUT: 'type(inst50000011)':
  59. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst50000012)}
  60. // CHECK:STDOUT: 'type(inst50000012)':
  61. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst50000012)}
  62. // CHECK:STDOUT: facet_types: {}
  63. // CHECK:STDOUT: insts:
  64. // CHECK:STDOUT: instF: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  65. // CHECK:STDOUT: inst50000010: {kind: FunctionDecl, arg0: function50000000, arg1: inst_block_empty, type: type(inst50000011)}
  66. // CHECK:STDOUT: inst50000011: {kind: FunctionType, arg0: function50000000, arg1: specific<none>, type: type(TypeType)}
  67. // CHECK:STDOUT: inst50000012: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  68. // CHECK:STDOUT: inst50000013: {kind: StructValue, arg0: inst_block_empty, type: type(inst50000011)}
  69. // CHECK:STDOUT: inst50000014: {kind: Return}
  70. // CHECK:STDOUT: constant_values:
  71. // CHECK:STDOUT: values:
  72. // CHECK:STDOUT: instF: concrete_constant(instF)
  73. // CHECK:STDOUT: inst50000010: concrete_constant(inst50000013)
  74. // CHECK:STDOUT: inst50000011: concrete_constant(inst50000011)
  75. // CHECK:STDOUT: inst50000012: concrete_constant(inst50000012)
  76. // CHECK:STDOUT: inst50000013: concrete_constant(inst50000013)
  77. // CHECK:STDOUT: symbolic_constants: {}
  78. // CHECK:STDOUT: inst_blocks:
  79. // CHECK:STDOUT: inst_block_empty: {}
  80. // CHECK:STDOUT: exports:
  81. // CHECK:STDOUT: 0: inst50000010
  82. // CHECK:STDOUT: generated: {}
  83. // CHECK:STDOUT: imports: {}
  84. // CHECK:STDOUT: global_init: {}
  85. // CHECK:STDOUT: inst_block50000005: {}
  86. // CHECK:STDOUT: inst_block50000006:
  87. // CHECK:STDOUT: 0: inst50000014
  88. // CHECK:STDOUT: inst_block50000007:
  89. // CHECK:STDOUT: 0: instF
  90. // CHECK:STDOUT: 1: inst50000010
  91. // CHECK:STDOUT: value_stores:
  92. // CHECK:STDOUT: shared_values:
  93. // CHECK:STDOUT: ints: {}
  94. // CHECK:STDOUT: reals: {}
  95. // CHECK:STDOUT: floats: {}
  96. // CHECK:STDOUT: identifiers:
  97. // CHECK:STDOUT: identifier0: A
  98. // CHECK:STDOUT: strings: {}
  99. // CHECK:STDOUT: ...
  100. // CHECK:STDOUT: ---
  101. // CHECK:STDOUT: filename: b.carbon
  102. // CHECK:STDOUT: sem_ir:
  103. // CHECK:STDOUT: names:
  104. // CHECK:STDOUT: name0: B
  105. // CHECK:STDOUT: name1: A
  106. // CHECK:STDOUT: import_irs:
  107. // CHECK:STDOUT: 'import_ir(ApiForImpl)': {decl_id: inst<none>, is_export: false}
  108. // CHECK:STDOUT: 'import_ir(Cpp)': {decl_id: inst<none>, is_export: false}
  109. // CHECK:STDOUT: import_ir70000002: {decl_id: inst70000010, is_export: false}
  110. // CHECK:STDOUT: import_ir_insts:
  111. // CHECK:STDOUT: import_ir_inst0: {ir_id: import_ir70000002, inst_id: inst50000010}
  112. // CHECK:STDOUT: import_ir_inst1: {ir_id: import_ir70000002, inst_id: inst50000010}
  113. // CHECK:STDOUT: clang_decls: {}
  114. // CHECK:STDOUT: name_scopes:
  115. // CHECK:STDOUT: name_scope0: {inst: instF, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name1: inst70000011, name0: inst70000012}}
  116. // CHECK:STDOUT: name_scope70000001: {inst: inst70000011, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst70000017}}
  117. // CHECK:STDOUT: entity_names:
  118. // CHECK:STDOUT: entity_name70000000: {name: name1, parent_scope: name_scope70000001, index: -1, is_template: 0, is_unused: 0, form: constant<none>}
  119. // CHECK:STDOUT: cpp_global_vars: {}
  120. // CHECK:STDOUT: functions:
  121. // CHECK:STDOUT: function70000000: {name: name0, parent_scope: name_scope0, call_param_patterns_id: inst_block_empty, call_params_id: inst_block_empty, body: [inst_block70000006]}
  122. // CHECK:STDOUT: function70000001: {name: name1, parent_scope: name_scope70000001, call_param_patterns_id: inst_block_empty}
  123. // CHECK:STDOUT: classes: {}
  124. // CHECK:STDOUT: interfaces: {}
  125. // CHECK:STDOUT: associated_constants: {}
  126. // CHECK:STDOUT: impls: {}
  127. // CHECK:STDOUT: generics: {}
  128. // CHECK:STDOUT: specifics: {}
  129. // CHECK:STDOUT: specific_interfaces: {}
  130. // CHECK:STDOUT: struct_type_fields:
  131. // CHECK:STDOUT: struct_type_fields_empty: {}
  132. // CHECK:STDOUT: types:
  133. // CHECK:STDOUT: 'type(TypeType)':
  134. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  135. // CHECK:STDOUT: 'type(inst(FormType))':
  136. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(FormType))}
  137. // CHECK:STDOUT: 'type(Error)':
  138. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  139. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  140. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  141. // CHECK:STDOUT: 'type(inst70000013)':
  142. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst70000014)}
  143. // CHECK:STDOUT: 'type(inst70000014)':
  144. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst70000014)}
  145. // CHECK:STDOUT: 'type(inst(InstType))':
  146. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst70000014)}
  147. // CHECK:STDOUT: facet_types: {}
  148. // CHECK:STDOUT: insts:
  149. // CHECK:STDOUT: instF: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  150. // CHECK:STDOUT: inst70000010: {kind: ImportDecl, arg0: name1}
  151. // CHECK:STDOUT: inst70000011: {kind: Namespace, arg0: name_scope70000001, arg1: inst70000010, type: type(inst(NamespaceType))}
  152. // CHECK:STDOUT: inst70000012: {kind: FunctionDecl, arg0: function70000000, arg1: inst_block_empty, type: type(inst70000013)}
  153. // CHECK:STDOUT: inst70000013: {kind: FunctionType, arg0: function70000000, arg1: specific<none>, type: type(TypeType)}
  154. // CHECK:STDOUT: inst70000014: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  155. // CHECK:STDOUT: inst70000015: {kind: StructValue, arg0: inst_block_empty, type: type(inst70000013)}
  156. // CHECK:STDOUT: inst70000016: {kind: NameRef, arg0: name1, arg1: inst70000011, type: type(inst(NamespaceType))}
  157. // CHECK:STDOUT: inst70000017: {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name70000000, type: type(inst70000019)}
  158. // CHECK:STDOUT: inst70000018: {kind: FunctionDecl, arg0: function70000001, arg1: inst_block_empty, type: type(inst70000019)}
  159. // CHECK:STDOUT: inst70000019: {kind: FunctionType, arg0: function70000001, arg1: specific<none>, type: type(TypeType)}
  160. // CHECK:STDOUT: inst7000001A: {kind: StructValue, arg0: inst_block_empty, type: type(inst70000019)}
  161. // CHECK:STDOUT: inst7000001B: {kind: NameRef, arg0: name1, arg1: inst70000017, type: type(inst70000019)}
  162. // CHECK:STDOUT: inst7000001C: {kind: Call, arg0: inst7000001B, arg1: inst_block_empty, type: type(inst70000014)}
  163. // CHECK:STDOUT: inst7000001D: {kind: Return}
  164. // CHECK:STDOUT: constant_values:
  165. // CHECK:STDOUT: values:
  166. // CHECK:STDOUT: instF: concrete_constant(instF)
  167. // CHECK:STDOUT: inst70000011: concrete_constant(inst70000011)
  168. // CHECK:STDOUT: inst70000012: concrete_constant(inst70000015)
  169. // CHECK:STDOUT: inst70000013: concrete_constant(inst70000013)
  170. // CHECK:STDOUT: inst70000014: concrete_constant(inst70000014)
  171. // CHECK:STDOUT: inst70000015: concrete_constant(inst70000015)
  172. // CHECK:STDOUT: inst70000016: concrete_constant(inst70000011)
  173. // CHECK:STDOUT: inst70000017: concrete_constant(inst7000001A)
  174. // CHECK:STDOUT: inst70000018: concrete_constant(inst7000001A)
  175. // CHECK:STDOUT: inst70000019: concrete_constant(inst70000019)
  176. // CHECK:STDOUT: inst7000001A: concrete_constant(inst7000001A)
  177. // CHECK:STDOUT: inst7000001B: concrete_constant(inst7000001A)
  178. // CHECK:STDOUT: symbolic_constants: {}
  179. // CHECK:STDOUT: inst_blocks:
  180. // CHECK:STDOUT: inst_block_empty: {}
  181. // CHECK:STDOUT: exports:
  182. // CHECK:STDOUT: 0: inst70000012
  183. // CHECK:STDOUT: generated: {}
  184. // CHECK:STDOUT: imports:
  185. // CHECK:STDOUT: 0: inst70000011
  186. // CHECK:STDOUT: 1: inst70000017
  187. // CHECK:STDOUT: 2: inst70000018
  188. // CHECK:STDOUT: global_init: {}
  189. // CHECK:STDOUT: inst_block70000005: {}
  190. // CHECK:STDOUT: inst_block70000006:
  191. // CHECK:STDOUT: 0: inst70000016
  192. // CHECK:STDOUT: 1: inst7000001B
  193. // CHECK:STDOUT: 2: inst7000001C
  194. // CHECK:STDOUT: 3: inst7000001D
  195. // CHECK:STDOUT: inst_block70000007:
  196. // CHECK:STDOUT: 0: instF
  197. // CHECK:STDOUT: 1: inst70000010
  198. // CHECK:STDOUT: 2: inst70000012
  199. // CHECK:STDOUT: value_stores:
  200. // CHECK:STDOUT: shared_values:
  201. // CHECK:STDOUT: ints: {}
  202. // CHECK:STDOUT: reals: {}
  203. // CHECK:STDOUT: floats: {}
  204. // CHECK:STDOUT: identifiers:
  205. // CHECK:STDOUT: identifier0: B
  206. // CHECK:STDOUT: identifier1: A
  207. // CHECK:STDOUT: strings: {}
  208. // CHECK:STDOUT: ...