param_int32.carbon 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  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/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/function/param_int32.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/function/param_int32.carbon
  12. // ============================================================================
  13. // int
  14. // ============================================================================
  15. // --- int.h
  16. auto foo(int a) -> void;
  17. // --- import_int.carbon
  18. library "[[@TEST_NAME]]";
  19. import Cpp library "int.h";
  20. fn F() {
  21. Cpp.foo(1);
  22. }
  23. // --- import_int_max.carbon
  24. library "[[@TEST_NAME]]";
  25. import Cpp library "int.h";
  26. fn F() {
  27. //@dump-sem-ir-begin
  28. Cpp.foo(0x7FFF_FFFF);
  29. //@dump-sem-ir-end
  30. }
  31. // --- fail_import_int_overflow_max.carbon
  32. library "[[@TEST_NAME]]";
  33. import Cpp library "int.h";
  34. fn F() {
  35. // CHECK:STDERR: fail_import_int_overflow_max.carbon:[[@LINE+5]]:11: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType]
  36. // CHECK:STDERR: Cpp.foo(0x8000_0000);
  37. // CHECK:STDERR: ^~~~~~~~~~~
  38. // CHECK:STDERR: fail_import_int_overflow_max.carbon: note: initializing function parameter [InCallToFunctionParam]
  39. // CHECK:STDERR:
  40. Cpp.foo(0x8000_0000);
  41. }
  42. // --- import_int_min.carbon
  43. library "[[@TEST_NAME]]";
  44. import Cpp library "int.h";
  45. fn F() {
  46. //@dump-sem-ir-begin
  47. Cpp.foo(-0x8000_0000);
  48. //@dump-sem-ir-end
  49. }
  50. // --- fail_import_int_overflow_min.carbon
  51. library "[[@TEST_NAME]]";
  52. import Cpp library "int.h";
  53. fn F() {
  54. // CHECK:STDERR: fail_import_int_overflow_min.carbon:[[@LINE+5]]:11: error: integer value -2147483649 too large for type `i32` [IntTooLargeForType]
  55. // CHECK:STDERR: Cpp.foo(-0x8000_0001);
  56. // CHECK:STDERR: ^~~~~~~~~~~~
  57. // CHECK:STDERR: fail_import_int_overflow_min.carbon: note: initializing function parameter [InCallToFunctionParam]
  58. // CHECK:STDERR:
  59. Cpp.foo(-0x8000_0001);
  60. }
  61. // ============================================================================
  62. // signed int
  63. // ============================================================================
  64. // --- signed_int.h
  65. auto foo(signed int a) -> void;
  66. // --- import_signed_int.carbon
  67. library "[[@TEST_NAME]]";
  68. import Cpp library "signed_int.h";
  69. fn F() {
  70. //@dump-sem-ir-begin
  71. Cpp.foo(1);
  72. //@dump-sem-ir-end
  73. }
  74. // ============================================================================
  75. // signed
  76. // ============================================================================
  77. // --- signed.h
  78. auto foo(signed a) -> void;
  79. // --- import_signed.carbon
  80. library "[[@TEST_NAME]]";
  81. import Cpp library "signed.h";
  82. fn F() {
  83. //@dump-sem-ir-begin
  84. Cpp.foo(1);
  85. //@dump-sem-ir-end
  86. }
  87. // ============================================================================
  88. // typedef for int
  89. // ============================================================================
  90. // --- int32_t.h
  91. namespace std {
  92. // Mimicking glibc definition for int32_t: https://codebrowser.dev/glibc/glibc/posix/bits/types.h.html#__int32_t
  93. typedef signed int int32_t;
  94. }
  95. auto foo(std::int32_t a) -> void;
  96. // --- import_int32_t.carbon
  97. library "[[@TEST_NAME]]";
  98. import Cpp library "int32_t.h";
  99. fn F() {
  100. //@dump-sem-ir-begin
  101. Cpp.foo(1);
  102. //@dump-sem-ir-end
  103. }
  104. // ============================================================================
  105. // ints
  106. // ============================================================================
  107. // --- ints.h
  108. auto foo(int a, int b) -> void;
  109. // --- import_ints.carbon
  110. library "[[@TEST_NAME]]";
  111. import Cpp library "ints.h";
  112. fn F() {
  113. //@dump-sem-ir-begin
  114. Cpp.foo(1, 2);
  115. //@dump-sem-ir-end
  116. }
  117. // ============================================================================
  118. // Multiple ints
  119. // ============================================================================
  120. // --- multiple_ints.h
  121. auto foo1(int a, int b) -> void;
  122. auto foo2(int c, int b) -> void;
  123. // --- import_multiple_ints.carbon
  124. library "[[@TEST_NAME]]";
  125. import Cpp library "multiple_ints.h";
  126. fn F() {
  127. //@dump-sem-ir-begin
  128. Cpp.foo1(1, 2);
  129. Cpp.foo2(3, 4);
  130. //@dump-sem-ir-end
  131. }
  132. // ============================================================================
  133. // Unnamed int
  134. // ============================================================================
  135. // --- unnamed_int.h
  136. auto foo(int) -> void;
  137. // --- import_unnamed_int.carbon
  138. library "[[@TEST_NAME]]";
  139. import Cpp library "unnamed_int.h";
  140. fn F() {
  141. //@dump-sem-ir-begin
  142. Cpp.foo(1);
  143. //@dump-sem-ir-end
  144. }
  145. // ============================================================================
  146. // int default
  147. // ============================================================================
  148. // --- int_default.h
  149. auto foo(int a = 0) -> void;
  150. // --- fail_todo_import_int_default_parameterless_call.carbon
  151. library "[[@TEST_NAME]]";
  152. import Cpp library "int_default.h";
  153. fn F() {
  154. //@dump-sem-ir-begin
  155. // CHECK:STDERR: fail_todo_import_int_default_parameterless_call.carbon:[[@LINE+5]]:3: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch]
  156. // CHECK:STDERR: Cpp.foo();
  157. // CHECK:STDERR: ^~~~~~~~~
  158. // CHECK:STDERR: fail_todo_import_int_default_parameterless_call.carbon: note: calling function declared here [InCallToEntity]
  159. // CHECK:STDERR:
  160. Cpp.foo();
  161. //@dump-sem-ir-end
  162. }
  163. // --- import_int_default_sucessful_call.carbon
  164. library "[[@TEST_NAME]]";
  165. import Cpp library "int_default.h";
  166. fn F() {
  167. //@dump-sem-ir-begin
  168. Cpp.foo(1);
  169. //@dump-sem-ir-end
  170. }
  171. // ============================================================================
  172. // const int
  173. // ============================================================================
  174. // --- const_int.h
  175. auto foo(const int a) -> void;
  176. // --- fail_todo_import_const_int.carbon
  177. library "[[@TEST_NAME]]";
  178. import Cpp library "const_int.h";
  179. fn F() {
  180. //@dump-sem-ir-begin
  181. // CHECK:STDERR: fail_todo_import_const_int.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const int` [SemanticsTodo]
  182. // CHECK:STDERR: Cpp.foo(1);
  183. // CHECK:STDERR: ^~~~~~~
  184. // CHECK:STDERR: fail_todo_import_const_int.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  185. // CHECK:STDERR: Cpp.foo(1);
  186. // CHECK:STDERR: ^~~~~~~
  187. // CHECK:STDERR:
  188. Cpp.foo(1);
  189. //@dump-sem-ir-end
  190. }
  191. // ============================================================================
  192. // int reference
  193. // ============================================================================
  194. // --- int_ref.h
  195. auto foo(int& a) -> int;
  196. // --- fail_todo_import_int_ref.carbon
  197. library "[[@TEST_NAME]]";
  198. import Cpp library "int_ref.h";
  199. fn F() {
  200. var a: i32 = 1;
  201. //@dump-sem-ir-begin
  202. // CHECK:STDERR: fail_todo_import_int_ref.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: int &` [SemanticsTodo]
  203. // CHECK:STDERR: Cpp.foo(a);
  204. // CHECK:STDERR: ^~~~~~~
  205. // CHECK:STDERR: fail_todo_import_int_ref.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  206. // CHECK:STDERR: Cpp.foo(a);
  207. // CHECK:STDERR: ^~~~~~~
  208. // CHECK:STDERR:
  209. Cpp.foo(a);
  210. //@dump-sem-ir-end
  211. }
  212. // ============================================================================
  213. // const int reference
  214. // ============================================================================
  215. // --- const_int_ref.h
  216. auto foo(const int& a) -> int;
  217. // --- fail_todo_import_const_int_ref.carbon
  218. library "[[@TEST_NAME]]";
  219. import Cpp library "const_int_ref.h";
  220. fn F() {
  221. var a : i32 = 1;
  222. //@dump-sem-ir-begin
  223. // CHECK:STDERR: fail_todo_import_const_int_ref.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const int &` [SemanticsTodo]
  224. // CHECK:STDERR: Cpp.foo(a);
  225. // CHECK:STDERR: ^~~~~~~
  226. // CHECK:STDERR: fail_todo_import_const_int_ref.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  227. // CHECK:STDERR: Cpp.foo(a);
  228. // CHECK:STDERR: ^~~~~~~
  229. // CHECK:STDERR:
  230. Cpp.foo(a);
  231. //@dump-sem-ir-end
  232. }
  233. // ============================================================================
  234. // int pointer
  235. // ============================================================================
  236. // --- int_pointer.h
  237. auto foo(int* _Nonnull a) -> void;
  238. // --- import_int_pointer.carbon
  239. library "[[@TEST_NAME]]";
  240. import Cpp library "int_pointer.h";
  241. fn F() {
  242. var a: i32 = 1;
  243. //@dump-sem-ir-begin
  244. Cpp.foo(&a);
  245. //@dump-sem-ir-end
  246. }
  247. // ============================================================================
  248. // const int pointer
  249. // ============================================================================
  250. // --- const_int_pointer.h
  251. auto foo(const int* _Nonnull a) -> int;
  252. // --- fail_todo_import_const_int_pointer.carbon
  253. library "[[@TEST_NAME]]";
  254. import Cpp library "const_int_pointer.h";
  255. fn F() {
  256. var a : i32 = 1;
  257. //@dump-sem-ir-begin
  258. // CHECK:STDERR: fail_todo_import_const_int_pointer.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const int * _Nonnull` [SemanticsTodo]
  259. // CHECK:STDERR: Cpp.foo(&a);
  260. // CHECK:STDERR: ^~~~~~~
  261. // CHECK:STDERR: fail_todo_import_const_int_pointer.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  262. // CHECK:STDERR: Cpp.foo(&a);
  263. // CHECK:STDERR: ^~~~~~~
  264. // CHECK:STDERR:
  265. Cpp.foo(&a);
  266. //@dump-sem-ir-end
  267. }
  268. // CHECK:STDOUT: --- import_int_max.carbon
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: constants {
  271. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  272. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  273. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  274. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  275. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  276. // CHECK:STDOUT: %int_2147483647.d89: Core.IntLiteral = int_value 2147483647 [concrete]
  277. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  278. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  279. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  280. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  281. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  282. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  283. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  284. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  285. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  286. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  287. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_2147483647.d89, %Convert.956 [concrete]
  288. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  289. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_2147483647.d89, %Convert.specific_fn [concrete]
  290. // CHECK:STDOUT: %int_2147483647.a74: %i32 = int_value 2147483647 [concrete]
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: imports {
  294. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  295. // CHECK:STDOUT: .foo = %foo.decl
  296. // CHECK:STDOUT: import Cpp//...
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  299. // CHECK:STDOUT: <elided>
  300. // CHECK:STDOUT: } {
  301. // CHECK:STDOUT: <elided>
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  304. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: fn @F() {
  308. // CHECK:STDOUT: !entry:
  309. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  310. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  311. // CHECK:STDOUT: %int_2147483647: Core.IntLiteral = int_value 2147483647 [concrete = constants.%int_2147483647.d89]
  312. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  313. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_2147483647, %impl.elem0 [concrete = constants.%Convert.bound]
  314. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  315. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_2147483647, %specific_fn [concrete = constants.%bound_method]
  316. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_11.2(%int_2147483647) [concrete = constants.%int_2147483647.a74]
  317. // CHECK:STDOUT: %.loc8_11.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_2147483647.a74]
  318. // CHECK:STDOUT: %.loc8_11.2: %i32 = converted %int_2147483647, %.loc8_11.1 [concrete = constants.%int_2147483647.a74]
  319. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2)
  320. // CHECK:STDOUT: <elided>
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: --- import_int_min.carbon
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: constants {
  326. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  327. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  328. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  329. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  330. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  331. // CHECK:STDOUT: %int_2147483648: Core.IntLiteral = int_value 2147483648 [concrete]
  332. // CHECK:STDOUT: %Negate.type: type = facet_type <@Negate> [concrete]
  333. // CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.1 [concrete]
  334. // CHECK:STDOUT: %Negate.impl_witness.973: <witness> = impl_witness imports.%Negate.impl_witness_table.b22 [concrete]
  335. // CHECK:STDOUT: %Negate.facet: %Negate.type = facet_value Core.IntLiteral, (%Negate.impl_witness.973) [concrete]
  336. // CHECK:STDOUT: %.d3d: type = fn_type_with_self_type %Op.type.e42, %Negate.facet [concrete]
  337. // CHECK:STDOUT: %Op.type.18a: type = fn_type @Op.2 [concrete]
  338. // CHECK:STDOUT: %Op.99f: %Op.type.18a = struct_value () [concrete]
  339. // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %int_2147483648, %Op.99f [concrete]
  340. // CHECK:STDOUT: %int_-2147483648.3b9: Core.IntLiteral = int_value -2147483648 [concrete]
  341. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  342. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  343. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  344. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  345. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  346. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  347. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  348. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  349. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  350. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  351. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_-2147483648.3b9, %Convert.956 [concrete]
  352. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  353. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_-2147483648.3b9, %Convert.specific_fn [concrete]
  354. // CHECK:STDOUT: %int_-2147483648.95c: %i32 = int_value -2147483648 [concrete]
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: imports {
  358. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  359. // CHECK:STDOUT: .foo = %foo.decl
  360. // CHECK:STDOUT: import Cpp//...
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  363. // CHECK:STDOUT: <elided>
  364. // CHECK:STDOUT: } {
  365. // CHECK:STDOUT: <elided>
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT: %Core.import_ref.abd = import_ref Core//prelude/parts/int_literal, loc13_50, unloaded
  368. // CHECK:STDOUT: %Core.import_ref.5e6: %Op.type.18a = import_ref Core//prelude/parts/int_literal, loc14_31, loaded [concrete = constants.%Op.99f]
  369. // CHECK:STDOUT: %Negate.impl_witness_table.b22 = impl_witness_table (%Core.import_ref.abd, %Core.import_ref.5e6), @impl.0ef [concrete]
  370. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  371. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: fn @F() {
  375. // CHECK:STDOUT: !entry:
  376. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  377. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  378. // CHECK:STDOUT: %int_2147483648: Core.IntLiteral = int_value 2147483648 [concrete = constants.%int_2147483648]
  379. // CHECK:STDOUT: %impl.elem1: %.d3d = impl_witness_access constants.%Negate.impl_witness.973, element1 [concrete = constants.%Op.99f]
  380. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_2147483648, %impl.elem1 [concrete = constants.%Op.bound]
  381. // CHECK:STDOUT: %int.snegate: init Core.IntLiteral = call %bound_method.loc8_11.1(%int_2147483648) [concrete = constants.%int_-2147483648.3b9]
  382. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  383. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int.snegate, %impl.elem0 [concrete = constants.%Convert.bound]
  384. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  385. // CHECK:STDOUT: %bound_method.loc8_11.3: <bound method> = bound_method %int.snegate, %specific_fn [concrete = constants.%bound_method]
  386. // CHECK:STDOUT: %.loc8_11.1: Core.IntLiteral = value_of_initializer %int.snegate [concrete = constants.%int_-2147483648.3b9]
  387. // CHECK:STDOUT: %.loc8_11.2: Core.IntLiteral = converted %int.snegate, %.loc8_11.1 [concrete = constants.%int_-2147483648.3b9]
  388. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_11.3(%.loc8_11.2) [concrete = constants.%int_-2147483648.95c]
  389. // CHECK:STDOUT: %.loc8_11.3: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_-2147483648.95c]
  390. // CHECK:STDOUT: %.loc8_11.4: %i32 = converted %int.snegate, %.loc8_11.3 [concrete = constants.%int_-2147483648.95c]
  391. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.4)
  392. // CHECK:STDOUT: <elided>
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: --- import_signed_int.carbon
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: constants {
  398. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  399. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  400. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  401. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  402. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  403. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  404. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  405. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  406. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  407. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  408. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  409. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  410. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  411. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  412. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  413. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  414. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  415. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  416. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  417. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: imports {
  421. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  422. // CHECK:STDOUT: .foo = %foo.decl
  423. // CHECK:STDOUT: import Cpp//...
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  426. // CHECK:STDOUT: <elided>
  427. // CHECK:STDOUT: } {
  428. // CHECK:STDOUT: <elided>
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  431. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: fn @F() {
  435. // CHECK:STDOUT: !entry:
  436. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  437. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  438. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  439. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  440. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  441. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  442. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  443. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_11.2(%int_1) [concrete = constants.%int_1.5d2]
  444. // CHECK:STDOUT: %.loc8_11.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  445. // CHECK:STDOUT: %.loc8_11.2: %i32 = converted %int_1, %.loc8_11.1 [concrete = constants.%int_1.5d2]
  446. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2)
  447. // CHECK:STDOUT: <elided>
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: --- import_signed.carbon
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: constants {
  453. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  454. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  455. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  456. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  457. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  458. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  459. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  460. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  461. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  462. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  463. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  464. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  465. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  466. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  467. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  468. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  469. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  470. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  471. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  472. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT:
  475. // CHECK:STDOUT: imports {
  476. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  477. // CHECK:STDOUT: .foo = %foo.decl
  478. // CHECK:STDOUT: import Cpp//...
  479. // CHECK:STDOUT: }
  480. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  481. // CHECK:STDOUT: <elided>
  482. // CHECK:STDOUT: } {
  483. // CHECK:STDOUT: <elided>
  484. // CHECK:STDOUT: }
  485. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  486. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT:
  489. // CHECK:STDOUT: fn @F() {
  490. // CHECK:STDOUT: !entry:
  491. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  492. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  493. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  494. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  495. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  496. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  497. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  498. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_11.2(%int_1) [concrete = constants.%int_1.5d2]
  499. // CHECK:STDOUT: %.loc8_11.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  500. // CHECK:STDOUT: %.loc8_11.2: %i32 = converted %int_1, %.loc8_11.1 [concrete = constants.%int_1.5d2]
  501. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2)
  502. // CHECK:STDOUT: <elided>
  503. // CHECK:STDOUT: }
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: --- import_int32_t.carbon
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: constants {
  508. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  509. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  510. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  511. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  512. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  513. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  514. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  515. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  516. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  517. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  518. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  519. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  520. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  521. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  522. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  523. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  524. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  525. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  526. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  527. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: imports {
  531. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  532. // CHECK:STDOUT: .foo = %foo.decl
  533. // CHECK:STDOUT: import Cpp//...
  534. // CHECK:STDOUT: }
  535. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  536. // CHECK:STDOUT: <elided>
  537. // CHECK:STDOUT: } {
  538. // CHECK:STDOUT: <elided>
  539. // CHECK:STDOUT: }
  540. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  541. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  542. // CHECK:STDOUT: }
  543. // CHECK:STDOUT:
  544. // CHECK:STDOUT: fn @F() {
  545. // CHECK:STDOUT: !entry:
  546. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  547. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  548. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  549. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  550. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  551. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  552. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  553. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_11.2(%int_1) [concrete = constants.%int_1.5d2]
  554. // CHECK:STDOUT: %.loc8_11.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  555. // CHECK:STDOUT: %.loc8_11.2: %i32 = converted %int_1, %.loc8_11.1 [concrete = constants.%int_1.5d2]
  556. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2)
  557. // CHECK:STDOUT: <elided>
  558. // CHECK:STDOUT: }
  559. // CHECK:STDOUT:
  560. // CHECK:STDOUT: --- import_ints.carbon
  561. // CHECK:STDOUT:
  562. // CHECK:STDOUT: constants {
  563. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  564. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  565. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  566. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  567. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  568. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  569. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  570. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  571. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  572. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  573. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  574. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  575. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  576. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  577. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  578. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  579. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  580. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  581. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  582. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  583. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  584. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  585. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  586. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  587. // CHECK:STDOUT: }
  588. // CHECK:STDOUT:
  589. // CHECK:STDOUT: imports {
  590. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  591. // CHECK:STDOUT: .foo = %foo.decl
  592. // CHECK:STDOUT: import Cpp//...
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  595. // CHECK:STDOUT: <elided>
  596. // CHECK:STDOUT: } {
  597. // CHECK:STDOUT: <elided>
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  600. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  601. // CHECK:STDOUT: }
  602. // CHECK:STDOUT:
  603. // CHECK:STDOUT: fn @F() {
  604. // CHECK:STDOUT: !entry:
  605. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  606. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  607. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  608. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  609. // CHECK:STDOUT: %impl.elem0.loc8_11: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  610. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_1, %impl.elem0.loc8_11 [concrete = constants.%Convert.bound.ab5]
  611. // CHECK:STDOUT: %specific_fn.loc8_11: <specific function> = specific_function %impl.elem0.loc8_11, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  612. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_1, %specific_fn.loc8_11 [concrete = constants.%bound_method.9a1]
  613. // CHECK:STDOUT: %int.convert_checked.loc8_11: init %i32 = call %bound_method.loc8_11.2(%int_1) [concrete = constants.%int_1.5d2]
  614. // CHECK:STDOUT: %.loc8_11.1: %i32 = value_of_initializer %int.convert_checked.loc8_11 [concrete = constants.%int_1.5d2]
  615. // CHECK:STDOUT: %.loc8_11.2: %i32 = converted %int_1, %.loc8_11.1 [concrete = constants.%int_1.5d2]
  616. // CHECK:STDOUT: %impl.elem0.loc8_14: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  617. // CHECK:STDOUT: %bound_method.loc8_14.1: <bound method> = bound_method %int_2, %impl.elem0.loc8_14 [concrete = constants.%Convert.bound.ef9]
  618. // CHECK:STDOUT: %specific_fn.loc8_14: <specific function> = specific_function %impl.elem0.loc8_14, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  619. // CHECK:STDOUT: %bound_method.loc8_14.2: <bound method> = bound_method %int_2, %specific_fn.loc8_14 [concrete = constants.%bound_method.b92]
  620. // CHECK:STDOUT: %int.convert_checked.loc8_14: init %i32 = call %bound_method.loc8_14.2(%int_2) [concrete = constants.%int_2.ef8]
  621. // CHECK:STDOUT: %.loc8_14.1: %i32 = value_of_initializer %int.convert_checked.loc8_14 [concrete = constants.%int_2.ef8]
  622. // CHECK:STDOUT: %.loc8_14.2: %i32 = converted %int_2, %.loc8_14.1 [concrete = constants.%int_2.ef8]
  623. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2, %.loc8_14.2)
  624. // CHECK:STDOUT: <elided>
  625. // CHECK:STDOUT: }
  626. // CHECK:STDOUT:
  627. // CHECK:STDOUT: --- import_multiple_ints.carbon
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: constants {
  630. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  631. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  632. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  633. // CHECK:STDOUT: %foo1.type: type = fn_type @foo1 [concrete]
  634. // CHECK:STDOUT: %foo1: %foo1.type = struct_value () [concrete]
  635. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  636. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  637. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  638. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  639. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  640. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  641. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  642. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  643. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  644. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  645. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  646. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  647. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  648. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  649. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  650. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  651. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  652. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  653. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  654. // CHECK:STDOUT: %foo2.type: type = fn_type @foo2 [concrete]
  655. // CHECK:STDOUT: %foo2: %foo2.type = struct_value () [concrete]
  656. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  657. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
  658. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
  659. // CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
  660. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  661. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [concrete]
  662. // CHECK:STDOUT: %bound_method.1da: <bound method> = bound_method %int_4.0c1, %Convert.specific_fn [concrete]
  663. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
  664. // CHECK:STDOUT: }
  665. // CHECK:STDOUT:
  666. // CHECK:STDOUT: imports {
  667. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  668. // CHECK:STDOUT: .foo1 = %foo1.decl
  669. // CHECK:STDOUT: .foo2 = %foo2.decl
  670. // CHECK:STDOUT: import Cpp//...
  671. // CHECK:STDOUT: }
  672. // CHECK:STDOUT: %foo1.decl: %foo1.type = fn_decl @foo1 [concrete = constants.%foo1] {
  673. // CHECK:STDOUT: <elided>
  674. // CHECK:STDOUT: } {
  675. // CHECK:STDOUT: <elided>
  676. // CHECK:STDOUT: }
  677. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  678. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  679. // CHECK:STDOUT: %foo2.decl: %foo2.type = fn_decl @foo2 [concrete = constants.%foo2] {
  680. // CHECK:STDOUT: <elided>
  681. // CHECK:STDOUT: } {
  682. // CHECK:STDOUT: <elided>
  683. // CHECK:STDOUT: }
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT:
  686. // CHECK:STDOUT: fn @F() {
  687. // CHECK:STDOUT: !entry:
  688. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  689. // CHECK:STDOUT: %foo1.ref: %foo1.type = name_ref foo1, imports.%foo1.decl [concrete = constants.%foo1]
  690. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  691. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  692. // CHECK:STDOUT: %impl.elem0.loc8_12: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  693. // CHECK:STDOUT: %bound_method.loc8_12.1: <bound method> = bound_method %int_1, %impl.elem0.loc8_12 [concrete = constants.%Convert.bound.ab5]
  694. // CHECK:STDOUT: %specific_fn.loc8_12: <specific function> = specific_function %impl.elem0.loc8_12, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  695. // CHECK:STDOUT: %bound_method.loc8_12.2: <bound method> = bound_method %int_1, %specific_fn.loc8_12 [concrete = constants.%bound_method.9a1]
  696. // CHECK:STDOUT: %int.convert_checked.loc8_12: init %i32 = call %bound_method.loc8_12.2(%int_1) [concrete = constants.%int_1.5d2]
  697. // CHECK:STDOUT: %.loc8_12.1: %i32 = value_of_initializer %int.convert_checked.loc8_12 [concrete = constants.%int_1.5d2]
  698. // CHECK:STDOUT: %.loc8_12.2: %i32 = converted %int_1, %.loc8_12.1 [concrete = constants.%int_1.5d2]
  699. // CHECK:STDOUT: %impl.elem0.loc8_15: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  700. // CHECK:STDOUT: %bound_method.loc8_15.1: <bound method> = bound_method %int_2, %impl.elem0.loc8_15 [concrete = constants.%Convert.bound.ef9]
  701. // CHECK:STDOUT: %specific_fn.loc8_15: <specific function> = specific_function %impl.elem0.loc8_15, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  702. // CHECK:STDOUT: %bound_method.loc8_15.2: <bound method> = bound_method %int_2, %specific_fn.loc8_15 [concrete = constants.%bound_method.b92]
  703. // CHECK:STDOUT: %int.convert_checked.loc8_15: init %i32 = call %bound_method.loc8_15.2(%int_2) [concrete = constants.%int_2.ef8]
  704. // CHECK:STDOUT: %.loc8_15.1: %i32 = value_of_initializer %int.convert_checked.loc8_15 [concrete = constants.%int_2.ef8]
  705. // CHECK:STDOUT: %.loc8_15.2: %i32 = converted %int_2, %.loc8_15.1 [concrete = constants.%int_2.ef8]
  706. // CHECK:STDOUT: %foo1.call: init %empty_tuple.type = call %foo1.ref(%.loc8_12.2, %.loc8_15.2)
  707. // CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  708. // CHECK:STDOUT: %foo2.ref: %foo2.type = name_ref foo2, imports.%foo2.decl [concrete = constants.%foo2]
  709. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  710. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  711. // CHECK:STDOUT: %impl.elem0.loc9_12: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  712. // CHECK:STDOUT: %bound_method.loc9_12.1: <bound method> = bound_method %int_3, %impl.elem0.loc9_12 [concrete = constants.%Convert.bound.b30]
  713. // CHECK:STDOUT: %specific_fn.loc9_12: <specific function> = specific_function %impl.elem0.loc9_12, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  714. // CHECK:STDOUT: %bound_method.loc9_12.2: <bound method> = bound_method %int_3, %specific_fn.loc9_12 [concrete = constants.%bound_method.047]
  715. // CHECK:STDOUT: %int.convert_checked.loc9_12: init %i32 = call %bound_method.loc9_12.2(%int_3) [concrete = constants.%int_3.822]
  716. // CHECK:STDOUT: %.loc9_12.1: %i32 = value_of_initializer %int.convert_checked.loc9_12 [concrete = constants.%int_3.822]
  717. // CHECK:STDOUT: %.loc9_12.2: %i32 = converted %int_3, %.loc9_12.1 [concrete = constants.%int_3.822]
  718. // CHECK:STDOUT: %impl.elem0.loc9_15: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  719. // CHECK:STDOUT: %bound_method.loc9_15.1: <bound method> = bound_method %int_4, %impl.elem0.loc9_15 [concrete = constants.%Convert.bound.ac3]
  720. // CHECK:STDOUT: %specific_fn.loc9_15: <specific function> = specific_function %impl.elem0.loc9_15, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  721. // CHECK:STDOUT: %bound_method.loc9_15.2: <bound method> = bound_method %int_4, %specific_fn.loc9_15 [concrete = constants.%bound_method.1da]
  722. // CHECK:STDOUT: %int.convert_checked.loc9_15: init %i32 = call %bound_method.loc9_15.2(%int_4) [concrete = constants.%int_4.940]
  723. // CHECK:STDOUT: %.loc9_15.1: %i32 = value_of_initializer %int.convert_checked.loc9_15 [concrete = constants.%int_4.940]
  724. // CHECK:STDOUT: %.loc9_15.2: %i32 = converted %int_4, %.loc9_15.1 [concrete = constants.%int_4.940]
  725. // CHECK:STDOUT: %foo2.call: init %empty_tuple.type = call %foo2.ref(%.loc9_12.2, %.loc9_15.2)
  726. // CHECK:STDOUT: <elided>
  727. // CHECK:STDOUT: }
  728. // CHECK:STDOUT:
  729. // CHECK:STDOUT: --- import_unnamed_int.carbon
  730. // CHECK:STDOUT:
  731. // CHECK:STDOUT: constants {
  732. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  733. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  734. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  735. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  736. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  737. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  738. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  739. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  740. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  741. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  742. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  743. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  744. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  745. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  746. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  747. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  748. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  749. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  750. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  751. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  752. // CHECK:STDOUT: }
  753. // CHECK:STDOUT:
  754. // CHECK:STDOUT: imports {
  755. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  756. // CHECK:STDOUT: .foo = %foo.decl
  757. // CHECK:STDOUT: import Cpp//...
  758. // CHECK:STDOUT: }
  759. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  760. // CHECK:STDOUT: <elided>
  761. // CHECK:STDOUT: } {
  762. // CHECK:STDOUT: <elided>
  763. // CHECK:STDOUT: }
  764. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  765. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT:
  768. // CHECK:STDOUT: fn @F() {
  769. // CHECK:STDOUT: !entry:
  770. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  771. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  772. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  773. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  774. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  775. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  776. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  777. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_11.2(%int_1) [concrete = constants.%int_1.5d2]
  778. // CHECK:STDOUT: %.loc8_11.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  779. // CHECK:STDOUT: %.loc8_11.2: %i32 = converted %int_1, %.loc8_11.1 [concrete = constants.%int_1.5d2]
  780. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2)
  781. // CHECK:STDOUT: <elided>
  782. // CHECK:STDOUT: }
  783. // CHECK:STDOUT:
  784. // CHECK:STDOUT: --- fail_todo_import_int_default_parameterless_call.carbon
  785. // CHECK:STDOUT:
  786. // CHECK:STDOUT: constants {
  787. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  788. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  789. // CHECK:STDOUT: }
  790. // CHECK:STDOUT:
  791. // CHECK:STDOUT: imports {
  792. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  793. // CHECK:STDOUT: .foo = %foo.decl
  794. // CHECK:STDOUT: import Cpp//...
  795. // CHECK:STDOUT: }
  796. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  797. // CHECK:STDOUT: <elided>
  798. // CHECK:STDOUT: } {
  799. // CHECK:STDOUT: <elided>
  800. // CHECK:STDOUT: }
  801. // CHECK:STDOUT: }
  802. // CHECK:STDOUT:
  803. // CHECK:STDOUT: fn @F() {
  804. // CHECK:STDOUT: !entry:
  805. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  806. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  807. // CHECK:STDOUT: <elided>
  808. // CHECK:STDOUT: }
  809. // CHECK:STDOUT:
  810. // CHECK:STDOUT: --- import_int_default_sucessful_call.carbon
  811. // CHECK:STDOUT:
  812. // CHECK:STDOUT: constants {
  813. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  814. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  815. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  816. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  817. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  818. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  819. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  820. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  821. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  822. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  823. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  824. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  825. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  826. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  827. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  828. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  829. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  830. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  831. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  832. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  833. // CHECK:STDOUT: }
  834. // CHECK:STDOUT:
  835. // CHECK:STDOUT: imports {
  836. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  837. // CHECK:STDOUT: .foo = %foo.decl
  838. // CHECK:STDOUT: import Cpp//...
  839. // CHECK:STDOUT: }
  840. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  841. // CHECK:STDOUT: <elided>
  842. // CHECK:STDOUT: } {
  843. // CHECK:STDOUT: <elided>
  844. // CHECK:STDOUT: }
  845. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  846. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  847. // CHECK:STDOUT: }
  848. // CHECK:STDOUT:
  849. // CHECK:STDOUT: fn @F() {
  850. // CHECK:STDOUT: !entry:
  851. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  852. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  853. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  854. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  855. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  856. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  857. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  858. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc8_11.2(%int_1) [concrete = constants.%int_1.5d2]
  859. // CHECK:STDOUT: %.loc8_11.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  860. // CHECK:STDOUT: %.loc8_11.2: %i32 = converted %int_1, %.loc8_11.1 [concrete = constants.%int_1.5d2]
  861. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2)
  862. // CHECK:STDOUT: <elided>
  863. // CHECK:STDOUT: }
  864. // CHECK:STDOUT:
  865. // CHECK:STDOUT: --- fail_todo_import_const_int.carbon
  866. // CHECK:STDOUT:
  867. // CHECK:STDOUT: constants {
  868. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  869. // CHECK:STDOUT: }
  870. // CHECK:STDOUT:
  871. // CHECK:STDOUT: imports {
  872. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  873. // CHECK:STDOUT: .foo = <error>
  874. // CHECK:STDOUT: import Cpp//...
  875. // CHECK:STDOUT: }
  876. // CHECK:STDOUT: }
  877. // CHECK:STDOUT:
  878. // CHECK:STDOUT: fn @F() {
  879. // CHECK:STDOUT: !entry:
  880. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  881. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  882. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  883. // CHECK:STDOUT: <elided>
  884. // CHECK:STDOUT: }
  885. // CHECK:STDOUT:
  886. // CHECK:STDOUT: --- fail_todo_import_int_ref.carbon
  887. // CHECK:STDOUT:
  888. // CHECK:STDOUT: constants {
  889. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  890. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  891. // CHECK:STDOUT: }
  892. // CHECK:STDOUT:
  893. // CHECK:STDOUT: imports {
  894. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  895. // CHECK:STDOUT: .foo = <error>
  896. // CHECK:STDOUT: import Cpp//...
  897. // CHECK:STDOUT: }
  898. // CHECK:STDOUT: }
  899. // CHECK:STDOUT:
  900. // CHECK:STDOUT: fn @F() {
  901. // CHECK:STDOUT: !entry:
  902. // CHECK:STDOUT: <elided>
  903. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  904. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  905. // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
  906. // CHECK:STDOUT: <elided>
  907. // CHECK:STDOUT: }
  908. // CHECK:STDOUT:
  909. // CHECK:STDOUT: --- fail_todo_import_const_int_ref.carbon
  910. // CHECK:STDOUT:
  911. // CHECK:STDOUT: constants {
  912. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  913. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  914. // CHECK:STDOUT: }
  915. // CHECK:STDOUT:
  916. // CHECK:STDOUT: imports {
  917. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  918. // CHECK:STDOUT: .foo = <error>
  919. // CHECK:STDOUT: import Cpp//...
  920. // CHECK:STDOUT: }
  921. // CHECK:STDOUT: }
  922. // CHECK:STDOUT:
  923. // CHECK:STDOUT: fn @F() {
  924. // CHECK:STDOUT: !entry:
  925. // CHECK:STDOUT: <elided>
  926. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  927. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  928. // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
  929. // CHECK:STDOUT: <elided>
  930. // CHECK:STDOUT: }
  931. // CHECK:STDOUT:
  932. // CHECK:STDOUT: --- import_int_pointer.carbon
  933. // CHECK:STDOUT:
  934. // CHECK:STDOUT: constants {
  935. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  936. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  937. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  938. // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
  939. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  940. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  941. // CHECK:STDOUT: }
  942. // CHECK:STDOUT:
  943. // CHECK:STDOUT: imports {
  944. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  945. // CHECK:STDOUT: .foo = %foo.decl
  946. // CHECK:STDOUT: import Cpp//...
  947. // CHECK:STDOUT: }
  948. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  949. // CHECK:STDOUT: <elided>
  950. // CHECK:STDOUT: } {
  951. // CHECK:STDOUT: <elided>
  952. // CHECK:STDOUT: }
  953. // CHECK:STDOUT: }
  954. // CHECK:STDOUT:
  955. // CHECK:STDOUT: fn @F() {
  956. // CHECK:STDOUT: !entry:
  957. // CHECK:STDOUT: <elided>
  958. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  959. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  960. // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
  961. // CHECK:STDOUT: %addr.loc9: %ptr.235 = addr_of %a.ref
  962. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%addr.loc9)
  963. // CHECK:STDOUT: <elided>
  964. // CHECK:STDOUT: }
  965. // CHECK:STDOUT:
  966. // CHECK:STDOUT: --- fail_todo_import_const_int_pointer.carbon
  967. // CHECK:STDOUT:
  968. // CHECK:STDOUT: constants {
  969. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  970. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  971. // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
  972. // CHECK:STDOUT: }
  973. // CHECK:STDOUT:
  974. // CHECK:STDOUT: imports {
  975. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  976. // CHECK:STDOUT: .foo = <error>
  977. // CHECK:STDOUT: import Cpp//...
  978. // CHECK:STDOUT: }
  979. // CHECK:STDOUT: }
  980. // CHECK:STDOUT:
  981. // CHECK:STDOUT: fn @F() {
  982. // CHECK:STDOUT: !entry:
  983. // CHECK:STDOUT: <elided>
  984. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  985. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  986. // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a
  987. // CHECK:STDOUT: %addr.loc16: %ptr.235 = addr_of %a.ref
  988. // CHECK:STDOUT: <elided>
  989. // CHECK:STDOUT: }
  990. // CHECK:STDOUT: