multifile.carbon 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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: import_irs:
  28. // CHECK:STDOUT: ir0: {decl_id: inst<none>, is_export: false}
  29. // CHECK:STDOUT: ir1: {decl_id: inst<none>, is_export: false}
  30. // CHECK:STDOUT: import_ir_insts: {}
  31. // CHECK:STDOUT: name_scopes:
  32. // CHECK:STDOUT: name_scope0: {inst: inst14, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name0: inst15}}
  33. // CHECK:STDOUT: entity_names: {}
  34. // CHECK:STDOUT: functions:
  35. // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, call_params_id: inst_block_empty, body: [inst_block5]}
  36. // CHECK:STDOUT: classes: {}
  37. // CHECK:STDOUT: generics: {}
  38. // CHECK:STDOUT: specifics: {}
  39. // CHECK:STDOUT: struct_type_fields:
  40. // CHECK:STDOUT: struct_type_fields0: {}
  41. // CHECK:STDOUT: types:
  42. // CHECK:STDOUT: 'type(TypeType)':
  43. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  44. // CHECK:STDOUT: 'type(Error)':
  45. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  46. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  47. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  48. // CHECK:STDOUT: 'type(inst16)':
  49. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst17)}
  50. // CHECK:STDOUT: 'type(inst17)':
  51. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst17)}
  52. // CHECK:STDOUT: insts:
  53. // CHECK:STDOUT: inst14: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  54. // CHECK:STDOUT: inst15: {kind: FunctionDecl, arg0: function0, arg1: inst_block_empty, type: type(inst16)}
  55. // CHECK:STDOUT: inst16: {kind: FunctionType, arg0: function0, arg1: specific<none>, type: type(TypeType)}
  56. // CHECK:STDOUT: inst17: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  57. // CHECK:STDOUT: inst18: {kind: StructValue, arg0: inst_block_empty, type: type(inst16)}
  58. // CHECK:STDOUT: inst19: {kind: Return}
  59. // CHECK:STDOUT: constant_values:
  60. // CHECK:STDOUT: values:
  61. // CHECK:STDOUT: inst14: concrete_constant(inst14)
  62. // CHECK:STDOUT: inst15: concrete_constant(inst18)
  63. // CHECK:STDOUT: inst16: concrete_constant(inst16)
  64. // CHECK:STDOUT: inst17: concrete_constant(inst17)
  65. // CHECK:STDOUT: inst18: concrete_constant(inst18)
  66. // CHECK:STDOUT: symbolic_constants: {}
  67. // CHECK:STDOUT: inst_blocks:
  68. // CHECK:STDOUT: inst_block_empty: {}
  69. // CHECK:STDOUT: exports:
  70. // CHECK:STDOUT: 0: inst15
  71. // CHECK:STDOUT: imports: {}
  72. // CHECK:STDOUT: global_init: {}
  73. // CHECK:STDOUT: inst_block4: {}
  74. // CHECK:STDOUT: inst_block5:
  75. // CHECK:STDOUT: 0: inst19
  76. // CHECK:STDOUT: inst_block6:
  77. // CHECK:STDOUT: 0: inst14
  78. // CHECK:STDOUT: 1: inst15
  79. // CHECK:STDOUT: ...
  80. // CHECK:STDOUT: ---
  81. // CHECK:STDOUT: filename: b.carbon
  82. // CHECK:STDOUT: sem_ir:
  83. // CHECK:STDOUT: import_irs:
  84. // CHECK:STDOUT: ir0: {decl_id: inst<none>, is_export: false}
  85. // CHECK:STDOUT: ir1: {decl_id: inst<none>, is_export: false}
  86. // CHECK:STDOUT: ir2: {decl_id: inst15, is_export: false}
  87. // CHECK:STDOUT: import_ir_insts:
  88. // CHECK:STDOUT: import_ir_inst0: {ir_id: ir2, inst_id: inst15}
  89. // CHECK:STDOUT: import_ir_inst1: {ir_id: ir2, inst_id: inst15}
  90. // CHECK:STDOUT: name_scopes:
  91. // CHECK:STDOUT: name_scope0: {inst: inst14, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name1: inst16, name0: inst17}}
  92. // CHECK:STDOUT: name_scope1: {inst: inst16, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst22}}
  93. // CHECK:STDOUT: entity_names:
  94. // CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: -1, is_template: 0}
  95. // CHECK:STDOUT: functions:
  96. // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, call_params_id: inst_block_empty, body: [inst_block5]}
  97. // CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1}
  98. // CHECK:STDOUT: classes: {}
  99. // CHECK:STDOUT: generics: {}
  100. // CHECK:STDOUT: specifics: {}
  101. // CHECK:STDOUT: struct_type_fields:
  102. // CHECK:STDOUT: struct_type_fields0: {}
  103. // CHECK:STDOUT: types:
  104. // CHECK:STDOUT: 'type(TypeType)':
  105. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  106. // CHECK:STDOUT: 'type(Error)':
  107. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  108. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  109. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  110. // CHECK:STDOUT: 'type(inst18)':
  111. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst19)}
  112. // CHECK:STDOUT: 'type(inst19)':
  113. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst19)}
  114. // CHECK:STDOUT: 'type(inst24)':
  115. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst19)}
  116. // CHECK:STDOUT: insts:
  117. // CHECK:STDOUT: inst14: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  118. // CHECK:STDOUT: inst15: {kind: ImportDecl, arg0: name1}
  119. // CHECK:STDOUT: inst16: {kind: Namespace, arg0: name_scope1, arg1: inst15, type: type(inst(NamespaceType))}
  120. // CHECK:STDOUT: inst17: {kind: FunctionDecl, arg0: function0, arg1: inst_block_empty, type: type(inst18)}
  121. // CHECK:STDOUT: inst18: {kind: FunctionType, arg0: function0, arg1: specific<none>, type: type(TypeType)}
  122. // CHECK:STDOUT: inst19: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  123. // CHECK:STDOUT: inst20: {kind: StructValue, arg0: inst_block_empty, type: type(inst18)}
  124. // CHECK:STDOUT: inst21: {kind: NameRef, arg0: name1, arg1: inst16, type: type(inst(NamespaceType))}
  125. // CHECK:STDOUT: inst22: {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst24)}
  126. // CHECK:STDOUT: inst23: {kind: FunctionDecl, arg0: function1, arg1: inst_block_empty, type: type(inst24)}
  127. // CHECK:STDOUT: inst24: {kind: FunctionType, arg0: function1, arg1: specific<none>, type: type(TypeType)}
  128. // CHECK:STDOUT: inst25: {kind: StructValue, arg0: inst_block_empty, type: type(inst24)}
  129. // CHECK:STDOUT: inst26: {kind: NameRef, arg0: name1, arg1: inst22, type: type(inst24)}
  130. // CHECK:STDOUT: inst27: {kind: Call, arg0: inst26, arg1: inst_block_empty, type: type(inst19)}
  131. // CHECK:STDOUT: inst28: {kind: Return}
  132. // CHECK:STDOUT: constant_values:
  133. // CHECK:STDOUT: values:
  134. // CHECK:STDOUT: inst14: concrete_constant(inst14)
  135. // CHECK:STDOUT: inst16: concrete_constant(inst16)
  136. // CHECK:STDOUT: inst17: concrete_constant(inst20)
  137. // CHECK:STDOUT: inst18: concrete_constant(inst18)
  138. // CHECK:STDOUT: inst19: concrete_constant(inst19)
  139. // CHECK:STDOUT: inst20: concrete_constant(inst20)
  140. // CHECK:STDOUT: inst21: concrete_constant(inst16)
  141. // CHECK:STDOUT: inst22: concrete_constant(inst25)
  142. // CHECK:STDOUT: inst23: concrete_constant(inst25)
  143. // CHECK:STDOUT: inst24: concrete_constant(inst24)
  144. // CHECK:STDOUT: inst25: concrete_constant(inst25)
  145. // CHECK:STDOUT: inst26: concrete_constant(inst25)
  146. // CHECK:STDOUT: symbolic_constants: {}
  147. // CHECK:STDOUT: inst_blocks:
  148. // CHECK:STDOUT: inst_block_empty: {}
  149. // CHECK:STDOUT: exports:
  150. // CHECK:STDOUT: 0: inst17
  151. // CHECK:STDOUT: imports:
  152. // CHECK:STDOUT: 0: inst16
  153. // CHECK:STDOUT: 1: inst22
  154. // CHECK:STDOUT: 2: inst23
  155. // CHECK:STDOUT: global_init: {}
  156. // CHECK:STDOUT: inst_block4: {}
  157. // CHECK:STDOUT: inst_block5:
  158. // CHECK:STDOUT: 0: inst21
  159. // CHECK:STDOUT: 1: inst26
  160. // CHECK:STDOUT: 2: inst27
  161. // CHECK:STDOUT: 3: inst28
  162. // CHECK:STDOUT: inst_block6:
  163. // CHECK:STDOUT: 0: inst14
  164. // CHECK:STDOUT: 1: inst15
  165. // CHECK:STDOUT: 2: inst17
  166. // CHECK:STDOUT: ...