struct.carbon 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  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/convert.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/struct.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/struct.carbon
  12. // ============================================================================
  13. // Forward-declared struct as parameter type
  14. // ============================================================================
  15. // --- decl_value_param_type.h
  16. struct S;
  17. auto foo(S) -> void;
  18. // --- fail_import_decl_value_param_type.carbon
  19. library "[[@TEST_NAME]]";
  20. import Cpp library "decl_value_param_type.h";
  21. fn F() {
  22. // CHECK:STDERR: fail_import_decl_value_param_type.carbon:[[@LINE+8]]:11: error: invalid use of incomplete type `Cpp.S` [IncompleteTypeInConversion]
  23. // CHECK:STDERR: Cpp.foo({} as Cpp.S);
  24. // CHECK:STDERR: ^~~~~~~~~~~
  25. // CHECK:STDERR: fail_import_decl_value_param_type.carbon:[[@LINE-6]]:10: in file included here [InCppInclude]
  26. // CHECK:STDERR: ./decl_value_param_type.h:2:8: note: class was forward declared here [ClassForwardDeclaredHere]
  27. // CHECK:STDERR: struct S;
  28. // CHECK:STDERR: ^
  29. // CHECK:STDERR:
  30. Cpp.foo({} as Cpp.S);
  31. }
  32. // --- fail_import_decl_value_param_type_previously_imported.carbon
  33. library "[[@TEST_NAME]]";
  34. import Cpp library "decl_value_param_type.h";
  35. fn F() {
  36. // CHECK:STDERR: fail_import_decl_value_param_type_previously_imported.carbon:[[@LINE+12]]:10: error: binding pattern has incomplete type `S` in name binding declaration [IncompleteTypeInBindingDecl]
  37. // CHECK:STDERR: let s: Cpp.S;
  38. // CHECK:STDERR: ^~~~~
  39. // CHECK:STDERR: fail_import_decl_value_param_type_previously_imported.carbon:[[@LINE-6]]:10: in file included here [InCppInclude]
  40. // CHECK:STDERR: ./decl_value_param_type.h:2:8: note: class was forward declared here [ClassForwardDeclaredHere]
  41. // CHECK:STDERR: struct S;
  42. // CHECK:STDERR: ^
  43. // CHECK:STDERR:
  44. // CHECK:STDERR: fail_import_decl_value_param_type_previously_imported.carbon:[[@LINE+4]]:15: error: expected `=`; `let` declaration must have an initializer [ExpectedInitializerAfterLet]
  45. // CHECK:STDERR: let s: Cpp.S;
  46. // CHECK:STDERR: ^
  47. // CHECK:STDERR:
  48. let s: Cpp.S;
  49. Cpp.foo(s);
  50. }
  51. // ============================================================================
  52. // Forward-declared struct as parameter type imported twice
  53. // ============================================================================
  54. // --- double_decl_value_param_type.h
  55. struct S;
  56. auto foo1(S) -> void;
  57. auto foo2(S) -> void;
  58. // --- fail_import_double_decl_value_param_type.carbon
  59. library "[[@TEST_NAME]]";
  60. import Cpp library "double_decl_value_param_type.h";
  61. fn F() {
  62. // CHECK:STDERR: fail_import_double_decl_value_param_type.carbon:[[@LINE+8]]:12: error: invalid use of incomplete type `Cpp.S` [IncompleteTypeInConversion]
  63. // CHECK:STDERR: Cpp.foo1({} as Cpp.S);
  64. // CHECK:STDERR: ^~~~~~~~~~~
  65. // CHECK:STDERR: fail_import_double_decl_value_param_type.carbon:[[@LINE-6]]:10: in file included here [InCppInclude]
  66. // CHECK:STDERR: ./double_decl_value_param_type.h:2:8: note: class was forward declared here [ClassForwardDeclaredHere]
  67. // CHECK:STDERR: struct S;
  68. // CHECK:STDERR: ^
  69. // CHECK:STDERR:
  70. Cpp.foo1({} as Cpp.S);
  71. // CHECK:STDERR: fail_import_double_decl_value_param_type.carbon:[[@LINE+8]]:12: error: invalid use of incomplete type `Cpp.S` [IncompleteTypeInConversion]
  72. // CHECK:STDERR: Cpp.foo2({} as Cpp.S);
  73. // CHECK:STDERR: ^~~~~~~~~~~
  74. // CHECK:STDERR: fail_import_double_decl_value_param_type.carbon:[[@LINE-15]]:10: in file included here [InCppInclude]
  75. // CHECK:STDERR: ./double_decl_value_param_type.h:2:8: note: class was forward declared here [ClassForwardDeclaredHere]
  76. // CHECK:STDERR: struct S;
  77. // CHECK:STDERR: ^
  78. // CHECK:STDERR:
  79. Cpp.foo2({} as Cpp.S);
  80. }
  81. // ============================================================================
  82. // Defined struct without data members as parameter type
  83. // ============================================================================
  84. // --- definition_no_data_members_value_param_type.h
  85. struct S {};
  86. auto foo(S) -> void;
  87. // --- import_definition_no_data_members_value_param_type.carbon
  88. library "[[@TEST_NAME]]";
  89. import Cpp library "definition_no_data_members_value_param_type.h";
  90. fn F() {
  91. //@dump-sem-ir-begin
  92. Cpp.foo({} as Cpp.S);
  93. //@dump-sem-ir-end
  94. }
  95. // ============================================================================
  96. // Non copyable struct as parameter type
  97. // ============================================================================
  98. // --- non_copyable_param_type.h
  99. struct S {
  100. S(const S&) = delete;
  101. };
  102. auto foo(S) -> void;
  103. // --- fail_import_non_copyable_param_type.carbon
  104. library "[[@TEST_NAME]]";
  105. // CHECK:STDERR: fail_import_non_copyable_param_type.carbon:[[@LINE+12]]:10: in file included here [InCppInclude]
  106. // CHECK:STDERR: ./non_copyable_param_type.h:6:6: error: call to deleted constructor of 'S' [CppInteropParseError]
  107. // CHECK:STDERR: 6 | auto foo(S) -> void;
  108. // CHECK:STDERR: | ^~~
  109. // CHECK:STDERR: fail_import_non_copyable_param_type.carbon:[[@LINE+8]]:10: in file included here [InCppInclude]
  110. // CHECK:STDERR: ./non_copyable_param_type.h:3:3: note: 'S' has been explicitly marked deleted here [CppInteropParseNote]
  111. // CHECK:STDERR: 3 | S(const S&) = delete;
  112. // CHECK:STDERR: | ^
  113. // CHECK:STDERR: fail_import_non_copyable_param_type.carbon:[[@LINE+4]]:10: in file included here [InCppInclude]
  114. // CHECK:STDERR: ./non_copyable_param_type.h:6:11: note: passing argument to parameter here [CppInteropParseNote]
  115. // CHECK:STDERR: 6 | auto foo(S) -> void;
  116. // CHECK:STDERR: | ^
  117. import Cpp library "non_copyable_param_type.h";
  118. fn F() {
  119. //@dump-sem-ir-begin
  120. // CHECK:STDERR: fail_import_non_copyable_param_type.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
  121. // CHECK:STDERR: Cpp.foo({} as Cpp.S);
  122. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  123. // CHECK:STDERR:
  124. Cpp.foo({} as Cpp.S);
  125. //@dump-sem-ir-end
  126. }
  127. // ============================================================================
  128. // Defined struct with a single data member as parameter type
  129. // ============================================================================
  130. // --- definition_single_data_member_value_param_type.h
  131. struct D {};
  132. struct S {
  133. D d;
  134. };
  135. auto foo(S) -> void;
  136. // --- fail_todo_import_definition_single_data_member_value_param_type.carbon
  137. library "[[@TEST_NAME]]";
  138. import Cpp library "definition_single_data_member_value_param_type.h";
  139. fn F() {
  140. //@dump-sem-ir-begin
  141. // CHECK:STDERR: fail_todo_import_definition_single_data_member_value_param_type.carbon:[[@LINE+7]]:11: error: cannot convert expression of type `{}` to `Cpp.S` with `as` [ConversionFailure]
  142. // CHECK:STDERR: Cpp.foo({} as Cpp.S);
  143. // CHECK:STDERR: ^~~~~~~~~~~
  144. // CHECK:STDERR: fail_todo_import_definition_single_data_member_value_param_type.carbon:[[@LINE+4]]:11: note: type `{}` does not implement interface `Core.As(Cpp.S)` [MissingImplInMemberAccessNote]
  145. // CHECK:STDERR: Cpp.foo({} as Cpp.S);
  146. // CHECK:STDERR: ^~~~~~~~~~~
  147. // CHECK:STDERR:
  148. Cpp.foo({} as Cpp.S);
  149. //@dump-sem-ir-end
  150. }
  151. // ============================================================================
  152. // Defined struct with multiple data members as parameter type
  153. // ============================================================================
  154. // --- definition_multiple_data_members_value_param_type.h
  155. struct D {};
  156. struct S {
  157. D d1;
  158. D d2;
  159. D d3;
  160. };
  161. auto foo(S) -> void;
  162. // --- fail_todo_import_definition_multiple_data_members_value_param_type.carbon
  163. library "[[@TEST_NAME]]";
  164. import Cpp library "definition_multiple_data_members_value_param_type.h";
  165. fn F() {
  166. //@dump-sem-ir-begin
  167. // CHECK:STDERR: fail_todo_import_definition_multiple_data_members_value_param_type.carbon:[[@LINE+7]]:11: error: cannot convert expression of type `{}` to `Cpp.S` with `as` [ConversionFailure]
  168. // CHECK:STDERR: Cpp.foo({} as Cpp.S);
  169. // CHECK:STDERR: ^~~~~~~~~~~
  170. // CHECK:STDERR: fail_todo_import_definition_multiple_data_members_value_param_type.carbon:[[@LINE+4]]:11: note: type `{}` does not implement interface `Core.As(Cpp.S)` [MissingImplInMemberAccessNote]
  171. // CHECK:STDERR: Cpp.foo({} as Cpp.S);
  172. // CHECK:STDERR: ^~~~~~~~~~~
  173. // CHECK:STDERR:
  174. Cpp.foo({} as Cpp.S);
  175. //@dump-sem-ir-end
  176. }
  177. // ============================================================================
  178. // Defined struct in namespace
  179. // ============================================================================
  180. // --- definition_in_namespace_value_param_type.h
  181. namespace N { struct S {}; }
  182. auto foo(N::S) -> void;
  183. // --- import_definition_in_namespace_value_param_type.carbon
  184. library "[[@TEST_NAME]]";
  185. import Cpp library "definition_in_namespace_value_param_type.h";
  186. fn F() {
  187. //@dump-sem-ir-begin
  188. Cpp.foo({} as Cpp.N.S);
  189. // Check that the parameter type was imported correctly.
  190. var x: Cpp.N.S;
  191. //@dump-sem-ir-end
  192. }
  193. // ============================================================================
  194. // Defined struct in relative namespace
  195. // ============================================================================
  196. // --- definition_in_relative_namespace_value_param_type.h
  197. namespace N1 {
  198. namespace N2 { struct S {}; }
  199. auto foo(N2::S) -> void;
  200. }
  201. // --- import_definition_in_relative_namespace_value_param_type.carbon
  202. library "[[@TEST_NAME]]";
  203. import Cpp library "definition_in_relative_namespace_value_param_type.h";
  204. fn F() {
  205. //@dump-sem-ir-begin
  206. Cpp.N1.foo({} as Cpp.N1.N2.S);
  207. //@dump-sem-ir-end
  208. }
  209. // ============================================================================
  210. // Defined struct in struct
  211. // ============================================================================
  212. // --- definition_in_outer_definition.h
  213. struct O {
  214. struct S {};
  215. };
  216. auto foo(O::S) -> void;
  217. // --- import_definition_in_outer_definition.carbon
  218. library "[[@TEST_NAME]]";
  219. import Cpp library "definition_in_outer_definition.h";
  220. fn F() {
  221. //@dump-sem-ir-begin
  222. Cpp.foo({} as Cpp.O.S);
  223. var x: Cpp.O;
  224. //@dump-sem-ir-end
  225. }
  226. // ============================================================================
  227. // Defined struct and explicitly used
  228. // ============================================================================
  229. // --- definition_with_static_method.h
  230. struct S {
  231. static void bar();
  232. };
  233. auto foo(S) -> void;
  234. // --- import_definition_and_static_method_call_before.carbon
  235. library "[[@TEST_NAME]]";
  236. import Cpp library "definition_with_static_method.h";
  237. fn F() {
  238. //@dump-sem-ir-begin
  239. Cpp.S.bar();
  240. Cpp.foo({} as Cpp.S);
  241. //@dump-sem-ir-end
  242. }
  243. // --- import_definition_and_static_method_call_after.carbon
  244. library "[[@TEST_NAME]]";
  245. import Cpp library "definition_with_static_method.h";
  246. fn F() {
  247. //@dump-sem-ir-begin
  248. Cpp.foo({} as Cpp.S);
  249. Cpp.S.bar();
  250. //@dump-sem-ir-end
  251. }
  252. // ============================================================================
  253. // Pointer to forward-declared struct as parameter type
  254. // ============================================================================
  255. // --- decl_pointer_param_type.h
  256. struct S;
  257. auto foo(S* _Nonnull) -> void;
  258. // --- import_decl_pointer_param_type.carbon
  259. library "[[@TEST_NAME]]";
  260. import Cpp library "decl_pointer_param_type.h";
  261. fn F(s: Cpp.S*) {
  262. //@dump-sem-ir-begin
  263. Cpp.foo(s);
  264. //@dump-sem-ir-end
  265. }
  266. // ============================================================================
  267. // Pointer to defined struct as parameter type
  268. // ============================================================================
  269. // --- definition_pointer_param_type.h
  270. struct S {};
  271. auto foo(S* _Nonnull) -> void;
  272. // --- import_definition_pointer_param_type.carbon
  273. library "[[@TEST_NAME]]";
  274. import Cpp library "definition_pointer_param_type.h";
  275. fn F(s: Cpp.S*) {
  276. //@dump-sem-ir-begin
  277. Cpp.foo(s);
  278. //@dump-sem-ir-end
  279. }
  280. // ============================================================================
  281. // Forward-declared struct as return type
  282. // ============================================================================
  283. // --- decl_value_return_type.h
  284. struct S;
  285. auto foo() -> S;
  286. // --- fail_import_decl_value_return_type.carbon
  287. library "[[@TEST_NAME]]";
  288. // TODO: We should only produce one error here.
  289. // CHECK:STDERR: fail_import_decl_value_return_type.carbon:[[@LINE+12]]:10: in file included here [InCppInclude]
  290. // CHECK:STDERR: ./decl_value_return_type.h:4:6: error: calling 'foo' with incomplete return type 'S' [CppInteropParseError]
  291. // CHECK:STDERR: 4 | auto foo() -> S;
  292. // CHECK:STDERR: | ^~~
  293. // CHECK:STDERR: fail_import_decl_value_return_type.carbon:[[@LINE+8]]:10: in file included here [InCppInclude]
  294. // CHECK:STDERR: ./decl_value_return_type.h:4:6: note: 'foo' declared here [CppInteropParseNote]
  295. // CHECK:STDERR: 4 | auto foo() -> S;
  296. // CHECK:STDERR: | ^
  297. // CHECK:STDERR: fail_import_decl_value_return_type.carbon:[[@LINE+4]]:10: in file included here [InCppInclude]
  298. // CHECK:STDERR: ./decl_value_return_type.h:2:8: note: forward declaration of 'S' [CppInteropParseNote]
  299. // CHECK:STDERR: 2 | struct S;
  300. // CHECK:STDERR: | ^
  301. import Cpp library "decl_value_return_type.h";
  302. fn F() {
  303. // CHECK:STDERR: fail_import_decl_value_return_type.carbon:[[@LINE+13]]:3: note: in call to Cpp function here [InCallToCppFunction]
  304. // CHECK:STDERR: Cpp.foo();
  305. // CHECK:STDERR: ^~~~~~~~~
  306. // CHECK:STDERR:
  307. // CHECK:STDERR: fail_import_decl_value_return_type.carbon:[[@LINE+9]]:3: error: function returns incomplete type `Cpp.S` [IncompleteTypeInFunctionReturnType]
  308. // CHECK:STDERR: Cpp.foo();
  309. // CHECK:STDERR: ^~~~~~~~~
  310. // CHECK:STDERR: fail_import_decl_value_return_type.carbon:[[@LINE-10]]:10: in file included here [InCppInclude]
  311. // CHECK:STDERR: ./decl_value_return_type.h:2:8: note: class was forward declared here [ClassForwardDeclaredHere]
  312. // CHECK:STDERR: struct S;
  313. // CHECK:STDERR: ^
  314. // CHECK:STDERR: fail_import_decl_value_return_type.carbon: note: return type declared here [IncompleteReturnTypeHere]
  315. // CHECK:STDERR:
  316. Cpp.foo();
  317. }
  318. // ============================================================================
  319. // Defined struct as return type
  320. // ============================================================================
  321. // --- definition_value_return_type.h
  322. struct S {};
  323. auto foo() -> S;
  324. // --- import_definition_value_return_type.carbon
  325. library "[[@TEST_NAME]]";
  326. import Cpp library "definition_value_return_type.h";
  327. fn F() {
  328. //@dump-sem-ir-begin
  329. Cpp.foo();
  330. //@dump-sem-ir-end
  331. }
  332. // ============================================================================
  333. // Pointer to forward-declared struct as return type
  334. // ============================================================================
  335. // --- decl_pointer_return_type.h
  336. struct S;
  337. auto foo() -> S* _Nonnull;
  338. // --- import_decl_pointer_return_type.carbon
  339. library "[[@TEST_NAME]]";
  340. import Cpp library "decl_pointer_return_type.h";
  341. fn F() {
  342. //@dump-sem-ir-begin
  343. Cpp.foo();
  344. //@dump-sem-ir-end
  345. }
  346. // ============================================================================
  347. // Pointer to defined struct as return type
  348. // ============================================================================
  349. // --- definition_pointer_return_type.h
  350. struct S {};
  351. auto foo() -> S* _Nonnull;
  352. // --- import_definition_pointer_return_type.carbon
  353. library "[[@TEST_NAME]]";
  354. import Cpp library "definition_pointer_return_type.h";
  355. fn F() {
  356. //@dump-sem-ir-begin
  357. Cpp.foo();
  358. //@dump-sem-ir-end
  359. }
  360. // CHECK:STDOUT: --- import_definition_no_data_members_value_param_type.carbon
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: constants {
  363. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  364. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  365. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  366. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  367. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  368. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  369. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  370. // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete]
  371. // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete]
  372. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.d46: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  373. // CHECK:STDOUT: %T.as.Destroy.impl.Op.062: %T.as.Destroy.impl.Op.type.d46 = struct_value () [concrete]
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: imports {
  377. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  378. // CHECK:STDOUT: .foo = %.a21
  379. // CHECK:STDOUT: .S = %S.decl
  380. // CHECK:STDOUT: import Cpp//...
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  383. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  384. // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] {
  385. // CHECK:STDOUT: <elided>
  386. // CHECK:STDOUT: } {
  387. // CHECK:STDOUT: <elided>
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: fn @F() {
  392. // CHECK:STDOUT: !entry:
  393. // CHECK:STDOUT: %Cpp.ref.loc8_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  394. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  395. // CHECK:STDOUT: %.loc8_12.1: %empty_struct_type = struct_literal ()
  396. // CHECK:STDOUT: %Cpp.ref.loc8_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  397. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  398. // CHECK:STDOUT: %.loc8_12.2: ref %S = temporary_storage
  399. // CHECK:STDOUT: %.loc8_12.3: init %S = class_init (), %.loc8_12.2 [concrete = constants.%S.val]
  400. // CHECK:STDOUT: %.loc8_12.4: ref %S = temporary %.loc8_12.2, %.loc8_12.3
  401. // CHECK:STDOUT: %.loc8_14.1: ref %S = converted %.loc8_12.1, %.loc8_12.4
  402. // CHECK:STDOUT: %.loc8_14.2: %S = bind_value %.loc8_14.1
  403. // CHECK:STDOUT: %.loc8_14.3: ref %S = value_as_ref %.loc8_14.2
  404. // CHECK:STDOUT: %addr.loc8_22: %ptr.5c7 = addr_of %.loc8_14.3
  405. // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr.loc8_22)
  406. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc8_12.4, constants.%T.as.Destroy.impl.Op.062
  407. // CHECK:STDOUT: <elided>
  408. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc8_12.4, %T.as.Destroy.impl.Op.specific_fn
  409. // CHECK:STDOUT: %addr.loc8_12: %ptr.5c7 = addr_of %.loc8_12.4
  410. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc8_12)
  411. // CHECK:STDOUT: <elided>
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: --- fail_import_non_copyable_param_type.carbon
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: constants {
  417. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  418. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  419. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  420. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  421. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  422. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  423. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  424. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  425. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.d46: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  426. // CHECK:STDOUT: %T.as.Destroy.impl.Op.062: %T.as.Destroy.impl.Op.type.d46 = struct_value () [concrete]
  427. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: imports {
  431. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  432. // CHECK:STDOUT: .foo = %.a21
  433. // CHECK:STDOUT: .S = %S.decl
  434. // CHECK:STDOUT: import Cpp//...
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  437. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  438. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  439. // CHECK:STDOUT: <elided>
  440. // CHECK:STDOUT: } {
  441. // CHECK:STDOUT: <elided>
  442. // CHECK:STDOUT: }
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: fn @F() {
  446. // CHECK:STDOUT: !entry:
  447. // CHECK:STDOUT: %Cpp.ref.loc24_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  448. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  449. // CHECK:STDOUT: %.loc24_12.1: %empty_struct_type = struct_literal ()
  450. // CHECK:STDOUT: %Cpp.ref.loc24_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  451. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  452. // CHECK:STDOUT: %.loc24_12.2: ref %S = temporary_storage
  453. // CHECK:STDOUT: %.loc24_12.3: init %S = class_init (), %.loc24_12.2 [concrete = constants.%S.val]
  454. // CHECK:STDOUT: %.loc24_12.4: ref %S = temporary %.loc24_12.2, %.loc24_12.3
  455. // CHECK:STDOUT: %.loc24_14.1: ref %S = converted %.loc24_12.1, %.loc24_12.4
  456. // CHECK:STDOUT: %.loc24_14.2: %S = bind_value %.loc24_14.1
  457. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(%.loc24_14.2)
  458. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc24_12.4, constants.%T.as.Destroy.impl.Op.062
  459. // CHECK:STDOUT: <elided>
  460. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc24_12.4, %T.as.Destroy.impl.Op.specific_fn
  461. // CHECK:STDOUT: %addr: %ptr.5c7 = addr_of %.loc24_12.4
  462. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  463. // CHECK:STDOUT: <elided>
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: --- fail_todo_import_definition_single_data_member_value_param_type.carbon
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: constants {
  469. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  470. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @As.Convert [concrete]
  471. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  472. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [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 = %.a21
  478. // CHECK:STDOUT: .S = %S.decl
  479. // CHECK:STDOUT: import Cpp//...
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  482. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @As.Convert [concrete = constants.%empty_struct]
  483. // CHECK:STDOUT: }
  484. // CHECK:STDOUT:
  485. // CHECK:STDOUT: fn @F() {
  486. // CHECK:STDOUT: !entry:
  487. // CHECK:STDOUT: %Cpp.ref.loc15_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  488. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  489. // CHECK:STDOUT: %.loc15_12: %empty_struct_type = struct_literal ()
  490. // CHECK:STDOUT: %Cpp.ref.loc15_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  491. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  492. // CHECK:STDOUT: %.loc15_14: %S = converted %.loc15_12, <error> [concrete = <error>]
  493. // CHECK:STDOUT: <elided>
  494. // CHECK:STDOUT: }
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: --- fail_todo_import_definition_multiple_data_members_value_param_type.carbon
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: constants {
  499. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  500. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @As.Convert [concrete]
  501. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  502. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  503. // CHECK:STDOUT: }
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: imports {
  506. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  507. // CHECK:STDOUT: .foo = %.a21
  508. // CHECK:STDOUT: .S = %S.decl
  509. // CHECK:STDOUT: import Cpp//...
  510. // CHECK:STDOUT: }
  511. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  512. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @As.Convert [concrete = constants.%empty_struct]
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: fn @F() {
  516. // CHECK:STDOUT: !entry:
  517. // CHECK:STDOUT: %Cpp.ref.loc15_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  518. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  519. // CHECK:STDOUT: %.loc15_12: %empty_struct_type = struct_literal ()
  520. // CHECK:STDOUT: %Cpp.ref.loc15_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  521. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  522. // CHECK:STDOUT: %.loc15_14: %S = converted %.loc15_12, <error> [concrete = <error>]
  523. // CHECK:STDOUT: <elided>
  524. // CHECK:STDOUT: }
  525. // CHECK:STDOUT:
  526. // CHECK:STDOUT: --- import_definition_in_namespace_value_param_type.carbon
  527. // CHECK:STDOUT:
  528. // CHECK:STDOUT: constants {
  529. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  530. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  531. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  532. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  533. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  534. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  535. // CHECK:STDOUT: %pattern_type.cd8: type = pattern_type %S [concrete]
  536. // CHECK:STDOUT: %ptr.edf: type = ptr_type %S [concrete]
  537. // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete]
  538. // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete]
  539. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.47c: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  540. // CHECK:STDOUT: %T.as.Destroy.impl.Op.ee3: %T.as.Destroy.impl.Op.type.47c = struct_value () [concrete]
  541. // CHECK:STDOUT: }
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: imports {
  544. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  545. // CHECK:STDOUT: .foo = %.a21
  546. // CHECK:STDOUT: .N = %N
  547. // CHECK:STDOUT: import Cpp//...
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: %N: <namespace> = namespace [concrete] {
  550. // CHECK:STDOUT: .S = %S.decl
  551. // CHECK:STDOUT: import Cpp//...
  552. // CHECK:STDOUT: }
  553. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  554. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  555. // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] {
  556. // CHECK:STDOUT: <elided>
  557. // CHECK:STDOUT: } {
  558. // CHECK:STDOUT: <elided>
  559. // CHECK:STDOUT: }
  560. // CHECK:STDOUT: }
  561. // CHECK:STDOUT:
  562. // CHECK:STDOUT: fn @F() {
  563. // CHECK:STDOUT: !entry:
  564. // CHECK:STDOUT: %Cpp.ref.loc8_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  565. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  566. // CHECK:STDOUT: %.loc8_12.1: %empty_struct_type = struct_literal ()
  567. // CHECK:STDOUT: %Cpp.ref.loc8_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  568. // CHECK:STDOUT: %N.ref.loc8: <namespace> = name_ref N, imports.%N [concrete = imports.%N]
  569. // CHECK:STDOUT: %S.ref.loc8: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  570. // CHECK:STDOUT: %.loc8_12.2: ref %S = temporary_storage
  571. // CHECK:STDOUT: %.loc8_12.3: init %S = class_init (), %.loc8_12.2 [concrete = constants.%S.val]
  572. // CHECK:STDOUT: %.loc8_12.4: ref %S = temporary %.loc8_12.2, %.loc8_12.3
  573. // CHECK:STDOUT: %.loc8_14.1: ref %S = converted %.loc8_12.1, %.loc8_12.4
  574. // CHECK:STDOUT: %.loc8_14.2: %S = bind_value %.loc8_14.1
  575. // CHECK:STDOUT: %.loc8_14.3: ref %S = value_as_ref %.loc8_14.2
  576. // CHECK:STDOUT: %addr.loc8_24: %ptr.edf = addr_of %.loc8_14.3
  577. // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr.loc8_24)
  578. // CHECK:STDOUT: name_binding_decl {
  579. // CHECK:STDOUT: %x.patt: %pattern_type.cd8 = binding_pattern x [concrete]
  580. // CHECK:STDOUT: %x.var_patt: %pattern_type.cd8 = var_pattern %x.patt [concrete]
  581. // CHECK:STDOUT: }
  582. // CHECK:STDOUT: %x.var: ref %S = var %x.var_patt
  583. // CHECK:STDOUT: %.loc10: type = splice_block %S.ref.loc10 [concrete = constants.%S] {
  584. // CHECK:STDOUT: %Cpp.ref.loc10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  585. // CHECK:STDOUT: %N.ref.loc10: <namespace> = name_ref N, imports.%N [concrete = imports.%N]
  586. // CHECK:STDOUT: %S.ref.loc10: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  587. // CHECK:STDOUT: }
  588. // CHECK:STDOUT: %x: ref %S = bind_name x, %x.var
  589. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc10: <bound method> = bound_method %x.var, constants.%T.as.Destroy.impl.Op.ee3
  590. // CHECK:STDOUT: <elided>
  591. // CHECK:STDOUT: %bound_method.loc10: <bound method> = bound_method %x.var, %T.as.Destroy.impl.Op.specific_fn.1
  592. // CHECK:STDOUT: %addr.loc10: %ptr.edf = addr_of %x.var
  593. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc10: init %empty_tuple.type = call %bound_method.loc10(%addr.loc10)
  594. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc8: <bound method> = bound_method %.loc8_12.4, constants.%T.as.Destroy.impl.Op.ee3
  595. // CHECK:STDOUT: <elided>
  596. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %.loc8_12.4, %T.as.Destroy.impl.Op.specific_fn.2
  597. // CHECK:STDOUT: %addr.loc8_12: %ptr.edf = addr_of %.loc8_12.4
  598. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc8: init %empty_tuple.type = call %bound_method.loc8(%addr.loc8_12)
  599. // CHECK:STDOUT: <elided>
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT:
  602. // CHECK:STDOUT: --- import_definition_in_relative_namespace_value_param_type.carbon
  603. // CHECK:STDOUT:
  604. // CHECK:STDOUT: constants {
  605. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  606. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  607. // CHECK:STDOUT: %.92e: type = cpp_overload_set_type @foo [concrete]
  608. // CHECK:STDOUT: %empty_struct: %.92e = struct_value () [concrete]
  609. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  610. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  611. // CHECK:STDOUT: %ptr.887: type = ptr_type %S [concrete]
  612. // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete]
  613. // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete]
  614. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.ddb: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  615. // CHECK:STDOUT: %T.as.Destroy.impl.Op.d79: %T.as.Destroy.impl.Op.type.ddb = struct_value () [concrete]
  616. // CHECK:STDOUT: }
  617. // CHECK:STDOUT:
  618. // CHECK:STDOUT: imports {
  619. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  620. // CHECK:STDOUT: .N1 = %N1
  621. // CHECK:STDOUT: import Cpp//...
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT: %N1: <namespace> = namespace [concrete] {
  624. // CHECK:STDOUT: .foo = %.218
  625. // CHECK:STDOUT: .N2 = %N2
  626. // CHECK:STDOUT: import Cpp//...
  627. // CHECK:STDOUT: }
  628. // CHECK:STDOUT: %N2: <namespace> = namespace [concrete] {
  629. // CHECK:STDOUT: .S = %S.decl
  630. // CHECK:STDOUT: import Cpp//...
  631. // CHECK:STDOUT: }
  632. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  633. // CHECK:STDOUT: %.218: %.92e = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  634. // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] {
  635. // CHECK:STDOUT: <elided>
  636. // CHECK:STDOUT: } {
  637. // CHECK:STDOUT: <elided>
  638. // CHECK:STDOUT: }
  639. // CHECK:STDOUT: }
  640. // CHECK:STDOUT:
  641. // CHECK:STDOUT: fn @F() {
  642. // CHECK:STDOUT: !entry:
  643. // CHECK:STDOUT: %Cpp.ref.loc8_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  644. // CHECK:STDOUT: %N1.ref.loc8_6: <namespace> = name_ref N1, imports.%N1 [concrete = imports.%N1]
  645. // CHECK:STDOUT: %foo.ref: %.92e = name_ref foo, imports.%.218 [concrete = constants.%empty_struct]
  646. // CHECK:STDOUT: %.loc8_15.1: %empty_struct_type = struct_literal ()
  647. // CHECK:STDOUT: %Cpp.ref.loc8_20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  648. // CHECK:STDOUT: %N1.ref.loc8_23: <namespace> = name_ref N1, imports.%N1 [concrete = imports.%N1]
  649. // CHECK:STDOUT: %N2.ref: <namespace> = name_ref N2, imports.%N2 [concrete = imports.%N2]
  650. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  651. // CHECK:STDOUT: %.loc8_15.2: ref %S = temporary_storage
  652. // CHECK:STDOUT: %.loc8_15.3: init %S = class_init (), %.loc8_15.2 [concrete = constants.%S.val]
  653. // CHECK:STDOUT: %.loc8_15.4: ref %S = temporary %.loc8_15.2, %.loc8_15.3
  654. // CHECK:STDOUT: %.loc8_17.1: ref %S = converted %.loc8_15.1, %.loc8_15.4
  655. // CHECK:STDOUT: %.loc8_17.2: %S = bind_value %.loc8_17.1
  656. // CHECK:STDOUT: %.loc8_17.3: ref %S = value_as_ref %.loc8_17.2
  657. // CHECK:STDOUT: %addr.loc8_31: %ptr.887 = addr_of %.loc8_17.3
  658. // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr.loc8_31)
  659. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc8_15.4, constants.%T.as.Destroy.impl.Op.d79
  660. // CHECK:STDOUT: <elided>
  661. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc8_15.4, %T.as.Destroy.impl.Op.specific_fn
  662. // CHECK:STDOUT: %addr.loc8_15: %ptr.887 = addr_of %.loc8_15.4
  663. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc8_15)
  664. // CHECK:STDOUT: <elided>
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT:
  667. // CHECK:STDOUT: --- import_definition_in_outer_definition.carbon
  668. // CHECK:STDOUT:
  669. // CHECK:STDOUT: constants {
  670. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  671. // CHECK:STDOUT: %O: type = class_type @O [concrete]
  672. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  673. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  674. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  675. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  676. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  677. // CHECK:STDOUT: %ptr.149: type = ptr_type %S [concrete]
  678. // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete]
  679. // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete]
  680. // CHECK:STDOUT: %pattern_type.cff: type = pattern_type %O [concrete]
  681. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.9f7: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%O) [concrete]
  682. // CHECK:STDOUT: %T.as.Destroy.impl.Op.273: %T.as.Destroy.impl.Op.type.9f7 = struct_value () [concrete]
  683. // CHECK:STDOUT: %ptr.820: type = ptr_type %O [concrete]
  684. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.752: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  685. // CHECK:STDOUT: %T.as.Destroy.impl.Op.c41: %T.as.Destroy.impl.Op.type.752 = struct_value () [concrete]
  686. // CHECK:STDOUT: }
  687. // CHECK:STDOUT:
  688. // CHECK:STDOUT: imports {
  689. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  690. // CHECK:STDOUT: .foo = %.a21
  691. // CHECK:STDOUT: .O = %O.decl
  692. // CHECK:STDOUT: import Cpp//...
  693. // CHECK:STDOUT: }
  694. // CHECK:STDOUT: %O.decl: type = class_decl @O [concrete = constants.%O] {} {}
  695. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  696. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  697. // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] {
  698. // CHECK:STDOUT: <elided>
  699. // CHECK:STDOUT: } {
  700. // CHECK:STDOUT: <elided>
  701. // CHECK:STDOUT: }
  702. // CHECK:STDOUT: }
  703. // CHECK:STDOUT:
  704. // CHECK:STDOUT: fn @F() {
  705. // CHECK:STDOUT: !entry:
  706. // CHECK:STDOUT: %Cpp.ref.loc8_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  707. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  708. // CHECK:STDOUT: %.loc8_12.1: %empty_struct_type = struct_literal ()
  709. // CHECK:STDOUT: %Cpp.ref.loc8_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  710. // CHECK:STDOUT: %O.ref.loc8: type = name_ref O, imports.%O.decl [concrete = constants.%O]
  711. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  712. // CHECK:STDOUT: %.loc8_12.2: ref %S = temporary_storage
  713. // CHECK:STDOUT: %.loc8_12.3: init %S = class_init (), %.loc8_12.2 [concrete = constants.%S.val]
  714. // CHECK:STDOUT: %.loc8_12.4: ref %S = temporary %.loc8_12.2, %.loc8_12.3
  715. // CHECK:STDOUT: %.loc8_14.1: ref %S = converted %.loc8_12.1, %.loc8_12.4
  716. // CHECK:STDOUT: %.loc8_14.2: %S = bind_value %.loc8_14.1
  717. // CHECK:STDOUT: %.loc8_14.3: ref %S = value_as_ref %.loc8_14.2
  718. // CHECK:STDOUT: %addr.loc8_24: %ptr.149 = addr_of %.loc8_14.3
  719. // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr.loc8_24)
  720. // CHECK:STDOUT: name_binding_decl {
  721. // CHECK:STDOUT: %x.patt: %pattern_type.cff = binding_pattern x [concrete]
  722. // CHECK:STDOUT: %x.var_patt: %pattern_type.cff = var_pattern %x.patt [concrete]
  723. // CHECK:STDOUT: }
  724. // CHECK:STDOUT: %x.var: ref %O = var %x.var_patt
  725. // CHECK:STDOUT: %.loc9: type = splice_block %O.ref.loc9 [concrete = constants.%O] {
  726. // CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  727. // CHECK:STDOUT: %O.ref.loc9: type = name_ref O, imports.%O.decl [concrete = constants.%O]
  728. // CHECK:STDOUT: }
  729. // CHECK:STDOUT: %x: ref %O = bind_name x, %x.var
  730. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc9: <bound method> = bound_method %x.var, constants.%T.as.Destroy.impl.Op.273
  731. // CHECK:STDOUT: <elided>
  732. // CHECK:STDOUT: %bound_method.loc9: <bound method> = bound_method %x.var, %T.as.Destroy.impl.Op.specific_fn.1
  733. // CHECK:STDOUT: %addr.loc9: %ptr.820 = addr_of %x.var
  734. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc9: init %empty_tuple.type = call %bound_method.loc9(%addr.loc9)
  735. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc8: <bound method> = bound_method %.loc8_12.4, constants.%T.as.Destroy.impl.Op.c41
  736. // CHECK:STDOUT: <elided>
  737. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %.loc8_12.4, %T.as.Destroy.impl.Op.specific_fn.2
  738. // CHECK:STDOUT: %addr.loc8_12: %ptr.149 = addr_of %.loc8_12.4
  739. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc8: init %empty_tuple.type = call %bound_method.loc8(%addr.loc8_12)
  740. // CHECK:STDOUT: <elided>
  741. // CHECK:STDOUT: }
  742. // CHECK:STDOUT:
  743. // CHECK:STDOUT: --- import_definition_and_static_method_call_before.carbon
  744. // CHECK:STDOUT:
  745. // CHECK:STDOUT: constants {
  746. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  747. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  748. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  749. // CHECK:STDOUT: %.bce: type = cpp_overload_set_type @foo [concrete]
  750. // CHECK:STDOUT: %empty_struct.21b: %.bce = struct_value () [concrete]
  751. // CHECK:STDOUT: %S.bar.type: type = fn_type @S.bar [concrete]
  752. // CHECK:STDOUT: %S.bar: %S.bar.type = struct_value () [concrete]
  753. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo__carbon_thunk [concrete]
  754. // CHECK:STDOUT: %empty_struct.109: %.c5d = struct_value () [concrete]
  755. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  756. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  757. // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete]
  758. // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete]
  759. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.d46: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  760. // CHECK:STDOUT: %T.as.Destroy.impl.Op.062: %T.as.Destroy.impl.Op.type.d46 = struct_value () [concrete]
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT:
  763. // CHECK:STDOUT: imports {
  764. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  765. // CHECK:STDOUT: .S = %S.decl
  766. // CHECK:STDOUT: .foo = %.a21
  767. // CHECK:STDOUT: import Cpp//...
  768. // CHECK:STDOUT: }
  769. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  770. // CHECK:STDOUT: %.8f2: %.bce = cpp_overload_set_value @foo [concrete = constants.%empty_struct.21b]
  771. // CHECK:STDOUT: %S.bar.decl: %S.bar.type = fn_decl @S.bar [concrete = constants.%S.bar] {} {}
  772. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo__carbon_thunk [concrete = constants.%empty_struct.109]
  773. // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] {
  774. // CHECK:STDOUT: <elided>
  775. // CHECK:STDOUT: } {
  776. // CHECK:STDOUT: <elided>
  777. // CHECK:STDOUT: }
  778. // CHECK:STDOUT: }
  779. // CHECK:STDOUT:
  780. // CHECK:STDOUT: fn @F() {
  781. // CHECK:STDOUT: !entry:
  782. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  783. // CHECK:STDOUT: %S.ref.loc8: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  784. // CHECK:STDOUT: %bar.ref: %.bce = name_ref bar, imports.%.8f2 [concrete = constants.%empty_struct.21b]
  785. // CHECK:STDOUT: %S.bar.call: init %empty_tuple.type = call imports.%S.bar.decl()
  786. // CHECK:STDOUT: %Cpp.ref.loc9_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  787. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct.109]
  788. // CHECK:STDOUT: %.loc9_12.1: %empty_struct_type = struct_literal ()
  789. // CHECK:STDOUT: %Cpp.ref.loc9_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  790. // CHECK:STDOUT: %S.ref.loc9: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  791. // CHECK:STDOUT: %.loc9_12.2: ref %S = temporary_storage
  792. // CHECK:STDOUT: %.loc9_12.3: init %S = class_init (), %.loc9_12.2 [concrete = constants.%S.val]
  793. // CHECK:STDOUT: %.loc9_12.4: ref %S = temporary %.loc9_12.2, %.loc9_12.3
  794. // CHECK:STDOUT: %.loc9_14.1: ref %S = converted %.loc9_12.1, %.loc9_12.4
  795. // CHECK:STDOUT: %.loc9_14.2: %S = bind_value %.loc9_14.1
  796. // CHECK:STDOUT: %.loc9_14.3: ref %S = value_as_ref %.loc9_14.2
  797. // CHECK:STDOUT: %addr.loc9_22: %ptr.5c7 = addr_of %.loc9_14.3
  798. // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr.loc9_22)
  799. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc9_12.4, constants.%T.as.Destroy.impl.Op.062
  800. // CHECK:STDOUT: <elided>
  801. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc9_12.4, %T.as.Destroy.impl.Op.specific_fn
  802. // CHECK:STDOUT: %addr.loc9_12: %ptr.5c7 = addr_of %.loc9_12.4
  803. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc9_12)
  804. // CHECK:STDOUT: <elided>
  805. // CHECK:STDOUT: }
  806. // CHECK:STDOUT:
  807. // CHECK:STDOUT: --- import_definition_and_static_method_call_after.carbon
  808. // CHECK:STDOUT:
  809. // CHECK:STDOUT: constants {
  810. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  811. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  812. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo__carbon_thunk [concrete]
  813. // CHECK:STDOUT: %empty_struct.109: %.c5d = struct_value () [concrete]
  814. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  815. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  816. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  817. // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete]
  818. // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete]
  819. // CHECK:STDOUT: %.bce: type = cpp_overload_set_type @S.bar [concrete]
  820. // CHECK:STDOUT: %empty_struct.21b: %.bce = struct_value () [concrete]
  821. // CHECK:STDOUT: %S.bar.type: type = fn_type @S.bar [concrete]
  822. // CHECK:STDOUT: %S.bar: %S.bar.type = struct_value () [concrete]
  823. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.d46: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  824. // CHECK:STDOUT: %T.as.Destroy.impl.Op.062: %T.as.Destroy.impl.Op.type.d46 = struct_value () [concrete]
  825. // CHECK:STDOUT: }
  826. // CHECK:STDOUT:
  827. // CHECK:STDOUT: imports {
  828. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  829. // CHECK:STDOUT: .foo = %.a21
  830. // CHECK:STDOUT: .S = %S.decl
  831. // CHECK:STDOUT: import Cpp//...
  832. // CHECK:STDOUT: }
  833. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  834. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo__carbon_thunk [concrete = constants.%empty_struct.109]
  835. // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] {
  836. // CHECK:STDOUT: <elided>
  837. // CHECK:STDOUT: } {
  838. // CHECK:STDOUT: <elided>
  839. // CHECK:STDOUT: }
  840. // CHECK:STDOUT: %.8f2: %.bce = cpp_overload_set_value @S.bar [concrete = constants.%empty_struct.21b]
  841. // CHECK:STDOUT: %S.bar.decl: %S.bar.type = fn_decl @S.bar [concrete = constants.%S.bar] {} {}
  842. // CHECK:STDOUT: }
  843. // CHECK:STDOUT:
  844. // CHECK:STDOUT: fn @F() {
  845. // CHECK:STDOUT: !entry:
  846. // CHECK:STDOUT: %Cpp.ref.loc8_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  847. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct.109]
  848. // CHECK:STDOUT: %.loc8_12.1: %empty_struct_type = struct_literal ()
  849. // CHECK:STDOUT: %Cpp.ref.loc8_17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  850. // CHECK:STDOUT: %S.ref.loc8: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  851. // CHECK:STDOUT: %.loc8_12.2: ref %S = temporary_storage
  852. // CHECK:STDOUT: %.loc8_12.3: init %S = class_init (), %.loc8_12.2 [concrete = constants.%S.val]
  853. // CHECK:STDOUT: %.loc8_12.4: ref %S = temporary %.loc8_12.2, %.loc8_12.3
  854. // CHECK:STDOUT: %.loc8_14.1: ref %S = converted %.loc8_12.1, %.loc8_12.4
  855. // CHECK:STDOUT: %.loc8_14.2: %S = bind_value %.loc8_14.1
  856. // CHECK:STDOUT: %.loc8_14.3: ref %S = value_as_ref %.loc8_14.2
  857. // CHECK:STDOUT: %addr.loc8_22: %ptr.5c7 = addr_of %.loc8_14.3
  858. // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr.loc8_22)
  859. // CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  860. // CHECK:STDOUT: %S.ref.loc9: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  861. // CHECK:STDOUT: %bar.ref: %.bce = name_ref bar, imports.%.8f2 [concrete = constants.%empty_struct.21b]
  862. // CHECK:STDOUT: %S.bar.call: init %empty_tuple.type = call imports.%S.bar.decl()
  863. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc8_12.4, constants.%T.as.Destroy.impl.Op.062
  864. // CHECK:STDOUT: <elided>
  865. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc8_12.4, %T.as.Destroy.impl.Op.specific_fn
  866. // CHECK:STDOUT: %addr.loc8_12: %ptr.5c7 = addr_of %.loc8_12.4
  867. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc8_12)
  868. // CHECK:STDOUT: <elided>
  869. // CHECK:STDOUT: }
  870. // CHECK:STDOUT:
  871. // CHECK:STDOUT: --- import_decl_pointer_param_type.carbon
  872. // CHECK:STDOUT:
  873. // CHECK:STDOUT: constants {
  874. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  875. // CHECK:STDOUT: %ptr: type = ptr_type %S [concrete]
  876. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  877. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  878. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  879. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  880. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  881. // CHECK:STDOUT: }
  882. // CHECK:STDOUT:
  883. // CHECK:STDOUT: imports {
  884. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  885. // CHECK:STDOUT: .S = %S.decl
  886. // CHECK:STDOUT: .foo = %.a21
  887. // CHECK:STDOUT: import Cpp//...
  888. // CHECK:STDOUT: }
  889. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  890. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  891. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  892. // CHECK:STDOUT: <elided>
  893. // CHECK:STDOUT: } {
  894. // CHECK:STDOUT: <elided>
  895. // CHECK:STDOUT: }
  896. // CHECK:STDOUT: }
  897. // CHECK:STDOUT:
  898. // CHECK:STDOUT: fn @F(%s.param: %ptr) {
  899. // CHECK:STDOUT: !entry:
  900. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  901. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  902. // CHECK:STDOUT: %s.ref: %ptr = name_ref s, %s
  903. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(%s.ref)
  904. // CHECK:STDOUT: <elided>
  905. // CHECK:STDOUT: }
  906. // CHECK:STDOUT:
  907. // CHECK:STDOUT: --- import_definition_pointer_param_type.carbon
  908. // CHECK:STDOUT:
  909. // CHECK:STDOUT: constants {
  910. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  911. // CHECK:STDOUT: %ptr: type = ptr_type %S [concrete]
  912. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  913. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  914. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  915. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  916. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  917. // CHECK:STDOUT: }
  918. // CHECK:STDOUT:
  919. // CHECK:STDOUT: imports {
  920. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  921. // CHECK:STDOUT: .S = %S.decl
  922. // CHECK:STDOUT: .foo = %.a21
  923. // CHECK:STDOUT: import Cpp//...
  924. // CHECK:STDOUT: }
  925. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  926. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  927. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  928. // CHECK:STDOUT: <elided>
  929. // CHECK:STDOUT: } {
  930. // CHECK:STDOUT: <elided>
  931. // CHECK:STDOUT: }
  932. // CHECK:STDOUT: }
  933. // CHECK:STDOUT:
  934. // CHECK:STDOUT: fn @F(%s.param: %ptr) {
  935. // CHECK:STDOUT: !entry:
  936. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  937. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  938. // CHECK:STDOUT: %s.ref: %ptr = name_ref s, %s
  939. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(%s.ref)
  940. // CHECK:STDOUT: <elided>
  941. // CHECK:STDOUT: }
  942. // CHECK:STDOUT:
  943. // CHECK:STDOUT: --- import_definition_value_return_type.carbon
  944. // CHECK:STDOUT:
  945. // CHECK:STDOUT: constants {
  946. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  947. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  948. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  949. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  950. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  951. // CHECK:STDOUT: %foo__carbon_thunk.type: type = fn_type @foo__carbon_thunk [concrete]
  952. // CHECK:STDOUT: %foo__carbon_thunk: %foo__carbon_thunk.type = struct_value () [concrete]
  953. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.d46: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%S) [concrete]
  954. // CHECK:STDOUT: %T.as.Destroy.impl.Op.062: %T.as.Destroy.impl.Op.type.d46 = struct_value () [concrete]
  955. // CHECK:STDOUT: }
  956. // CHECK:STDOUT:
  957. // CHECK:STDOUT: imports {
  958. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  959. // CHECK:STDOUT: .foo = %.a21
  960. // CHECK:STDOUT: import Cpp//...
  961. // CHECK:STDOUT: }
  962. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  963. // CHECK:STDOUT: %foo__carbon_thunk.decl: %foo__carbon_thunk.type = fn_decl @foo__carbon_thunk [concrete = constants.%foo__carbon_thunk] {
  964. // CHECK:STDOUT: <elided>
  965. // CHECK:STDOUT: } {
  966. // CHECK:STDOUT: <elided>
  967. // CHECK:STDOUT: }
  968. // CHECK:STDOUT: }
  969. // CHECK:STDOUT:
  970. // CHECK:STDOUT: fn @F() {
  971. // CHECK:STDOUT: !entry:
  972. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  973. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  974. // CHECK:STDOUT: %.loc8_11.1: ref %S = temporary_storage
  975. // CHECK:STDOUT: %addr.loc8_11.1: %ptr.5c7 = addr_of %.loc8_11.1
  976. // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr.loc8_11.1)
  977. // CHECK:STDOUT: %.loc8_11.2: init %S = in_place_init %foo__carbon_thunk.call, %.loc8_11.1
  978. // CHECK:STDOUT: %.loc8_11.3: ref %S = temporary %.loc8_11.1, %.loc8_11.2
  979. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc8_11.3, constants.%T.as.Destroy.impl.Op.062
  980. // CHECK:STDOUT: <elided>
  981. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc8_11.3, %T.as.Destroy.impl.Op.specific_fn
  982. // CHECK:STDOUT: %addr.loc8_11.2: %ptr.5c7 = addr_of %.loc8_11.3
  983. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc8_11.2)
  984. // CHECK:STDOUT: <elided>
  985. // CHECK:STDOUT: }
  986. // CHECK:STDOUT:
  987. // CHECK:STDOUT: --- import_decl_pointer_return_type.carbon
  988. // CHECK:STDOUT:
  989. // CHECK:STDOUT: constants {
  990. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  991. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  992. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  993. // CHECK:STDOUT: %ptr: type = ptr_type %S [concrete]
  994. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  995. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  996. // CHECK:STDOUT: }
  997. // CHECK:STDOUT:
  998. // CHECK:STDOUT: imports {
  999. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1000. // CHECK:STDOUT: .foo = %.a21
  1001. // CHECK:STDOUT: import Cpp//...
  1002. // CHECK:STDOUT: }
  1003. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  1004. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  1005. // CHECK:STDOUT: <elided>
  1006. // CHECK:STDOUT: } {
  1007. // CHECK:STDOUT: <elided>
  1008. // CHECK:STDOUT: }
  1009. // CHECK:STDOUT: }
  1010. // CHECK:STDOUT:
  1011. // CHECK:STDOUT: fn @F() {
  1012. // CHECK:STDOUT: !entry:
  1013. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1014. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  1015. // CHECK:STDOUT: %foo.call: init %ptr = call imports.%foo.decl()
  1016. // CHECK:STDOUT: <elided>
  1017. // CHECK:STDOUT: }
  1018. // CHECK:STDOUT:
  1019. // CHECK:STDOUT: --- import_definition_pointer_return_type.carbon
  1020. // CHECK:STDOUT:
  1021. // CHECK:STDOUT: constants {
  1022. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  1023. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  1024. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  1025. // CHECK:STDOUT: %ptr: type = ptr_type %S [concrete]
  1026. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  1027. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  1028. // CHECK:STDOUT: }
  1029. // CHECK:STDOUT:
  1030. // CHECK:STDOUT: imports {
  1031. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1032. // CHECK:STDOUT: .foo = %.a21
  1033. // CHECK:STDOUT: import Cpp//...
  1034. // CHECK:STDOUT: }
  1035. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  1036. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  1037. // CHECK:STDOUT: <elided>
  1038. // CHECK:STDOUT: } {
  1039. // CHECK:STDOUT: <elided>
  1040. // CHECK:STDOUT: }
  1041. // CHECK:STDOUT: }
  1042. // CHECK:STDOUT:
  1043. // CHECK:STDOUT: fn @F() {
  1044. // CHECK:STDOUT: !entry:
  1045. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1046. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  1047. // CHECK:STDOUT: %foo.call: init %ptr = call imports.%foo.decl()
  1048. // CHECK:STDOUT: <elided>
  1049. // CHECK:STDOUT: }
  1050. // CHECK:STDOUT: