multifile_raw_ir.carbon 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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: 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/check/testdata/basics/no_prelude/multifile_raw_ir.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/no_prelude/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<invalid>, is_export: false}
  28. // CHECK:STDOUT: import_ir_insts: {}
  29. // CHECK:STDOUT: name_scopes:
  30. // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+1}}
  31. // CHECK:STDOUT: entity_names: {}
  32. // CHECK:STDOUT: functions:
  33. // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [block4]}
  34. // CHECK:STDOUT: classes: {}
  35. // CHECK:STDOUT: generics: {}
  36. // CHECK:STDOUT: specifics: {}
  37. // CHECK:STDOUT: types:
  38. // CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType}
  39. // CHECK:STDOUT: typeError: {kind: copy, type: typeError}
  40. // CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)}
  41. // CHECK:STDOUT: 'type(inst+2)': {kind: none, type: type(inst+3)}
  42. // CHECK:STDOUT: 'type(inst+3)': {kind: none, type: type(inst+3)}
  43. // CHECK:STDOUT: type_blocks:
  44. // CHECK:STDOUT: type_block0: {}
  45. // CHECK:STDOUT: insts:
  46. // CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst<invalid>, type: type(instNamespaceType)}
  47. // CHECK:STDOUT: 'inst+1': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type(inst+2)}
  48. // CHECK:STDOUT: 'inst+2': {kind: FunctionType, arg0: function0, arg1: specific<invalid>, type: typeTypeType}
  49. // CHECK:STDOUT: 'inst+3': {kind: TupleType, arg0: type_block0, type: typeTypeType}
  50. // CHECK:STDOUT: 'inst+4': {kind: StructValue, arg0: empty, type: type(inst+2)}
  51. // CHECK:STDOUT: 'inst+5': {kind: Return}
  52. // CHECK:STDOUT: constant_values:
  53. // CHECK:STDOUT: 'inst+0': templateConstant(inst+0)
  54. // CHECK:STDOUT: 'inst+1': templateConstant(inst+4)
  55. // CHECK:STDOUT: 'inst+2': templateConstant(inst+2)
  56. // CHECK:STDOUT: 'inst+3': templateConstant(inst+3)
  57. // CHECK:STDOUT: 'inst+4': templateConstant(inst+4)
  58. // CHECK:STDOUT: symbolic_constants: {}
  59. // CHECK:STDOUT: inst_blocks:
  60. // CHECK:STDOUT: empty: {}
  61. // CHECK:STDOUT: exports:
  62. // CHECK:STDOUT: 0: inst+1
  63. // CHECK:STDOUT: import_refs: {}
  64. // CHECK:STDOUT: global_init: {}
  65. // CHECK:STDOUT: block4:
  66. // CHECK:STDOUT: 0: inst+5
  67. // CHECK:STDOUT: block5:
  68. // CHECK:STDOUT: 0: inst+0
  69. // CHECK:STDOUT: 1: inst+1
  70. // CHECK:STDOUT: ...
  71. // CHECK:STDOUT: ---
  72. // CHECK:STDOUT: filename: b.carbon
  73. // CHECK:STDOUT: sem_ir:
  74. // CHECK:STDOUT: import_irs:
  75. // CHECK:STDOUT: ir0: {decl_id: inst<invalid>, is_export: false}
  76. // CHECK:STDOUT: ir1: {decl_id: inst+1, is_export: false}
  77. // CHECK:STDOUT: import_ir_insts:
  78. // CHECK:STDOUT: import_ir_inst0: {ir_id: ir1, inst_id: inst+1}
  79. // CHECK:STDOUT: import_ir_inst1: {ir_id: ir1, inst_id: inst+1}
  80. // CHECK:STDOUT: name_scopes:
  81. // CHECK:STDOUT: name_scope0: {inst: inst+0, parent_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name1: inst+2, name0: inst+3}}
  82. // CHECK:STDOUT: name_scope1: {inst: inst+2, parent_scope: name_scope0, has_error: false, extended_scopes: [], names: {name1: inst+8}}
  83. // CHECK:STDOUT: entity_names:
  84. // CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope1, index: comp_time_bind<invalid>}
  85. // CHECK:STDOUT: functions:
  86. // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, body: [block4]}
  87. // CHECK:STDOUT: function1: {name: name1, parent_scope: name_scope1}
  88. // CHECK:STDOUT: classes: {}
  89. // CHECK:STDOUT: generics: {}
  90. // CHECK:STDOUT: specifics: {}
  91. // CHECK:STDOUT: types:
  92. // CHECK:STDOUT: typeTypeType: {kind: copy, type: typeTypeType}
  93. // CHECK:STDOUT: typeError: {kind: copy, type: typeError}
  94. // CHECK:STDOUT: 'type(instNamespaceType)': {kind: copy, type: type(instNamespaceType)}
  95. // CHECK:STDOUT: 'type(inst+4)': {kind: none, type: type(inst+5)}
  96. // CHECK:STDOUT: 'type(inst+5)': {kind: none, type: type(inst+5)}
  97. // CHECK:STDOUT: 'type(inst+10)': {kind: none, type: type(inst+5)}
  98. // CHECK:STDOUT: type_blocks:
  99. // CHECK:STDOUT: type_block0: {}
  100. // CHECK:STDOUT: insts:
  101. // CHECK:STDOUT: 'inst+0': {kind: Namespace, arg0: name_scope0, arg1: inst<invalid>, type: type(instNamespaceType)}
  102. // CHECK:STDOUT: 'inst+1': {kind: ImportDecl, arg0: name1}
  103. // CHECK:STDOUT: 'inst+2': {kind: Namespace, arg0: name_scope1, arg1: inst+1, type: type(instNamespaceType)}
  104. // CHECK:STDOUT: 'inst+3': {kind: FunctionDecl, arg0: function0, arg1: empty, type: type(inst+4)}
  105. // CHECK:STDOUT: 'inst+4': {kind: FunctionType, arg0: function0, arg1: specific<invalid>, type: typeTypeType}
  106. // CHECK:STDOUT: 'inst+5': {kind: TupleType, arg0: type_block0, type: typeTypeType}
  107. // CHECK:STDOUT: 'inst+6': {kind: StructValue, arg0: empty, type: type(inst+4)}
  108. // CHECK:STDOUT: 'inst+7': {kind: NameRef, arg0: name1, arg1: inst+2, type: type(instNamespaceType)}
  109. // CHECK:STDOUT: 'inst+8': {kind: ImportRefLoaded, arg0: import_ir_inst0, arg1: entity_name0, type: type(inst+10)}
  110. // CHECK:STDOUT: 'inst+9': {kind: FunctionDecl, arg0: function1, arg1: empty, type: type(inst+10)}
  111. // CHECK:STDOUT: 'inst+10': {kind: FunctionType, arg0: function1, arg1: specific<invalid>, type: typeTypeType}
  112. // CHECK:STDOUT: 'inst+11': {kind: StructValue, arg0: empty, type: type(inst+10)}
  113. // CHECK:STDOUT: 'inst+12': {kind: NameRef, arg0: name1, arg1: inst+8, type: type(inst+10)}
  114. // CHECK:STDOUT: 'inst+13': {kind: Call, arg0: inst+12, arg1: empty, type: type(inst+5)}
  115. // CHECK:STDOUT: 'inst+14': {kind: Return}
  116. // CHECK:STDOUT: constant_values:
  117. // CHECK:STDOUT: 'inst+0': templateConstant(inst+0)
  118. // CHECK:STDOUT: 'inst+2': templateConstant(inst+2)
  119. // CHECK:STDOUT: 'inst+3': templateConstant(inst+6)
  120. // CHECK:STDOUT: 'inst+4': templateConstant(inst+4)
  121. // CHECK:STDOUT: 'inst+5': templateConstant(inst+5)
  122. // CHECK:STDOUT: 'inst+6': templateConstant(inst+6)
  123. // CHECK:STDOUT: 'inst+7': templateConstant(inst+2)
  124. // CHECK:STDOUT: 'inst+8': templateConstant(inst+11)
  125. // CHECK:STDOUT: 'inst+9': templateConstant(inst+11)
  126. // CHECK:STDOUT: 'inst+10': templateConstant(inst+10)
  127. // CHECK:STDOUT: 'inst+11': templateConstant(inst+11)
  128. // CHECK:STDOUT: 'inst+12': templateConstant(inst+11)
  129. // CHECK:STDOUT: symbolic_constants: {}
  130. // CHECK:STDOUT: inst_blocks:
  131. // CHECK:STDOUT: empty: {}
  132. // CHECK:STDOUT: exports:
  133. // CHECK:STDOUT: 0: inst+3
  134. // CHECK:STDOUT: import_refs:
  135. // CHECK:STDOUT: 0: inst+2
  136. // CHECK:STDOUT: 1: inst+8
  137. // CHECK:STDOUT: global_init: {}
  138. // CHECK:STDOUT: block4:
  139. // CHECK:STDOUT: 0: inst+7
  140. // CHECK:STDOUT: 1: inst+12
  141. // CHECK:STDOUT: 2: inst+13
  142. // CHECK:STDOUT: 3: inst+14
  143. // CHECK:STDOUT: block5:
  144. // CHECK:STDOUT: 0: inst+0
  145. // CHECK:STDOUT: 1: inst+1
  146. // CHECK:STDOUT: 2: inst+3
  147. // CHECK:STDOUT: ...