multifile_raw_ir.carbon 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. // ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-raw-sem-ir %s
  6. //
  7. // Check that raw IR dumping works as expected.
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/compile/multifile_raw_ir.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/compile/multifile_raw_ir.carbon
  14. // --- a.carbon
  15. package A;
  16. fn A() {}
  17. // --- b.carbon
  18. package B;
  19. import A;
  20. fn B() {
  21. A.A();
  22. }
  23. // CHECK:STDOUT: ---
  24. // CHECK:STDOUT: filename: a.carbon
  25. // CHECK:STDOUT: sem_ir:
  26. // CHECK:STDOUT: import_irs:
  27. // CHECK:STDOUT: ir0: {decl_id: inst<none>, is_export: false}
  28. // CHECK:STDOUT: import_ir_insts: {}
  29. // CHECK:STDOUT: name_scopes:
  30. // CHECK:STDOUT: name_scope0: {inst: inst14, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name0: inst15}}
  31. // CHECK:STDOUT: entity_names: {}
  32. // CHECK:STDOUT: functions:
  33. // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, call_params_id: inst_block_empty, body: [inst_block5]}
  34. // CHECK:STDOUT: classes: {}
  35. // CHECK:STDOUT: generics: {}
  36. // CHECK:STDOUT: specifics: {}
  37. // CHECK:STDOUT: struct_type_fields:
  38. // CHECK:STDOUT: struct_type_fields0: {}
  39. // CHECK:STDOUT: types:
  40. // CHECK:STDOUT: 'type(TypeType)':
  41. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  42. // CHECK:STDOUT: 'type(Error)':
  43. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  44. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  45. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  46. // CHECK:STDOUT: 'type(inst16)':
  47. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst17)}
  48. // CHECK:STDOUT: 'type(inst17)':
  49. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst17)}
  50. // CHECK:STDOUT: insts:
  51. // CHECK:STDOUT: inst14: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  52. // CHECK:STDOUT: inst15: {kind: FunctionDecl, arg0: function0, arg1: inst_block_empty, type: type(inst16)}
  53. // CHECK:STDOUT: inst16: {kind: FunctionType, arg0: function0, arg1: specific<none>, type: type(TypeType)}
  54. // CHECK:STDOUT: inst17: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  55. // CHECK:STDOUT: inst18: {kind: StructValue, arg0: inst_block_empty, type: type(inst16)}
  56. // CHECK:STDOUT: inst19: {kind: Return}
  57. // CHECK:STDOUT: constant_values:
  58. // CHECK:STDOUT: inst14: concrete_constant(inst14)
  59. // CHECK:STDOUT: inst15: concrete_constant(inst18)
  60. // CHECK:STDOUT: inst16: concrete_constant(inst16)
  61. // CHECK:STDOUT: inst17: concrete_constant(inst17)
  62. // CHECK:STDOUT: inst18: concrete_constant(inst18)
  63. // CHECK:STDOUT: symbolic_constants: {}
  64. // CHECK:STDOUT: inst_blocks:
  65. // CHECK:STDOUT: inst_block_empty: {}
  66. // CHECK:STDOUT: exports:
  67. // CHECK:STDOUT: 0: inst15
  68. // CHECK:STDOUT: import_refs: {}
  69. // CHECK:STDOUT: global_init: {}
  70. // CHECK:STDOUT: inst_block4: {}
  71. // CHECK:STDOUT: inst_block5:
  72. // CHECK:STDOUT: 0: inst19
  73. // CHECK:STDOUT: inst_block6:
  74. // CHECK:STDOUT: 0: inst14
  75. // CHECK:STDOUT: 1: inst15
  76. // CHECK:STDOUT: ...
  77. // CHECK:STDOUT: ---
  78. // CHECK:STDOUT: filename: b.carbon
  79. // CHECK:STDOUT: sem_ir:
  80. // CHECK:STDOUT: import_irs:
  81. // CHECK:STDOUT: ir0: {decl_id: inst<none>, is_export: false}
  82. // CHECK:STDOUT: ir1: {decl_id: inst15, is_export: false}
  83. // CHECK:STDOUT: import_ir_insts:
  84. // CHECK:STDOUT: import_ir_inst0: {ir_id: ir1, inst_id: inst15}
  85. // CHECK:STDOUT: import_ir_inst1: {ir_id: ir1, inst_id: inst15}
  86. // CHECK:STDOUT: name_scopes:
  87. // CHECK:STDOUT: name_scope0: {inst: inst14, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name1: inst16, name0: inst17}}
  88. // CHECK:STDOUT: name_scope1: {inst: inst16, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst22}}
  89. // CHECK:STDOUT: entity_names:
  90. // CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: -1, is_template: 0}
  91. // CHECK:STDOUT: functions:
  92. // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, call_params_id: inst_block_empty, body: [inst_block5]}
  93. // CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1}
  94. // CHECK:STDOUT: classes: {}
  95. // CHECK:STDOUT: generics: {}
  96. // CHECK:STDOUT: specifics: {}
  97. // CHECK:STDOUT: struct_type_fields:
  98. // CHECK:STDOUT: struct_type_fields0: {}
  99. // CHECK:STDOUT: types:
  100. // CHECK:STDOUT: 'type(TypeType)':
  101. // CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)}
  102. // CHECK:STDOUT: 'type(Error)':
  103. // CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)}
  104. // CHECK:STDOUT: 'type(inst(NamespaceType))':
  105. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))}
  106. // CHECK:STDOUT: 'type(inst18)':
  107. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst19)}
  108. // CHECK:STDOUT: 'type(inst19)':
  109. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst19)}
  110. // CHECK:STDOUT: 'type(inst24)':
  111. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst19)}
  112. // CHECK:STDOUT: insts:
  113. // CHECK:STDOUT: inst14: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  114. // CHECK:STDOUT: inst15: {kind: ImportDecl, arg0: name1}
  115. // CHECK:STDOUT: inst16: {kind: Namespace, arg0: name_scope1, arg1: inst15, type: type(inst(NamespaceType))}
  116. // CHECK:STDOUT: inst17: {kind: FunctionDecl, arg0: function0, arg1: inst_block_empty, type: type(inst18)}
  117. // CHECK:STDOUT: inst18: {kind: FunctionType, arg0: function0, arg1: specific<none>, type: type(TypeType)}
  118. // CHECK:STDOUT: inst19: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  119. // CHECK:STDOUT: inst20: {kind: StructValue, arg0: inst_block_empty, type: type(inst18)}
  120. // CHECK:STDOUT: inst21: {kind: NameRef, arg0: name1, arg1: inst16, type: type(inst(NamespaceType))}
  121. // CHECK:STDOUT: inst22: {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst24)}
  122. // CHECK:STDOUT: inst23: {kind: FunctionDecl, arg0: function1, arg1: inst_block_empty, type: type(inst24)}
  123. // CHECK:STDOUT: inst24: {kind: FunctionType, arg0: function1, arg1: specific<none>, type: type(TypeType)}
  124. // CHECK:STDOUT: inst25: {kind: StructValue, arg0: inst_block_empty, type: type(inst24)}
  125. // CHECK:STDOUT: inst26: {kind: NameRef, arg0: name1, arg1: inst22, type: type(inst24)}
  126. // CHECK:STDOUT: inst27: {kind: Call, arg0: inst26, arg1: inst_block_empty, type: type(inst19)}
  127. // CHECK:STDOUT: inst28: {kind: Return}
  128. // CHECK:STDOUT: constant_values:
  129. // CHECK:STDOUT: inst14: concrete_constant(inst14)
  130. // CHECK:STDOUT: inst16: concrete_constant(inst16)
  131. // CHECK:STDOUT: inst17: concrete_constant(inst20)
  132. // CHECK:STDOUT: inst18: concrete_constant(inst18)
  133. // CHECK:STDOUT: inst19: concrete_constant(inst19)
  134. // CHECK:STDOUT: inst20: concrete_constant(inst20)
  135. // CHECK:STDOUT: inst21: concrete_constant(inst16)
  136. // CHECK:STDOUT: inst22: concrete_constant(inst25)
  137. // CHECK:STDOUT: inst23: concrete_constant(inst25)
  138. // CHECK:STDOUT: inst24: concrete_constant(inst24)
  139. // CHECK:STDOUT: inst25: concrete_constant(inst25)
  140. // CHECK:STDOUT: inst26: concrete_constant(inst25)
  141. // CHECK:STDOUT: symbolic_constants: {}
  142. // CHECK:STDOUT: inst_blocks:
  143. // CHECK:STDOUT: inst_block_empty: {}
  144. // CHECK:STDOUT: exports:
  145. // CHECK:STDOUT: 0: inst17
  146. // CHECK:STDOUT: import_refs:
  147. // CHECK:STDOUT: 0: inst16
  148. // CHECK:STDOUT: 1: inst22
  149. // CHECK:STDOUT: global_init: {}
  150. // CHECK:STDOUT: inst_block4: {}
  151. // CHECK:STDOUT: inst_block5:
  152. // CHECK:STDOUT: 0: inst21
  153. // CHECK:STDOUT: 1: inst26
  154. // CHECK:STDOUT: 2: inst27
  155. // CHECK:STDOUT: 3: inst28
  156. // CHECK:STDOUT: inst_block6:
  157. // CHECK:STDOUT: 0: inst14
  158. // CHECK:STDOUT: 1: inst15
  159. // CHECK:STDOUT: 2: inst17
  160. // CHECK:STDOUT: ...