multifile_raw_ir.carbon 8.6 KB

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