multifile.carbon 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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: 'import_ir(ApiForImpl)': {decl_id: inst<none>, is_export: false}
  29. // CHECK:STDOUT: 'import_ir(Cpp)': {decl_id: inst<none>, is_export: false}
  30. // CHECK:STDOUT: import_ir_insts: {}
  31. // CHECK:STDOUT: clang_decls: {}
  32. // CHECK:STDOUT: name_scopes:
  33. // CHECK:STDOUT: name_scope0: {inst: instE, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name0: inst6000000F}}
  34. // CHECK:STDOUT: entity_names: {}
  35. // CHECK:STDOUT: cpp_global_vars: {}
  36. // CHECK:STDOUT: functions:
  37. // CHECK:STDOUT: function60000000: {name: name0, parent_scope: name_scope0, call_params_id: inst_block_empty, body: [inst_block60000005]}
  38. // CHECK:STDOUT: classes: {}
  39. // CHECK:STDOUT: generics: {}
  40. // CHECK:STDOUT: specifics: {}
  41. // CHECK:STDOUT: struct_type_fields:
  42. // CHECK:STDOUT: struct_type_fields0: {}
  43. // CHECK:STDOUT: types:
  44. // CHECK:STDOUT: 'type(TypeType)':
  45. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  46. // CHECK:STDOUT: 'type(Error)':
  47. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  48. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  49. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  50. // CHECK:STDOUT: 'type(inst60000010)':
  51. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst60000011)}
  52. // CHECK:STDOUT: 'type(inst60000011)':
  53. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst60000011)}
  54. // CHECK:STDOUT: insts:
  55. // CHECK:STDOUT: instE: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  56. // CHECK:STDOUT: inst6000000F: {kind: FunctionDecl, arg0: function60000000, arg1: inst_block_empty, type: type(inst60000010)}
  57. // CHECK:STDOUT: inst60000010: {kind: FunctionType, arg0: function60000000, arg1: specific<none>, type: type(TypeType)}
  58. // CHECK:STDOUT: inst60000011: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  59. // CHECK:STDOUT: inst60000012: {kind: StructValue, arg0: inst_block_empty, type: type(inst60000010)}
  60. // CHECK:STDOUT: inst60000013: {kind: Return}
  61. // CHECK:STDOUT: constant_values:
  62. // CHECK:STDOUT: values:
  63. // CHECK:STDOUT: instE: concrete_constant(instE)
  64. // CHECK:STDOUT: inst6000000F: concrete_constant(inst60000012)
  65. // CHECK:STDOUT: inst60000010: concrete_constant(inst60000010)
  66. // CHECK:STDOUT: inst60000011: concrete_constant(inst60000011)
  67. // CHECK:STDOUT: inst60000012: concrete_constant(inst60000012)
  68. // CHECK:STDOUT: symbolic_constants: {}
  69. // CHECK:STDOUT: inst_blocks:
  70. // CHECK:STDOUT: inst_block_empty: {}
  71. // CHECK:STDOUT: exports:
  72. // CHECK:STDOUT: 0: inst6000000F
  73. // CHECK:STDOUT: imports: {}
  74. // CHECK:STDOUT: global_init: {}
  75. // CHECK:STDOUT: inst_block60000004: {}
  76. // CHECK:STDOUT: inst_block60000005:
  77. // CHECK:STDOUT: 0: inst60000013
  78. // CHECK:STDOUT: inst_block60000006:
  79. // CHECK:STDOUT: 0: instE
  80. // CHECK:STDOUT: 1: inst6000000F
  81. // CHECK:STDOUT: ...
  82. // CHECK:STDOUT: ---
  83. // CHECK:STDOUT: filename: b.carbon
  84. // CHECK:STDOUT: sem_ir:
  85. // CHECK:STDOUT: import_irs:
  86. // CHECK:STDOUT: 'import_ir(ApiForImpl)': {decl_id: inst<none>, is_export: false}
  87. // CHECK:STDOUT: 'import_ir(Cpp)': {decl_id: inst<none>, is_export: false}
  88. // CHECK:STDOUT: import_ir50000002: {decl_id: inst5000000F, is_export: false}
  89. // CHECK:STDOUT: import_ir_insts:
  90. // CHECK:STDOUT: import_ir_inst0: {ir_id: import_ir50000002, inst_id: inst6000000F}
  91. // CHECK:STDOUT: import_ir_inst1: {ir_id: import_ir50000002, inst_id: inst6000000F}
  92. // CHECK:STDOUT: clang_decls: {}
  93. // CHECK:STDOUT: name_scopes:
  94. // CHECK:STDOUT: name_scope0: {inst: instE, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name1: inst50000010, name0: inst50000011}}
  95. // CHECK:STDOUT: name_scope50000001: {inst: inst50000010, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst50000016}}
  96. // CHECK:STDOUT: entity_names:
  97. // CHECK:STDOUT: entity_name50000000: {name: name1, parent_scope: name_scope50000001, index: -1, is_template: 0}
  98. // CHECK:STDOUT: cpp_global_vars: {}
  99. // CHECK:STDOUT: functions:
  100. // CHECK:STDOUT: function50000000: {name: name0, parent_scope: name_scope0, call_params_id: inst_block_empty, body: [inst_block50000005]}
  101. // CHECK:STDOUT: function50000001: {name: name1, parent_scope: name_scope50000001}
  102. // CHECK:STDOUT: classes: {}
  103. // CHECK:STDOUT: generics: {}
  104. // CHECK:STDOUT: specifics: {}
  105. // CHECK:STDOUT: struct_type_fields:
  106. // CHECK:STDOUT: struct_type_fields0: {}
  107. // CHECK:STDOUT: types:
  108. // CHECK:STDOUT: 'type(TypeType)':
  109. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  110. // CHECK:STDOUT: 'type(Error)':
  111. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  112. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  113. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  114. // CHECK:STDOUT: 'type(inst50000012)':
  115. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst50000013)}
  116. // CHECK:STDOUT: 'type(inst50000013)':
  117. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst50000013)}
  118. // CHECK:STDOUT: 'type(inst(InstType))':
  119. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst50000013)}
  120. // CHECK:STDOUT: insts:
  121. // CHECK:STDOUT: instE: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  122. // CHECK:STDOUT: inst5000000F: {kind: ImportDecl, arg0: name1}
  123. // CHECK:STDOUT: inst50000010: {kind: Namespace, arg0: name_scope50000001, arg1: inst5000000F, type: type(inst(NamespaceType))}
  124. // CHECK:STDOUT: inst50000011: {kind: FunctionDecl, arg0: function50000000, arg1: inst_block_empty, type: type(inst50000012)}
  125. // CHECK:STDOUT: inst50000012: {kind: FunctionType, arg0: function50000000, arg1: specific<none>, type: type(TypeType)}
  126. // CHECK:STDOUT: inst50000013: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  127. // CHECK:STDOUT: inst50000014: {kind: StructValue, arg0: inst_block_empty, type: type(inst50000012)}
  128. // CHECK:STDOUT: inst50000015: {kind: NameRef, arg0: name1, arg1: inst50000010, type: type(inst(NamespaceType))}
  129. // CHECK:STDOUT: inst50000016: {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name50000000, type: type(inst50000018)}
  130. // CHECK:STDOUT: inst50000017: {kind: FunctionDecl, arg0: function50000001, arg1: inst_block_empty, type: type(inst50000018)}
  131. // CHECK:STDOUT: inst50000018: {kind: FunctionType, arg0: function50000001, arg1: specific<none>, type: type(TypeType)}
  132. // CHECK:STDOUT: inst50000019: {kind: StructValue, arg0: inst_block_empty, type: type(inst50000018)}
  133. // CHECK:STDOUT: inst5000001A: {kind: NameRef, arg0: name1, arg1: inst50000016, type: type(inst50000018)}
  134. // CHECK:STDOUT: inst5000001B: {kind: Call, arg0: inst5000001A, arg1: inst_block_empty, type: type(inst50000013)}
  135. // CHECK:STDOUT: inst5000001C: {kind: Return}
  136. // CHECK:STDOUT: constant_values:
  137. // CHECK:STDOUT: values:
  138. // CHECK:STDOUT: instE: concrete_constant(instE)
  139. // CHECK:STDOUT: inst50000010: concrete_constant(inst50000010)
  140. // CHECK:STDOUT: inst50000011: concrete_constant(inst50000014)
  141. // CHECK:STDOUT: inst50000012: concrete_constant(inst50000012)
  142. // CHECK:STDOUT: inst50000013: concrete_constant(inst50000013)
  143. // CHECK:STDOUT: inst50000014: concrete_constant(inst50000014)
  144. // CHECK:STDOUT: inst50000015: concrete_constant(inst50000010)
  145. // CHECK:STDOUT: inst50000016: concrete_constant(inst50000019)
  146. // CHECK:STDOUT: inst50000017: concrete_constant(inst50000019)
  147. // CHECK:STDOUT: inst50000018: concrete_constant(inst50000018)
  148. // CHECK:STDOUT: inst50000019: concrete_constant(inst50000019)
  149. // CHECK:STDOUT: inst5000001A: concrete_constant(inst50000019)
  150. // CHECK:STDOUT: symbolic_constants: {}
  151. // CHECK:STDOUT: inst_blocks:
  152. // CHECK:STDOUT: inst_block_empty: {}
  153. // CHECK:STDOUT: exports:
  154. // CHECK:STDOUT: 0: inst50000011
  155. // CHECK:STDOUT: imports:
  156. // CHECK:STDOUT: 0: inst50000010
  157. // CHECK:STDOUT: 1: inst50000016
  158. // CHECK:STDOUT: 2: inst50000017
  159. // CHECK:STDOUT: global_init: {}
  160. // CHECK:STDOUT: inst_block50000004: {}
  161. // CHECK:STDOUT: inst_block50000005:
  162. // CHECK:STDOUT: 0: inst50000015
  163. // CHECK:STDOUT: 1: inst5000001A
  164. // CHECK:STDOUT: 2: inst5000001B
  165. // CHECK:STDOUT: 3: inst5000001C
  166. // CHECK:STDOUT: inst_block50000006:
  167. // CHECK:STDOUT: 0: instE
  168. // CHECK:STDOUT: 1: inst5000000F
  169. // CHECK:STDOUT: 2: inst50000011
  170. // CHECK:STDOUT: ...