one_file.carbon 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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/one_file.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/one_file.carbon
  15. fn Foo[T:! type](n: T) -> (T, ()) {
  16. return (n, ());
  17. }
  18. // CHECK:STDOUT: ---
  19. // CHECK:STDOUT: filename: one_file.carbon
  20. // CHECK:STDOUT: sem_ir:
  21. // CHECK:STDOUT: import_irs:
  22. // CHECK:STDOUT: ir0: {decl_id: inst<none>, is_export: false}
  23. // CHECK:STDOUT: ir1: {decl_id: inst<none>, is_export: false}
  24. // CHECK:STDOUT: import_ir_insts: {}
  25. // CHECK:STDOUT: name_scopes:
  26. // CHECK:STDOUT: name_scope0: {inst: inst15, parent_scope: name_scope<none>, has_error: false, extended_scopes: [], names: {name0: inst43}}
  27. // CHECK:STDOUT: entity_names:
  28. // CHECK:STDOUT: entity_name0: {name: name1, parent_scope: name_scope<none>, index: 0, is_template: 0}
  29. // CHECK:STDOUT: entity_name1: {name: name2, parent_scope: name_scope<none>, index: -1, is_template: 0}
  30. // CHECK:STDOUT: functions:
  31. // CHECK:STDOUT: function0: {name: name0, parent_scope: name_scope0, call_params_id: inst_block13, return_slot_pattern: inst39, body: [inst_block20]}
  32. // CHECK:STDOUT: classes: {}
  33. // CHECK:STDOUT: generics:
  34. // CHECK:STDOUT: generic0: {decl: inst43, bindings: inst_block16}
  35. // CHECK:STDOUT: specifics:
  36. // CHECK:STDOUT: specific0: {generic: generic0, args: inst_block17}
  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(inst44)':
  47. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst28)}
  48. // CHECK:STDOUT: 'type(inst28)':
  49. // CHECK:STDOUT: value_repr: {kind: none, type: type(inst28)}
  50. // CHECK:STDOUT: 'type(symbolic_constant0)':
  51. // CHECK:STDOUT: value_repr: {kind: copy, type: type(symbolic_constant0)}
  52. // CHECK:STDOUT: 'type(symbolic_constant4)':
  53. // CHECK:STDOUT: value_repr: {kind: pointer, type: type(symbolic_constant8)}
  54. // CHECK:STDOUT: 'type(symbolic_constant8)':
  55. // CHECK:STDOUT: value_repr: {kind: copy, type: type(symbolic_constant8)}
  56. // CHECK:STDOUT: 'type(inst(WitnessType))':
  57. // CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(WitnessType))}
  58. // CHECK:STDOUT: 'type(symbolic_constant1)':
  59. // CHECK:STDOUT: value_repr: {kind: copy, type: type(symbolic_constant1)}
  60. // CHECK:STDOUT: 'type(symbolic_constant5)':
  61. // CHECK:STDOUT: value_repr: {kind: pointer, type: type(symbolic_constant8)}
  62. // CHECK:STDOUT: insts:
  63. // CHECK:STDOUT: inst15: {kind: Namespace, arg0: name_scope0, arg1: inst<none>, type: type(inst(NamespaceType))}
  64. // CHECK:STDOUT: inst16: {kind: BindSymbolicName, arg0: entity_name0, arg1: inst<none>, type: type(TypeType)}
  65. // CHECK:STDOUT: inst17: {kind: BindSymbolicName, arg0: entity_name0, arg1: inst<none>, type: type(TypeType)}
  66. // CHECK:STDOUT: inst18: {kind: BindSymbolicName, arg0: entity_name0, arg1: inst<none>, type: type(TypeType)}
  67. // CHECK:STDOUT: inst19: {kind: PatternType, arg0: inst(TypeType), type: type(TypeType)}
  68. // CHECK:STDOUT: inst20: {kind: SymbolicBindingPattern, arg0: entity_name0, type: type(inst19)}
  69. // CHECK:STDOUT: inst21: {kind: NameRef, arg0: name1, arg1: inst16, type: type(TypeType)}
  70. // CHECK:STDOUT: inst22: {kind: BindName, arg0: entity_name1, arg1: inst40, type: type(symbolic_constant1)}
  71. // CHECK:STDOUT: inst23: {kind: PatternType, arg0: inst17, type: type(TypeType)}
  72. // CHECK:STDOUT: inst24: {kind: BindingPattern, arg0: entity_name1, type: type(symbolic_constant3)}
  73. // CHECK:STDOUT: inst25: {kind: PatternType, arg0: inst18, type: type(TypeType)}
  74. // CHECK:STDOUT: inst26: {kind: ValueParamPattern, arg0: inst24, arg1: call_param0, type: type(symbolic_constant3)}
  75. // CHECK:STDOUT: inst27: {kind: NameRef, arg0: name1, arg1: inst16, type: type(TypeType)}
  76. // CHECK:STDOUT: inst28: {kind: TupleType, arg0: inst_block_empty, type: type(TypeType)}
  77. // CHECK:STDOUT: inst29: {kind: TupleLiteral, arg0: inst_block_empty, type: type(inst28)}
  78. // CHECK:STDOUT: inst30: {kind: TupleType, arg0: inst_block9, type: type(TypeType)}
  79. // CHECK:STDOUT: inst31: {kind: TupleLiteral, arg0: inst_block8, type: type(inst30)}
  80. // CHECK:STDOUT: inst32: {kind: Converted, arg0: inst29, arg1: inst28, type: type(TypeType)}
  81. // CHECK:STDOUT: inst33: {kind: TupleType, arg0: inst_block11, type: type(TypeType)}
  82. // CHECK:STDOUT: inst34: {kind: Converted, arg0: inst31, arg1: inst33, type: type(TypeType)}
  83. // CHECK:STDOUT: inst35: {kind: TupleType, arg0: inst_block12, type: type(TypeType)}
  84. // CHECK:STDOUT: inst36: {kind: PatternType, arg0: inst33, type: type(TypeType)}
  85. // CHECK:STDOUT: inst37: {kind: ReturnSlotPattern, arg0: inst34, type: type(symbolic_constant7)}
  86. // CHECK:STDOUT: inst38: {kind: PatternType, arg0: inst35, type: type(TypeType)}
  87. // CHECK:STDOUT: inst39: {kind: OutParamPattern, arg0: inst37, arg1: call_param1, type: type(symbolic_constant7)}
  88. // CHECK:STDOUT: inst40: {kind: ValueParam, arg0: call_param0, arg1: name2, type: type(symbolic_constant1)}
  89. // CHECK:STDOUT: inst41: {kind: OutParam, arg0: call_param1, arg1: name(ReturnSlot), type: type(symbolic_constant5)}
  90. // CHECK:STDOUT: inst42: {kind: ReturnSlot, arg0: inst33, arg1: inst41, type: type(symbolic_constant5)}
  91. // CHECK:STDOUT: inst43: {kind: FunctionDecl, arg0: function0, arg1: inst_block15, type: type(inst44)}
  92. // CHECK:STDOUT: inst44: {kind: FunctionType, arg0: function0, arg1: specific<none>, type: type(TypeType)}
  93. // CHECK:STDOUT: inst45: {kind: StructValue, arg0: inst_block_empty, type: type(inst44)}
  94. // CHECK:STDOUT: inst46: {kind: PointerType, arg0: inst33, type: type(TypeType)}
  95. // CHECK:STDOUT: inst47: {kind: RequireCompleteType, arg0: inst33, type: type(inst(WitnessType))}
  96. // CHECK:STDOUT: inst48: {kind: RequireCompleteType, arg0: inst33, type: type(inst(WitnessType))}
  97. // CHECK:STDOUT: inst49: {kind: RequireCompleteType, arg0: inst35, type: type(inst(WitnessType))}
  98. // CHECK:STDOUT: inst50: {kind: RequireCompleteType, arg0: inst17, type: type(inst(WitnessType))}
  99. // CHECK:STDOUT: inst51: {kind: RequireCompleteType, arg0: inst17, type: type(inst(WitnessType))}
  100. // CHECK:STDOUT: inst52: {kind: RequireCompleteType, arg0: inst18, type: type(inst(WitnessType))}
  101. // CHECK:STDOUT: inst53: {kind: NameRef, arg0: name2, arg1: inst22, type: type(symbolic_constant1)}
  102. // CHECK:STDOUT: inst54: {kind: TupleLiteral, arg0: inst_block_empty, type: type(inst28)}
  103. // CHECK:STDOUT: inst55: {kind: TupleLiteral, arg0: inst_block21, type: type(symbolic_constant5)}
  104. // CHECK:STDOUT: inst56: {kind: RequireCompleteType, arg0: inst33, type: type(inst(WitnessType))}
  105. // CHECK:STDOUT: inst57: {kind: TupleAccess, arg0: inst42, arg1: element0, type: type(symbolic_constant1)}
  106. // CHECK:STDOUT: inst58: {kind: RequireCompleteType, arg0: inst17, type: type(inst(WitnessType))}
  107. // CHECK:STDOUT: inst59: {kind: InitializeFrom, arg0: inst53, arg1: inst57, type: type(symbolic_constant1)}
  108. // CHECK:STDOUT: inst60: {kind: TupleAccess, arg0: inst42, arg1: element1, type: type(inst28)}
  109. // CHECK:STDOUT: inst61: {kind: TupleInit, arg0: inst_block_empty, arg1: inst60, type: type(inst28)}
  110. // CHECK:STDOUT: inst62: {kind: TupleValue, arg0: inst_block_empty, type: type(inst28)}
  111. // CHECK:STDOUT: inst63: {kind: Converted, arg0: inst54, arg1: inst61, type: type(inst28)}
  112. // CHECK:STDOUT: inst64: {kind: TupleInit, arg0: inst_block22, arg1: inst42, type: type(symbolic_constant5)}
  113. // CHECK:STDOUT: inst65: {kind: Converted, arg0: inst55, arg1: inst64, type: type(symbolic_constant5)}
  114. // CHECK:STDOUT: inst66: {kind: ReturnExpr, arg0: inst65, arg1: inst42}
  115. // CHECK:STDOUT: constant_values:
  116. // CHECK:STDOUT: values:
  117. // CHECK:STDOUT: inst15: concrete_constant(inst15)
  118. // CHECK:STDOUT: inst16: symbolic_constant1
  119. // CHECK:STDOUT: inst17: symbolic_constant0
  120. // CHECK:STDOUT: inst18: symbolic_constant1
  121. // CHECK:STDOUT: inst19: concrete_constant(inst19)
  122. // CHECK:STDOUT: inst20: concrete_constant(inst20)
  123. // CHECK:STDOUT: inst21: symbolic_constant1
  124. // CHECK:STDOUT: inst23: symbolic_constant2
  125. // CHECK:STDOUT: inst24: concrete_constant(inst24)
  126. // CHECK:STDOUT: inst25: symbolic_constant3
  127. // CHECK:STDOUT: inst26: concrete_constant(inst26)
  128. // CHECK:STDOUT: inst27: symbolic_constant1
  129. // CHECK:STDOUT: inst28: concrete_constant(inst28)
  130. // CHECK:STDOUT: inst30: concrete_constant(inst30)
  131. // CHECK:STDOUT: inst32: concrete_constant(inst28)
  132. // CHECK:STDOUT: inst33: symbolic_constant4
  133. // CHECK:STDOUT: inst34: symbolic_constant5
  134. // CHECK:STDOUT: inst35: symbolic_constant5
  135. // CHECK:STDOUT: inst36: symbolic_constant6
  136. // CHECK:STDOUT: inst37: concrete_constant(inst37)
  137. // CHECK:STDOUT: inst38: symbolic_constant7
  138. // CHECK:STDOUT: inst39: concrete_constant(inst39)
  139. // CHECK:STDOUT: inst43: concrete_constant(inst45)
  140. // CHECK:STDOUT: inst44: concrete_constant(inst44)
  141. // CHECK:STDOUT: inst45: concrete_constant(inst45)
  142. // CHECK:STDOUT: inst46: symbolic_constant8
  143. // CHECK:STDOUT: inst47: symbolic_constant10
  144. // CHECK:STDOUT: inst48: symbolic_constant9
  145. // CHECK:STDOUT: inst49: symbolic_constant10
  146. // CHECK:STDOUT: inst50: symbolic_constant12
  147. // CHECK:STDOUT: inst51: symbolic_constant11
  148. // CHECK:STDOUT: inst52: symbolic_constant12
  149. // CHECK:STDOUT: inst56: symbolic_constant10
  150. // CHECK:STDOUT: inst58: symbolic_constant12
  151. // CHECK:STDOUT: inst61: concrete_constant(inst62)
  152. // CHECK:STDOUT: inst62: concrete_constant(inst62)
  153. // CHECK:STDOUT: inst63: concrete_constant(inst62)
  154. // CHECK:STDOUT: symbolic_constants:
  155. // CHECK:STDOUT: symbolic_constant0: {inst: inst17, generic: generic<none>, index: generic_inst<none>, kind: checked}
  156. // CHECK:STDOUT: symbolic_constant1: {inst: inst17, generic: generic0, index: generic_inst_in_decl0, kind: checked}
  157. // CHECK:STDOUT: symbolic_constant2: {inst: inst23, generic: generic<none>, index: generic_inst<none>, kind: checked}
  158. // CHECK:STDOUT: symbolic_constant3: {inst: inst23, generic: generic0, index: generic_inst_in_decl1, kind: checked}
  159. // CHECK:STDOUT: symbolic_constant4: {inst: inst33, generic: generic<none>, index: generic_inst<none>, kind: checked}
  160. // CHECK:STDOUT: symbolic_constant5: {inst: inst33, generic: generic0, index: generic_inst_in_decl2, kind: checked}
  161. // CHECK:STDOUT: symbolic_constant6: {inst: inst36, generic: generic<none>, index: generic_inst<none>, kind: checked}
  162. // CHECK:STDOUT: symbolic_constant7: {inst: inst36, generic: generic0, index: generic_inst_in_decl3, kind: checked}
  163. // CHECK:STDOUT: symbolic_constant8: {inst: inst46, generic: generic<none>, index: generic_inst<none>, kind: checked}
  164. // CHECK:STDOUT: symbolic_constant9: {inst: inst48, generic: generic<none>, index: generic_inst<none>, kind: checked}
  165. // CHECK:STDOUT: symbolic_constant10: {inst: inst48, generic: generic0, index: generic_inst_in_def0, kind: checked}
  166. // CHECK:STDOUT: symbolic_constant11: {inst: inst51, generic: generic<none>, index: generic_inst<none>, kind: checked}
  167. // CHECK:STDOUT: symbolic_constant12: {inst: inst51, generic: generic0, index: generic_inst_in_def1, kind: checked}
  168. // CHECK:STDOUT: inst_blocks:
  169. // CHECK:STDOUT: inst_block_empty: {}
  170. // CHECK:STDOUT: exports:
  171. // CHECK:STDOUT: 0: inst43
  172. // CHECK:STDOUT: imports: {}
  173. // CHECK:STDOUT: global_init: {}
  174. // CHECK:STDOUT: inst_block4: {}
  175. // CHECK:STDOUT: inst_block5:
  176. // CHECK:STDOUT: 0: inst20
  177. // CHECK:STDOUT: inst_block6:
  178. // CHECK:STDOUT: 0: inst21
  179. // CHECK:STDOUT: inst_block7:
  180. // CHECK:STDOUT: 0: inst26
  181. // CHECK:STDOUT: inst_block8:
  182. // CHECK:STDOUT: 0: inst27
  183. // CHECK:STDOUT: 1: inst29
  184. // CHECK:STDOUT: inst_block9:
  185. // CHECK:STDOUT: 0: inst(TypeType)
  186. // CHECK:STDOUT: 1: inst28
  187. // CHECK:STDOUT: inst_block10:
  188. // CHECK:STDOUT: 0: inst27
  189. // CHECK:STDOUT: 1: inst32
  190. // CHECK:STDOUT: inst_block11:
  191. // CHECK:STDOUT: 0: inst17
  192. // CHECK:STDOUT: 1: inst28
  193. // CHECK:STDOUT: inst_block12:
  194. // CHECK:STDOUT: 0: inst18
  195. // CHECK:STDOUT: 1: inst28
  196. // CHECK:STDOUT: inst_block13:
  197. // CHECK:STDOUT: 0: inst40
  198. // CHECK:STDOUT: 1: inst41
  199. // CHECK:STDOUT: inst_block14:
  200. // CHECK:STDOUT: 0: inst20
  201. // CHECK:STDOUT: 1: inst24
  202. // CHECK:STDOUT: 2: inst26
  203. // CHECK:STDOUT: 3: inst37
  204. // CHECK:STDOUT: 4: inst39
  205. // CHECK:STDOUT: inst_block15:
  206. // CHECK:STDOUT: 0: inst27
  207. // CHECK:STDOUT: 1: inst29
  208. // CHECK:STDOUT: 2: inst31
  209. // CHECK:STDOUT: 3: inst32
  210. // CHECK:STDOUT: 4: inst34
  211. // CHECK:STDOUT: 5: inst16
  212. // CHECK:STDOUT: 6: inst40
  213. // CHECK:STDOUT: 7: inst21
  214. // CHECK:STDOUT: 8: inst22
  215. // CHECK:STDOUT: 9: inst41
  216. // CHECK:STDOUT: 10: inst42
  217. // CHECK:STDOUT: inst_block16:
  218. // CHECK:STDOUT: 0: inst16
  219. // CHECK:STDOUT: inst_block17:
  220. // CHECK:STDOUT: 0: inst17
  221. // CHECK:STDOUT: inst_block18:
  222. // CHECK:STDOUT: 0: inst18
  223. // CHECK:STDOUT: 1: inst25
  224. // CHECK:STDOUT: 2: inst35
  225. // CHECK:STDOUT: 3: inst38
  226. // CHECK:STDOUT: inst_block19:
  227. // CHECK:STDOUT: 0: inst17
  228. // CHECK:STDOUT: 1: inst23
  229. // CHECK:STDOUT: 2: inst33
  230. // CHECK:STDOUT: 3: inst36
  231. // CHECK:STDOUT: inst_block20:
  232. // CHECK:STDOUT: 0: inst53
  233. // CHECK:STDOUT: 1: inst54
  234. // CHECK:STDOUT: 2: inst55
  235. // CHECK:STDOUT: 3: inst57
  236. // CHECK:STDOUT: 4: inst59
  237. // CHECK:STDOUT: 5: inst60
  238. // CHECK:STDOUT: 6: inst61
  239. // CHECK:STDOUT: 7: inst63
  240. // CHECK:STDOUT: 8: inst64
  241. // CHECK:STDOUT: 9: inst65
  242. // CHECK:STDOUT: 10: inst66
  243. // CHECK:STDOUT: inst_block21:
  244. // CHECK:STDOUT: 0: inst53
  245. // CHECK:STDOUT: 1: inst54
  246. // CHECK:STDOUT: inst_block22:
  247. // CHECK:STDOUT: 0: inst59
  248. // CHECK:STDOUT: 1: inst63
  249. // CHECK:STDOUT: inst_block23:
  250. // CHECK:STDOUT: 0: inst49
  251. // CHECK:STDOUT: 1: inst52
  252. // CHECK:STDOUT: inst_block24:
  253. // CHECK:STDOUT: 0: inst15
  254. // CHECK:STDOUT: 1: inst43
  255. // CHECK:STDOUT: ...