reference.carbon 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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/reference.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/reference.carbon
  12. // ============================================================================
  13. // Lvalue reference as a parameter type
  14. // ============================================================================
  15. // --- param_lvalue_ref.h
  16. struct S {};
  17. struct T {};
  18. auto TakesLValue(S&) -> void;
  19. // --- call_param_lvalue_ref.carbon
  20. library "[[@TEST_NAME]]";
  21. import Cpp library "param_lvalue_ref.h";
  22. fn F() {
  23. //@dump-sem-ir-begin
  24. var s: Cpp.S = {};
  25. Cpp.TakesLValue(s);
  26. //@dump-sem-ir-end
  27. }
  28. // --- fail_param_lvalue_ref.carbon
  29. library "[[@TEST_NAME]]";
  30. import Cpp library "param_lvalue_ref.h";
  31. fn F() {
  32. //@dump-sem-ir-begin
  33. var v: Cpp.S;
  34. let s: Cpp.S = v;
  35. // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+8]]:20: error: no matching function for call to 'TakesLValue' [CppInteropParseError]
  36. // CHECK:STDERR: 18 | Cpp.TakesLValue(s);
  37. // CHECK:STDERR: | ^
  38. // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE-9]]:10: in file included here [InCppInclude]
  39. // CHECK:STDERR: ./param_lvalue_ref.h:5:6: note: candidate function not viable: expects an lvalue for 1st argument [CppInteropParseNote]
  40. // CHECK:STDERR: 5 | auto TakesLValue(S&) -> void;
  41. // CHECK:STDERR: | ^ ~~
  42. // CHECK:STDERR:
  43. Cpp.TakesLValue(s);
  44. var t: Cpp.T;
  45. // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+8]]:20: error: no matching function for call to 'TakesLValue' [CppInteropParseError]
  46. // CHECK:STDERR: 29 | Cpp.TakesLValue(t);
  47. // CHECK:STDERR: | ^
  48. // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE-20]]:10: in file included here [InCppInclude]
  49. // CHECK:STDERR: ./param_lvalue_ref.h:5:6: note: candidate function not viable: no known conversion from 'T' to 'S &' for 1st argument [CppInteropParseNote]
  50. // CHECK:STDERR: 5 | auto TakesLValue(S&) -> void;
  51. // CHECK:STDERR: | ^ ~~
  52. // CHECK:STDERR:
  53. Cpp.TakesLValue(t);
  54. var u: Cpp.S;
  55. // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+8]]:35: error: no matching function for call to 'TakesLValue' [CppInteropParseError]
  56. // CHECK:STDERR: 40 | Cpp.TakesLValue(u as const Cpp.S);
  57. // CHECK:STDERR: | ^
  58. // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE-31]]:10: in file included here [InCppInclude]
  59. // CHECK:STDERR: ./param_lvalue_ref.h:5:6: note: candidate function not viable: 1st argument ('const S') would lose const qualifier [CppInteropParseNote]
  60. // CHECK:STDERR: 5 | auto TakesLValue(S&) -> void;
  61. // CHECK:STDERR: | ^ ~~
  62. // CHECK:STDERR:
  63. Cpp.TakesLValue(u as const Cpp.S);
  64. //@dump-sem-ir-end
  65. }
  66. // ============================================================================
  67. // Rvalue reference as a parameter type
  68. // ============================================================================
  69. // --- param_rvalue_ref.h
  70. struct S {};
  71. struct T {};
  72. auto TakesRValue(S&&) -> void;
  73. // --- call_param_rvalue_ref.carbon
  74. library "[[@TEST_NAME]]";
  75. import Cpp library "param_rvalue_ref.h";
  76. fn F() {
  77. //@dump-sem-ir-begin
  78. Cpp.TakesRValue({} as Cpp.S);
  79. //@dump-sem-ir-end
  80. }
  81. // --- todo_fail_param_value_arg_for_rvalue_ref.carbon
  82. library "[[@TEST_NAME]]";
  83. import Cpp library "param_rvalue_ref.h";
  84. fn F() {
  85. //@dump-sem-ir-begin
  86. // TODO: We should probably reject binding an rvalue reference to a value
  87. // expression. If we don't reject, we should instead force a copy to be made,
  88. // at least if the type has a pointer value representation, so that moving
  89. // from the reference doesn't alter tne original value.
  90. let s: Cpp.S = {};
  91. Cpp.TakesRValue(s);
  92. //@dump-sem-ir-end
  93. }
  94. // --- fail_param_rvalue_ref.carbon
  95. library "[[@TEST_NAME]]";
  96. import Cpp library "param_rvalue_ref.h";
  97. fn F() {
  98. //@dump-sem-ir-begin
  99. var s: Cpp.S;
  100. // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+8]]:20: error: no matching function for call to 'TakesRValue' [CppInteropParseError]
  101. // CHECK:STDERR: 17 | Cpp.TakesRValue(s);
  102. // CHECK:STDERR: | ^
  103. // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE-8]]:10: in file included here [InCppInclude]
  104. // CHECK:STDERR: ./param_rvalue_ref.h:5:6: note: candidate function not viable: expects an rvalue for 1st argument [CppInteropParseNote]
  105. // CHECK:STDERR: 5 | auto TakesRValue(S&&) -> void;
  106. // CHECK:STDERR: | ^ ~~~
  107. // CHECK:STDERR:
  108. Cpp.TakesRValue(s);
  109. var t: Cpp.T;
  110. // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+8]]:20: error: no matching function for call to 'TakesRValue' [CppInteropParseError]
  111. // CHECK:STDERR: 28 | Cpp.TakesRValue(t);
  112. // CHECK:STDERR: | ^
  113. // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE-19]]:10: in file included here [InCppInclude]
  114. // CHECK:STDERR: ./param_rvalue_ref.h:5:6: note: candidate function not viable: no known conversion from 'T' to 'S' for 1st argument [CppInteropParseNote]
  115. // CHECK:STDERR: 5 | auto TakesRValue(S&&) -> void;
  116. // CHECK:STDERR: | ^ ~~~
  117. // CHECK:STDERR:
  118. Cpp.TakesRValue(t);
  119. // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+8]]:47: error: no matching function for call to 'TakesRValue' [CppInteropParseError]
  120. // CHECK:STDERR: 38 | Cpp.TakesRValue(({} as Cpp.S) as const Cpp.S);
  121. // CHECK:STDERR: | ^
  122. // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE-29]]:10: in file included here [InCppInclude]
  123. // CHECK:STDERR: ./param_rvalue_ref.h:5:6: note: candidate function not viable: 1st argument ('const S') would lose const qualifier [CppInteropParseNote]
  124. // CHECK:STDERR: 5 | auto TakesRValue(S&&) -> void;
  125. // CHECK:STDERR: | ^ ~~~
  126. // CHECK:STDERR:
  127. Cpp.TakesRValue(({} as Cpp.S) as const Cpp.S);
  128. //@dump-sem-ir-end
  129. }
  130. // ============================================================================
  131. // Const reference as a parameter type
  132. // ============================================================================
  133. // --- param_const_lvalue_ref.h
  134. struct S {};
  135. struct T {};
  136. auto TakesConstLValue(const S&) -> void;
  137. // --- call_param_const_lvalue_ref.carbon
  138. library "[[@TEST_NAME]]";
  139. import Cpp library "param_const_lvalue_ref.h";
  140. fn F() {
  141. //@dump-sem-ir-begin
  142. var s: Cpp.S = {};
  143. Cpp.TakesConstLValue(s as const Cpp.S);
  144. Cpp.TakesConstLValue(s);
  145. //@dump-sem-ir-end
  146. }
  147. // --- fail_param_const_lvalue_ref.carbon
  148. library "[[@TEST_NAME]]";
  149. import Cpp library "param_const_lvalue_ref.h";
  150. fn F() {
  151. //@dump-sem-ir-begin
  152. // TODO: Should this work? We could create a temporary. Overload resolution
  153. // accepts this but the Carbon-side call fails.
  154. // TODO: The diagnostic here is wrong; we're internally using `addr` but this
  155. // is not `addr self`.
  156. let s: Cpp.S = {};
  157. // CHECK:STDERR: fail_param_const_lvalue_ref.carbon:[[@LINE+5]]:24: error: `addr self` method cannot be invoked on a value [AddrSelfIsNonRef]
  158. // CHECK:STDERR: Cpp.TakesConstLValue(s);
  159. // CHECK:STDERR: ^
  160. // CHECK:STDERR: fail_param_const_lvalue_ref.carbon: note: initializing function parameter [InCallToFunctionParam]
  161. // CHECK:STDERR:
  162. Cpp.TakesConstLValue(s);
  163. var t: Cpp.T;
  164. // CHECK:STDERR: fail_param_const_lvalue_ref.carbon:[[@LINE+8]]:25: error: no matching function for call to 'TakesConstLValue' [CppInteropParseError]
  165. // CHECK:STDERR: 29 | Cpp.TakesConstLValue(t);
  166. // CHECK:STDERR: | ^
  167. // CHECK:STDERR: fail_param_const_lvalue_ref.carbon:[[@LINE-20]]:10: in file included here [InCppInclude]
  168. // CHECK:STDERR: ./param_const_lvalue_ref.h:5:6: note: candidate function not viable: no known conversion from 'T' to 'const S' for 1st argument [CppInteropParseNote]
  169. // CHECK:STDERR: 5 | auto TakesConstLValue(const S&) -> void;
  170. // CHECK:STDERR: | ^ ~~~~~~~~
  171. // CHECK:STDERR:
  172. Cpp.TakesConstLValue(t);
  173. //@dump-sem-ir-end
  174. }
  175. // ============================================================================
  176. // Lvalue reference as return type
  177. // ============================================================================
  178. // --- fail_todo_call_return_lvalue_ref.carbon
  179. library "[[@TEST_NAME]]";
  180. import Cpp inline '''
  181. struct S {};
  182. auto ReturnsLValue() -> S&;
  183. ''';
  184. fn F() {
  185. //@dump-sem-ir-begin
  186. // CHECK:STDERR: fail_todo_call_return_lvalue_ref.carbon:[[@LINE+4]]:19: error: semantics TODO: `Unsupported: return type: S &` [SemanticsTodo]
  187. // CHECK:STDERR: let s: Cpp.S* = Cpp.ReturnsLValue();
  188. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  189. // CHECK:STDERR:
  190. let s: Cpp.S* = Cpp.ReturnsLValue();
  191. //@dump-sem-ir-end
  192. }
  193. // ============================================================================
  194. // Rvalue reference as return type
  195. // ============================================================================
  196. // --- fail_todo_call_return_rvalue_ref.carbon
  197. library "[[@TEST_NAME]]";
  198. import Cpp inline '''
  199. struct S {};
  200. auto ReturnsRValue() -> S&&;
  201. ''';
  202. fn F() {
  203. //@dump-sem-ir-begin
  204. // CHECK:STDERR: fail_todo_call_return_rvalue_ref.carbon:[[@LINE+4]]:18: error: semantics TODO: `Unsupported: return type: S &&` [SemanticsTodo]
  205. // CHECK:STDERR: var s: Cpp.S = Cpp.ReturnsRValue();
  206. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  207. // CHECK:STDERR:
  208. var s: Cpp.S = Cpp.ReturnsRValue();
  209. //@dump-sem-ir-end
  210. }
  211. // ============================================================================
  212. // Const reference as return type
  213. // ============================================================================
  214. // --- fail_todo_call_return_const_lvalue_ref.carbon
  215. library "[[@TEST_NAME]]";
  216. import Cpp inline '''
  217. struct S {};
  218. auto ReturnConstLValue() -> const S&;
  219. ''';
  220. fn F() {
  221. //@dump-sem-ir-begin
  222. // CHECK:STDERR: fail_todo_call_return_const_lvalue_ref.carbon:[[@LINE+4]]:24: error: semantics TODO: `Unsupported: return type: const S &` [SemanticsTodo]
  223. // CHECK:STDERR: var s: const Cpp.S = Cpp.ReturnConstLValue();
  224. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  225. // CHECK:STDERR:
  226. var s: const Cpp.S = Cpp.ReturnConstLValue();
  227. //@dump-sem-ir-end
  228. }
  229. // CHECK:STDOUT: --- call_param_lvalue_ref.carbon
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: constants {
  232. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  233. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  234. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  235. // CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
  236. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  237. // CHECK:STDOUT: %.547: type = cpp_overload_set_type @<null name> [concrete]
  238. // CHECK:STDOUT: %.a7f: %.547 = cpp_overload_set_value @<null name> [concrete]
  239. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  240. // CHECK:STDOUT: %TakesLValue__carbon_thunk.type: type = fn_type @TakesLValue__carbon_thunk [concrete]
  241. // CHECK:STDOUT: %TakesLValue__carbon_thunk: %TakesLValue__carbon_thunk.type = struct_value () [concrete]
  242. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  243. // CHECK:STDOUT: %facet_value: %type_where = facet_value %S, () [concrete]
  244. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
  245. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: imports {
  249. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  250. // CHECK:STDOUT: .S = %S.decl
  251. // CHECK:STDOUT: .TakesLValue = %.a7f
  252. // CHECK:STDOUT: import Cpp//...
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  255. // CHECK:STDOUT: %.a7f: %.547 = cpp_overload_set_value @<null name> [concrete = constants.%.a7f]
  256. // CHECK:STDOUT: %TakesLValue__carbon_thunk.decl: %TakesLValue__carbon_thunk.type = fn_decl @TakesLValue__carbon_thunk [concrete = constants.%TakesLValue__carbon_thunk] {
  257. // CHECK:STDOUT: <elided>
  258. // CHECK:STDOUT: } {
  259. // CHECK:STDOUT: <elided>
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: fn @F() {
  264. // CHECK:STDOUT: !entry:
  265. // CHECK:STDOUT: name_binding_decl {
  266. // CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete]
  267. // CHECK:STDOUT: %s.var_patt: %pattern_type.7da = var_pattern %s.patt [concrete]
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT: %s.var: ref %S = var %s.var_patt
  270. // CHECK:STDOUT: %.loc8_19.1: %empty_struct_type = struct_literal ()
  271. // CHECK:STDOUT: %.loc8_19.2: init %S = class_init (), %s.var [concrete = constants.%S.val]
  272. // CHECK:STDOUT: %.loc8_3.1: init %S = converted %.loc8_19.1, %.loc8_19.2 [concrete = constants.%S.val]
  273. // CHECK:STDOUT: assign %s.var, %.loc8_3.1
  274. // CHECK:STDOUT: %.loc8_13: type = splice_block %S.ref [concrete = constants.%S] {
  275. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  276. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT: %s: ref %S = bind_name s, %s.var
  279. // CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  280. // CHECK:STDOUT: %TakesLValue.ref: %.547 = name_ref TakesLValue, imports.%.a7f [concrete = constants.%.a7f]
  281. // CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s
  282. // CHECK:STDOUT: %addr.loc9: %ptr.5c7 = addr_of %s.ref
  283. // CHECK:STDOUT: %TakesLValue__carbon_thunk.call: init %empty_tuple.type = call imports.%TakesLValue__carbon_thunk.decl(%addr.loc9)
  284. // CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value]
  285. // CHECK:STDOUT: %.loc8_3.2: %type_where = converted constants.%S, %facet_value [concrete = constants.%facet_value]
  286. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %s.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  287. // CHECK:STDOUT: <elided>
  288. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %s.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn
  289. // CHECK:STDOUT: %addr.loc8: %ptr.5c7 = addr_of %s.var
  290. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc8)
  291. // CHECK:STDOUT: <elided>
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: --- fail_param_lvalue_ref.carbon
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: constants {
  297. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  298. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  299. // CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
  300. // CHECK:STDOUT: %.547: type = cpp_overload_set_type @<null name> [concrete]
  301. // CHECK:STDOUT: %.a7f: %.547 = cpp_overload_set_value @<null name> [concrete]
  302. // CHECK:STDOUT: %T: type = class_type @T [concrete]
  303. // CHECK:STDOUT: %pattern_type.e6b: type = pattern_type %T [concrete]
  304. // CHECK:STDOUT: %const: type = const_type %S [concrete]
  305. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  306. // CHECK:STDOUT: %facet_value.7bd: %type_where = facet_value %S, () [concrete]
  307. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.7bd) [concrete]
  308. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  309. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  310. // CHECK:STDOUT: %facet_value.19d: %type_where = facet_value %T, () [concrete]
  311. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.896: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.19d) [concrete]
  312. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.8c8: %DestroyT.as_type.as.Destroy.impl.Op.type.896 = struct_value () [concrete]
  313. // CHECK:STDOUT: %ptr.b04: type = ptr_type %T [concrete]
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: imports {
  317. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  318. // CHECK:STDOUT: .S = %S.decl
  319. // CHECK:STDOUT: .TakesLValue = %.a7f
  320. // CHECK:STDOUT: .T = %T.decl
  321. // CHECK:STDOUT: import Cpp//...
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  324. // CHECK:STDOUT: %.a7f: %.547 = cpp_overload_set_value @<null name> [concrete = constants.%.a7f]
  325. // CHECK:STDOUT: %T.decl: type = class_decl @T [concrete = constants.%T] {} {}
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: fn @F() {
  329. // CHECK:STDOUT: !entry:
  330. // CHECK:STDOUT: name_binding_decl {
  331. // CHECK:STDOUT: %v.patt: %pattern_type.7da = binding_pattern v [concrete]
  332. // CHECK:STDOUT: %v.var_patt: %pattern_type.7da = var_pattern %v.patt [concrete]
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT: %v.var: ref %S = var %v.var_patt
  335. // CHECK:STDOUT: %.loc8_13: type = splice_block %S.ref.loc8 [concrete = constants.%S] {
  336. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  337. // CHECK:STDOUT: %S.ref.loc8: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT: %v: ref %S = bind_name v, %v.var
  340. // CHECK:STDOUT: name_binding_decl {
  341. // CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete]
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT: %v.ref: ref %S = name_ref v, %v
  344. // CHECK:STDOUT: %.loc9_13: type = splice_block %S.ref.loc9 [concrete = constants.%S] {
  345. // CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  346. // CHECK:STDOUT: %S.ref.loc9: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT: %.loc9_18: %S = bind_value %v.ref
  349. // CHECK:STDOUT: %s: %S = bind_name s, %.loc9_18
  350. // CHECK:STDOUT: %Cpp.ref.loc18: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  351. // CHECK:STDOUT: %TakesLValue.ref.loc18: %.547 = name_ref TakesLValue, imports.%.a7f [concrete = constants.%.a7f]
  352. // CHECK:STDOUT: %s.ref: %S = name_ref s, %s
  353. // CHECK:STDOUT: name_binding_decl {
  354. // CHECK:STDOUT: %t.patt: %pattern_type.e6b = binding_pattern t [concrete]
  355. // CHECK:STDOUT: %t.var_patt: %pattern_type.e6b = var_pattern %t.patt [concrete]
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT: %t.var: ref %T = var %t.var_patt
  358. // CHECK:STDOUT: %.loc20_13: type = splice_block %T.ref [concrete = constants.%T] {
  359. // CHECK:STDOUT: %Cpp.ref.loc20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  360. // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%T.decl [concrete = constants.%T]
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT: %t: ref %T = bind_name t, %t.var
  363. // CHECK:STDOUT: %Cpp.ref.loc29: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  364. // CHECK:STDOUT: %TakesLValue.ref.loc29: %.547 = name_ref TakesLValue, imports.%.a7f [concrete = constants.%.a7f]
  365. // CHECK:STDOUT: %t.ref: ref %T = name_ref t, %t
  366. // CHECK:STDOUT: name_binding_decl {
  367. // CHECK:STDOUT: %u.patt: %pattern_type.7da = binding_pattern u [concrete]
  368. // CHECK:STDOUT: %u.var_patt: %pattern_type.7da = var_pattern %u.patt [concrete]
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT: %u.var: ref %S = var %u.var_patt
  371. // CHECK:STDOUT: %.loc31_13: type = splice_block %S.ref.loc31 [concrete = constants.%S] {
  372. // CHECK:STDOUT: %Cpp.ref.loc31: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  373. // CHECK:STDOUT: %S.ref.loc31: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT: %u: ref %S = bind_name u, %u.var
  376. // CHECK:STDOUT: %Cpp.ref.loc40_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  377. // CHECK:STDOUT: %TakesLValue.ref.loc40: %.547 = name_ref TakesLValue, imports.%.a7f [concrete = constants.%.a7f]
  378. // CHECK:STDOUT: %u.ref: ref %S = name_ref u, %u
  379. // CHECK:STDOUT: %Cpp.ref.loc40_30: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  380. // CHECK:STDOUT: %S.ref.loc40: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  381. // CHECK:STDOUT: %const: type = const_type %S.ref.loc40 [concrete = constants.%const]
  382. // CHECK:STDOUT: %.loc40_21.1: ref %const = as_compatible %u.ref
  383. // CHECK:STDOUT: %.loc40_21.2: ref %const = converted %u.ref, %.loc40_21.1
  384. // CHECK:STDOUT: %facet_value.loc31: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value.7bd]
  385. // CHECK:STDOUT: %.loc31_3: %type_where = converted constants.%S, %facet_value.loc31 [concrete = constants.%facet_value.7bd]
  386. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc31: <bound method> = bound_method %u.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  387. // CHECK:STDOUT: <elided>
  388. // CHECK:STDOUT: %bound_method.loc31: <bound method> = bound_method %u.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1
  389. // CHECK:STDOUT: %addr.loc31: %ptr.5c7 = addr_of %u.var
  390. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc31: init %empty_tuple.type = call %bound_method.loc31(%addr.loc31)
  391. // CHECK:STDOUT: %facet_value.loc20: %type_where = facet_value constants.%T, () [concrete = constants.%facet_value.19d]
  392. // CHECK:STDOUT: %.loc20_3: %type_where = converted constants.%T, %facet_value.loc20 [concrete = constants.%facet_value.19d]
  393. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc20: <bound method> = bound_method %t.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.8c8
  394. // CHECK:STDOUT: <elided>
  395. // CHECK:STDOUT: %bound_method.loc20: <bound method> = bound_method %t.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2
  396. // CHECK:STDOUT: %addr.loc20: %ptr.b04 = addr_of %t.var
  397. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc20: init %empty_tuple.type = call %bound_method.loc20(%addr.loc20)
  398. // CHECK:STDOUT: %facet_value.loc8: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value.7bd]
  399. // CHECK:STDOUT: %.loc8_3: %type_where = converted constants.%S, %facet_value.loc8 [concrete = constants.%facet_value.7bd]
  400. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc8: <bound method> = bound_method %v.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  401. // CHECK:STDOUT: <elided>
  402. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %v.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.3
  403. // CHECK:STDOUT: %addr.loc8: %ptr.5c7 = addr_of %v.var
  404. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc8: init %empty_tuple.type = call %bound_method.loc8(%addr.loc8)
  405. // CHECK:STDOUT: <elided>
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: --- call_param_rvalue_ref.carbon
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: constants {
  411. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  412. // CHECK:STDOUT: %.1b9: type = cpp_overload_set_type @<null name> [concrete]
  413. // CHECK:STDOUT: %.1f6: %.1b9 = cpp_overload_set_value @<null name> [concrete]
  414. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  415. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  416. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  417. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  418. // CHECK:STDOUT: %TakesRValue__carbon_thunk.type: type = fn_type @TakesRValue__carbon_thunk [concrete]
  419. // CHECK:STDOUT: %TakesRValue__carbon_thunk: %TakesRValue__carbon_thunk.type = struct_value () [concrete]
  420. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  421. // CHECK:STDOUT: %facet_value: %type_where = facet_value %S, () [concrete]
  422. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
  423. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: imports {
  427. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  428. // CHECK:STDOUT: .TakesRValue = %.1f6
  429. // CHECK:STDOUT: .S = %S.decl
  430. // CHECK:STDOUT: import Cpp//...
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT: %.1f6: %.1b9 = cpp_overload_set_value @<null name> [concrete = constants.%.1f6]
  433. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  434. // CHECK:STDOUT: %TakesRValue__carbon_thunk.decl: %TakesRValue__carbon_thunk.type = fn_decl @TakesRValue__carbon_thunk [concrete = constants.%TakesRValue__carbon_thunk] {
  435. // CHECK:STDOUT: <elided>
  436. // CHECK:STDOUT: } {
  437. // CHECK:STDOUT: <elided>
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: fn @F() {
  442. // CHECK:STDOUT: !entry:
  443. // CHECK:STDOUT: %Cpp.ref.loc8_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  444. // CHECK:STDOUT: %TakesRValue.ref: %.1b9 = name_ref TakesRValue, imports.%.1f6 [concrete = constants.%.1f6]
  445. // CHECK:STDOUT: %.loc8_20.1: %empty_struct_type = struct_literal ()
  446. // CHECK:STDOUT: %Cpp.ref.loc8_25: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  447. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  448. // CHECK:STDOUT: %.loc8_20.2: ref %S = temporary_storage
  449. // CHECK:STDOUT: %.loc8_20.3: init %S = class_init (), %.loc8_20.2 [concrete = constants.%S.val]
  450. // CHECK:STDOUT: %.loc8_20.4: ref %S = temporary %.loc8_20.2, %.loc8_20.3
  451. // CHECK:STDOUT: %.loc8_22.1: ref %S = converted %.loc8_20.1, %.loc8_20.4
  452. // CHECK:STDOUT: %.loc8_22.2: %S = bind_value %.loc8_22.1
  453. // CHECK:STDOUT: %.loc8_22.3: ref %S = value_as_ref %.loc8_22.2
  454. // CHECK:STDOUT: %addr.loc8_30: %ptr.5c7 = addr_of %.loc8_22.3
  455. // CHECK:STDOUT: %TakesRValue__carbon_thunk.call: init %empty_tuple.type = call imports.%TakesRValue__carbon_thunk.decl(%addr.loc8_30)
  456. // CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value]
  457. // CHECK:STDOUT: %.loc8_20.5: %type_where = converted constants.%S, %facet_value [concrete = constants.%facet_value]
  458. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc8_20.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  459. // CHECK:STDOUT: <elided>
  460. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc8_20.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn
  461. // CHECK:STDOUT: %addr.loc8_20: %ptr.5c7 = addr_of %.loc8_20.4
  462. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc8_20)
  463. // CHECK:STDOUT: <elided>
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: --- todo_fail_param_value_arg_for_rvalue_ref.carbon
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: constants {
  469. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  470. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  471. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  472. // CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
  473. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  474. // CHECK:STDOUT: %.1b9: type = cpp_overload_set_type @<null name> [concrete]
  475. // CHECK:STDOUT: %.1f6: %.1b9 = cpp_overload_set_value @<null name> [concrete]
  476. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  477. // CHECK:STDOUT: %TakesRValue__carbon_thunk.type: type = fn_type @TakesRValue__carbon_thunk [concrete]
  478. // CHECK:STDOUT: %TakesRValue__carbon_thunk: %TakesRValue__carbon_thunk.type = struct_value () [concrete]
  479. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  480. // CHECK:STDOUT: %facet_value: %type_where = facet_value %S, () [concrete]
  481. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
  482. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  483. // CHECK:STDOUT: }
  484. // CHECK:STDOUT:
  485. // CHECK:STDOUT: imports {
  486. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  487. // CHECK:STDOUT: .S = %S.decl
  488. // CHECK:STDOUT: .TakesRValue = %.1f6
  489. // CHECK:STDOUT: import Cpp//...
  490. // CHECK:STDOUT: }
  491. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  492. // CHECK:STDOUT: %.1f6: %.1b9 = cpp_overload_set_value @<null name> [concrete = constants.%.1f6]
  493. // CHECK:STDOUT: %TakesRValue__carbon_thunk.decl: %TakesRValue__carbon_thunk.type = fn_decl @TakesRValue__carbon_thunk [concrete = constants.%TakesRValue__carbon_thunk] {
  494. // CHECK:STDOUT: <elided>
  495. // CHECK:STDOUT: } {
  496. // CHECK:STDOUT: <elided>
  497. // CHECK:STDOUT: }
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: fn @F() {
  501. // CHECK:STDOUT: !entry:
  502. // CHECK:STDOUT: name_binding_decl {
  503. // CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete]
  504. // CHECK:STDOUT: }
  505. // CHECK:STDOUT: %.loc12_19.1: %empty_struct_type = struct_literal ()
  506. // CHECK:STDOUT: %.loc12_13: type = splice_block %S.ref [concrete = constants.%S] {
  507. // CHECK:STDOUT: %Cpp.ref.loc12: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  508. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  509. // CHECK:STDOUT: }
  510. // CHECK:STDOUT: %.loc12_19.2: ref %S = temporary_storage
  511. // CHECK:STDOUT: %.loc12_19.3: init %S = class_init (), %.loc12_19.2 [concrete = constants.%S.val]
  512. // CHECK:STDOUT: %.loc12_19.4: ref %S = temporary %.loc12_19.2, %.loc12_19.3
  513. // CHECK:STDOUT: %.loc12_19.5: ref %S = converted %.loc12_19.1, %.loc12_19.4
  514. // CHECK:STDOUT: %.loc12_19.6: %S = bind_value %.loc12_19.5
  515. // CHECK:STDOUT: %s: %S = bind_name s, %.loc12_19.6
  516. // CHECK:STDOUT: %Cpp.ref.loc13: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  517. // CHECK:STDOUT: %TakesRValue.ref: %.1b9 = name_ref TakesRValue, imports.%.1f6 [concrete = constants.%.1f6]
  518. // CHECK:STDOUT: %s.ref: %S = name_ref s, %s
  519. // CHECK:STDOUT: %.loc13: ref %S = value_as_ref %s.ref
  520. // CHECK:STDOUT: %addr.loc13: %ptr.5c7 = addr_of %.loc13
  521. // CHECK:STDOUT: %TakesRValue__carbon_thunk.call: init %empty_tuple.type = call imports.%TakesRValue__carbon_thunk.decl(%addr.loc13)
  522. // CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value]
  523. // CHECK:STDOUT: %.loc12_19.7: %type_where = converted constants.%S, %facet_value [concrete = constants.%facet_value]
  524. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %.loc12_19.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  525. // CHECK:STDOUT: <elided>
  526. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc12_19.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn
  527. // CHECK:STDOUT: %addr.loc12: %ptr.5c7 = addr_of %.loc12_19.4
  528. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc12)
  529. // CHECK:STDOUT: <elided>
  530. // CHECK:STDOUT: }
  531. // CHECK:STDOUT:
  532. // CHECK:STDOUT: --- fail_param_rvalue_ref.carbon
  533. // CHECK:STDOUT:
  534. // CHECK:STDOUT: constants {
  535. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  536. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  537. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  538. // CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
  539. // CHECK:STDOUT: %.1b9: type = cpp_overload_set_type @<null name> [concrete]
  540. // CHECK:STDOUT: %.1f6: %.1b9 = cpp_overload_set_value @<null name> [concrete]
  541. // CHECK:STDOUT: %T: type = class_type @T [concrete]
  542. // CHECK:STDOUT: %pattern_type.e6b: type = pattern_type %T [concrete]
  543. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  544. // CHECK:STDOUT: %const: type = const_type %S [concrete]
  545. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  546. // CHECK:STDOUT: %facet_value.7bd: %type_where = facet_value %S, () [concrete]
  547. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.7bd) [concrete]
  548. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  549. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  550. // CHECK:STDOUT: %facet_value.19d: %type_where = facet_value %T, () [concrete]
  551. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.896: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.19d) [concrete]
  552. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.8c8: %DestroyT.as_type.as.Destroy.impl.Op.type.896 = struct_value () [concrete]
  553. // CHECK:STDOUT: %ptr.b04: type = ptr_type %T [concrete]
  554. // CHECK:STDOUT: }
  555. // CHECK:STDOUT:
  556. // CHECK:STDOUT: imports {
  557. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  558. // CHECK:STDOUT: .S = %S.decl
  559. // CHECK:STDOUT: .TakesRValue = %.1f6
  560. // CHECK:STDOUT: .T = %T.decl
  561. // CHECK:STDOUT: import Cpp//...
  562. // CHECK:STDOUT: }
  563. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  564. // CHECK:STDOUT: %.1f6: %.1b9 = cpp_overload_set_value @<null name> [concrete = constants.%.1f6]
  565. // CHECK:STDOUT: %T.decl: type = class_decl @T [concrete = constants.%T] {} {}
  566. // CHECK:STDOUT: }
  567. // CHECK:STDOUT:
  568. // CHECK:STDOUT: fn @F() {
  569. // CHECK:STDOUT: !entry:
  570. // CHECK:STDOUT: name_binding_decl {
  571. // CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete]
  572. // CHECK:STDOUT: %s.var_patt: %pattern_type.7da = var_pattern %s.patt [concrete]
  573. // CHECK:STDOUT: }
  574. // CHECK:STDOUT: %s.var: ref %S = var %s.var_patt
  575. // CHECK:STDOUT: %.loc8_13: type = splice_block %S.ref.loc8 [concrete = constants.%S] {
  576. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  577. // CHECK:STDOUT: %S.ref.loc8: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  578. // CHECK:STDOUT: }
  579. // CHECK:STDOUT: %s: ref %S = bind_name s, %s.var
  580. // CHECK:STDOUT: %Cpp.ref.loc17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  581. // CHECK:STDOUT: %TakesRValue.ref.loc17: %.1b9 = name_ref TakesRValue, imports.%.1f6 [concrete = constants.%.1f6]
  582. // CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s
  583. // CHECK:STDOUT: name_binding_decl {
  584. // CHECK:STDOUT: %t.patt: %pattern_type.e6b = binding_pattern t [concrete]
  585. // CHECK:STDOUT: %t.var_patt: %pattern_type.e6b = var_pattern %t.patt [concrete]
  586. // CHECK:STDOUT: }
  587. // CHECK:STDOUT: %t.var: ref %T = var %t.var_patt
  588. // CHECK:STDOUT: %.loc19_13: type = splice_block %T.ref [concrete = constants.%T] {
  589. // CHECK:STDOUT: %Cpp.ref.loc19: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  590. // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%T.decl [concrete = constants.%T]
  591. // CHECK:STDOUT: }
  592. // CHECK:STDOUT: %t: ref %T = bind_name t, %t.var
  593. // CHECK:STDOUT: %Cpp.ref.loc28: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  594. // CHECK:STDOUT: %TakesRValue.ref.loc28: %.1b9 = name_ref TakesRValue, imports.%.1f6 [concrete = constants.%.1f6]
  595. // CHECK:STDOUT: %t.ref: ref %T = name_ref t, %t
  596. // CHECK:STDOUT: %Cpp.ref.loc38_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  597. // CHECK:STDOUT: %TakesRValue.ref.loc38: %.1b9 = name_ref TakesRValue, imports.%.1f6 [concrete = constants.%.1f6]
  598. // CHECK:STDOUT: %.loc38_21.1: %empty_struct_type = struct_literal ()
  599. // CHECK:STDOUT: %Cpp.ref.loc38_26: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  600. // CHECK:STDOUT: %S.ref.loc38_29: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  601. // CHECK:STDOUT: %.loc38_21.2: ref %S = temporary_storage
  602. // CHECK:STDOUT: %.loc38_21.3: init %S = class_init (), %.loc38_21.2 [concrete = constants.%S.val]
  603. // CHECK:STDOUT: %.loc38_21.4: ref %S = temporary %.loc38_21.2, %.loc38_21.3
  604. // CHECK:STDOUT: %.loc38_23: ref %S = converted %.loc38_21.1, %.loc38_21.4
  605. // CHECK:STDOUT: %Cpp.ref.loc38_42: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  606. // CHECK:STDOUT: %S.ref.loc38_45: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  607. // CHECK:STDOUT: %const: type = const_type %S.ref.loc38_45 [concrete = constants.%const]
  608. // CHECK:STDOUT: %.loc38_33.1: ref %const = as_compatible %.loc38_23
  609. // CHECK:STDOUT: %.loc38_33.2: ref %const = converted %.loc38_23, %.loc38_33.1
  610. // CHECK:STDOUT: %facet_value.loc38: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value.7bd]
  611. // CHECK:STDOUT: %.loc38_21.5: %type_where = converted constants.%S, %facet_value.loc38 [concrete = constants.%facet_value.7bd]
  612. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc38: <bound method> = bound_method %.loc38_21.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  613. // CHECK:STDOUT: <elided>
  614. // CHECK:STDOUT: %bound_method.loc38: <bound method> = bound_method %.loc38_21.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1
  615. // CHECK:STDOUT: %addr.loc38: %ptr.5c7 = addr_of %.loc38_21.4
  616. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc38: init %empty_tuple.type = call %bound_method.loc38(%addr.loc38)
  617. // CHECK:STDOUT: %facet_value.loc19: %type_where = facet_value constants.%T, () [concrete = constants.%facet_value.19d]
  618. // CHECK:STDOUT: %.loc19_3: %type_where = converted constants.%T, %facet_value.loc19 [concrete = constants.%facet_value.19d]
  619. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc19: <bound method> = bound_method %t.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.8c8
  620. // CHECK:STDOUT: <elided>
  621. // CHECK:STDOUT: %bound_method.loc19: <bound method> = bound_method %t.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2
  622. // CHECK:STDOUT: %addr.loc19: %ptr.b04 = addr_of %t.var
  623. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc19: init %empty_tuple.type = call %bound_method.loc19(%addr.loc19)
  624. // CHECK:STDOUT: %facet_value.loc8: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value.7bd]
  625. // CHECK:STDOUT: %.loc8_3: %type_where = converted constants.%S, %facet_value.loc8 [concrete = constants.%facet_value.7bd]
  626. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc8: <bound method> = bound_method %s.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  627. // CHECK:STDOUT: <elided>
  628. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %s.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.3
  629. // CHECK:STDOUT: %addr.loc8: %ptr.5c7 = addr_of %s.var
  630. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc8: init %empty_tuple.type = call %bound_method.loc8(%addr.loc8)
  631. // CHECK:STDOUT: <elided>
  632. // CHECK:STDOUT: }
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: --- call_param_const_lvalue_ref.carbon
  635. // CHECK:STDOUT:
  636. // CHECK:STDOUT: constants {
  637. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  638. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  639. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  640. // CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
  641. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  642. // CHECK:STDOUT: %.4e1: type = cpp_overload_set_type @<null name> [concrete]
  643. // CHECK:STDOUT: %.9bc: %.4e1 = cpp_overload_set_value @<null name> [concrete]
  644. // CHECK:STDOUT: %const: type = const_type %S [concrete]
  645. // CHECK:STDOUT: %ptr.ff5: type = ptr_type %const [concrete]
  646. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk.type: type = fn_type @TakesConstLValue__carbon_thunk [concrete]
  647. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk: %TakesConstLValue__carbon_thunk.type = struct_value () [concrete]
  648. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  649. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  650. // CHECK:STDOUT: %facet_value: %type_where = facet_value %S, () [concrete]
  651. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
  652. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  653. // CHECK:STDOUT: }
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: imports {
  656. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  657. // CHECK:STDOUT: .S = %S.decl
  658. // CHECK:STDOUT: .TakesConstLValue = %.9bc
  659. // CHECK:STDOUT: import Cpp//...
  660. // CHECK:STDOUT: }
  661. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  662. // CHECK:STDOUT: %.9bc: %.4e1 = cpp_overload_set_value @<null name> [concrete = constants.%.9bc]
  663. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk.decl: %TakesConstLValue__carbon_thunk.type = fn_decl @TakesConstLValue__carbon_thunk [concrete = constants.%TakesConstLValue__carbon_thunk] {
  664. // CHECK:STDOUT: <elided>
  665. // CHECK:STDOUT: } {
  666. // CHECK:STDOUT: <elided>
  667. // CHECK:STDOUT: }
  668. // CHECK:STDOUT: }
  669. // CHECK:STDOUT:
  670. // CHECK:STDOUT: fn @F() {
  671. // CHECK:STDOUT: !entry:
  672. // CHECK:STDOUT: name_binding_decl {
  673. // CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete]
  674. // CHECK:STDOUT: %s.var_patt: %pattern_type.7da = var_pattern %s.patt [concrete]
  675. // CHECK:STDOUT: }
  676. // CHECK:STDOUT: %s.var: ref %S = var %s.var_patt
  677. // CHECK:STDOUT: %.loc8_19.1: %empty_struct_type = struct_literal ()
  678. // CHECK:STDOUT: %.loc8_19.2: init %S = class_init (), %s.var [concrete = constants.%S.val]
  679. // CHECK:STDOUT: %.loc8_3.1: init %S = converted %.loc8_19.1, %.loc8_19.2 [concrete = constants.%S.val]
  680. // CHECK:STDOUT: assign %s.var, %.loc8_3.1
  681. // CHECK:STDOUT: %.loc8_13: type = splice_block %S.ref.loc8 [concrete = constants.%S] {
  682. // CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  683. // CHECK:STDOUT: %S.ref.loc8: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT: %s: ref %S = bind_name s, %s.var
  686. // CHECK:STDOUT: %Cpp.ref.loc9_3: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  687. // CHECK:STDOUT: %TakesConstLValue.ref.loc9: %.4e1 = name_ref TakesConstLValue, imports.%.9bc [concrete = constants.%.9bc]
  688. // CHECK:STDOUT: %s.ref.loc9: ref %S = name_ref s, %s
  689. // CHECK:STDOUT: %Cpp.ref.loc9_35: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  690. // CHECK:STDOUT: %S.ref.loc9: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  691. // CHECK:STDOUT: %const: type = const_type %S.ref.loc9 [concrete = constants.%const]
  692. // CHECK:STDOUT: %.loc9_26.1: ref %const = as_compatible %s.ref.loc9
  693. // CHECK:STDOUT: %.loc9_26.2: ref %const = converted %s.ref.loc9, %.loc9_26.1
  694. // CHECK:STDOUT: %addr.loc9: %ptr.ff5 = addr_of %.loc9_26.2
  695. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk.call.loc9: init %empty_tuple.type = call imports.%TakesConstLValue__carbon_thunk.decl(%addr.loc9)
  696. // CHECK:STDOUT: %Cpp.ref.loc11: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  697. // CHECK:STDOUT: %TakesConstLValue.ref.loc11: %.4e1 = name_ref TakesConstLValue, imports.%.9bc [concrete = constants.%.9bc]
  698. // CHECK:STDOUT: %s.ref.loc11: ref %S = name_ref s, %s
  699. // CHECK:STDOUT: %addr.loc11: %ptr.5c7 = addr_of %s.ref.loc11
  700. // CHECK:STDOUT: %.loc11_24.1: %ptr.ff5 = as_compatible %addr.loc11
  701. // CHECK:STDOUT: %.loc11_24.2: %ptr.ff5 = converted %addr.loc11, %.loc11_24.1
  702. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk.call.loc11: init %empty_tuple.type = call imports.%TakesConstLValue__carbon_thunk.decl(%.loc11_24.2)
  703. // CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value]
  704. // CHECK:STDOUT: %.loc8_3.2: %type_where = converted constants.%S, %facet_value [concrete = constants.%facet_value]
  705. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %s.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  706. // CHECK:STDOUT: <elided>
  707. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %s.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn
  708. // CHECK:STDOUT: %addr.loc8: %ptr.5c7 = addr_of %s.var
  709. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr.loc8)
  710. // CHECK:STDOUT: <elided>
  711. // CHECK:STDOUT: }
  712. // CHECK:STDOUT:
  713. // CHECK:STDOUT: --- fail_param_const_lvalue_ref.carbon
  714. // CHECK:STDOUT:
  715. // CHECK:STDOUT: constants {
  716. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  717. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  718. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  719. // CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
  720. // CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
  721. // CHECK:STDOUT: %.4e1: type = cpp_overload_set_type @<null name> [concrete]
  722. // CHECK:STDOUT: %.9bc: %.4e1 = cpp_overload_set_value @<null name> [concrete]
  723. // CHECK:STDOUT: %const: type = const_type %S [concrete]
  724. // CHECK:STDOUT: %ptr.ff5: type = ptr_type %const [concrete]
  725. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk.type: type = fn_type @TakesConstLValue__carbon_thunk [concrete]
  726. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk: %TakesConstLValue__carbon_thunk.type = struct_value () [concrete]
  727. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  728. // CHECK:STDOUT: %T: type = class_type @T [concrete]
  729. // CHECK:STDOUT: %pattern_type.e6b: type = pattern_type %T [concrete]
  730. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  731. // CHECK:STDOUT: %facet_value.19d: %type_where = facet_value %T, () [concrete]
  732. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.896: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.19d) [concrete]
  733. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.8c8: %DestroyT.as_type.as.Destroy.impl.Op.type.896 = struct_value () [concrete]
  734. // CHECK:STDOUT: %ptr.b04: type = ptr_type %T [concrete]
  735. // CHECK:STDOUT: %facet_value.7bd: %type_where = facet_value %S, () [concrete]
  736. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.7bd) [concrete]
  737. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  738. // CHECK:STDOUT: }
  739. // CHECK:STDOUT:
  740. // CHECK:STDOUT: imports {
  741. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  742. // CHECK:STDOUT: .S = %S.decl
  743. // CHECK:STDOUT: .TakesConstLValue = %.9bc
  744. // CHECK:STDOUT: .T = %T.decl
  745. // CHECK:STDOUT: import Cpp//...
  746. // CHECK:STDOUT: }
  747. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  748. // CHECK:STDOUT: %.9bc: %.4e1 = cpp_overload_set_value @<null name> [concrete = constants.%.9bc]
  749. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk.decl: %TakesConstLValue__carbon_thunk.type = fn_decl @TakesConstLValue__carbon_thunk [concrete = constants.%TakesConstLValue__carbon_thunk] {
  750. // CHECK:STDOUT: <elided>
  751. // CHECK:STDOUT: } {
  752. // CHECK:STDOUT: <elided>
  753. // CHECK:STDOUT: }
  754. // CHECK:STDOUT: %T.decl: type = class_decl @T [concrete = constants.%T] {} {}
  755. // CHECK:STDOUT: }
  756. // CHECK:STDOUT:
  757. // CHECK:STDOUT: fn @F() {
  758. // CHECK:STDOUT: !entry:
  759. // CHECK:STDOUT: name_binding_decl {
  760. // CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete]
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT: %.loc12_19.1: %empty_struct_type = struct_literal ()
  763. // CHECK:STDOUT: %.loc12_13: type = splice_block %S.ref [concrete = constants.%S] {
  764. // CHECK:STDOUT: %Cpp.ref.loc12: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  765. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT: %.loc12_19.2: ref %S = temporary_storage
  768. // CHECK:STDOUT: %.loc12_19.3: init %S = class_init (), %.loc12_19.2 [concrete = constants.%S.val]
  769. // CHECK:STDOUT: %.loc12_19.4: ref %S = temporary %.loc12_19.2, %.loc12_19.3
  770. // CHECK:STDOUT: %.loc12_19.5: ref %S = converted %.loc12_19.1, %.loc12_19.4
  771. // CHECK:STDOUT: %.loc12_19.6: %S = bind_value %.loc12_19.5
  772. // CHECK:STDOUT: %s: %S = bind_name s, %.loc12_19.6
  773. // CHECK:STDOUT: %Cpp.ref.loc18: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  774. // CHECK:STDOUT: %TakesConstLValue.ref.loc18: %.4e1 = name_ref TakesConstLValue, imports.%.9bc [concrete = constants.%.9bc]
  775. // CHECK:STDOUT: %s.ref: %S = name_ref s, %s
  776. // CHECK:STDOUT: %.loc18_24.1: ref %S = temporary_storage
  777. // CHECK:STDOUT: %addr.loc18: %ptr.5c7 = addr_of %.loc18_24.1
  778. // CHECK:STDOUT: %.loc18_24.2: %ptr.ff5 = as_compatible %addr.loc18
  779. // CHECK:STDOUT: %.loc18_24.3: %ptr.ff5 = converted %addr.loc18, %.loc18_24.2
  780. // CHECK:STDOUT: %TakesConstLValue__carbon_thunk.call: init %empty_tuple.type = call imports.%TakesConstLValue__carbon_thunk.decl(%.loc18_24.3)
  781. // CHECK:STDOUT: name_binding_decl {
  782. // CHECK:STDOUT: %t.patt: %pattern_type.e6b = binding_pattern t [concrete]
  783. // CHECK:STDOUT: %t.var_patt: %pattern_type.e6b = var_pattern %t.patt [concrete]
  784. // CHECK:STDOUT: }
  785. // CHECK:STDOUT: %t.var: ref %T = var %t.var_patt
  786. // CHECK:STDOUT: %.loc20_13: type = splice_block %T.ref [concrete = constants.%T] {
  787. // CHECK:STDOUT: %Cpp.ref.loc20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  788. // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%T.decl [concrete = constants.%T]
  789. // CHECK:STDOUT: }
  790. // CHECK:STDOUT: %t: ref %T = bind_name t, %t.var
  791. // CHECK:STDOUT: %Cpp.ref.loc29: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  792. // CHECK:STDOUT: %TakesConstLValue.ref.loc29: %.4e1 = name_ref TakesConstLValue, imports.%.9bc [concrete = constants.%.9bc]
  793. // CHECK:STDOUT: %t.ref: ref %T = name_ref t, %t
  794. // CHECK:STDOUT: %facet_value.loc20: %type_where = facet_value constants.%T, () [concrete = constants.%facet_value.19d]
  795. // CHECK:STDOUT: %.loc20_3: %type_where = converted constants.%T, %facet_value.loc20 [concrete = constants.%facet_value.19d]
  796. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc20: <bound method> = bound_method %t.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.8c8
  797. // CHECK:STDOUT: <elided>
  798. // CHECK:STDOUT: %bound_method.loc20: <bound method> = bound_method %t.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1
  799. // CHECK:STDOUT: %addr.loc20: %ptr.b04 = addr_of %t.var
  800. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc20: init %empty_tuple.type = call %bound_method.loc20(%addr.loc20)
  801. // CHECK:STDOUT: %facet_value.loc12: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value.7bd]
  802. // CHECK:STDOUT: %.loc12_19.7: %type_where = converted constants.%S, %facet_value.loc12 [concrete = constants.%facet_value.7bd]
  803. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc12: <bound method> = bound_method %.loc12_19.4, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  804. // CHECK:STDOUT: <elided>
  805. // CHECK:STDOUT: %bound_method.loc12: <bound method> = bound_method %.loc12_19.4, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2
  806. // CHECK:STDOUT: %addr.loc12: %ptr.5c7 = addr_of %.loc12_19.4
  807. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc12: init %empty_tuple.type = call %bound_method.loc12(%addr.loc12)
  808. // CHECK:STDOUT: <elided>
  809. // CHECK:STDOUT: }
  810. // CHECK:STDOUT:
  811. // CHECK:STDOUT: --- fail_todo_call_return_lvalue_ref.carbon
  812. // CHECK:STDOUT:
  813. // CHECK:STDOUT: constants {
  814. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  815. // CHECK:STDOUT: %ptr: type = ptr_type %S [concrete]
  816. // CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
  817. // CHECK:STDOUT: %.041: type = cpp_overload_set_type @<null name> [concrete]
  818. // CHECK:STDOUT: %.03d: %.041 = cpp_overload_set_value @<null name> [concrete]
  819. // CHECK:STDOUT: %ReturnsLValue.type: type = fn_type @ReturnsLValue [concrete]
  820. // CHECK:STDOUT: %ReturnsLValue: %ReturnsLValue.type = struct_value () [concrete]
  821. // CHECK:STDOUT: }
  822. // CHECK:STDOUT:
  823. // CHECK:STDOUT: imports {
  824. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  825. // CHECK:STDOUT: .S = %S.decl
  826. // CHECK:STDOUT: .ReturnsLValue = %.03d
  827. // CHECK:STDOUT: import Cpp//...
  828. // CHECK:STDOUT: }
  829. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  830. // CHECK:STDOUT: %.03d: %.041 = cpp_overload_set_value @<null name> [concrete = constants.%.03d]
  831. // CHECK:STDOUT: %ReturnsLValue.decl: %ReturnsLValue.type = fn_decl @ReturnsLValue [concrete = constants.%ReturnsLValue] {
  832. // CHECK:STDOUT: <elided>
  833. // CHECK:STDOUT: } {
  834. // CHECK:STDOUT: <elided>
  835. // CHECK:STDOUT: }
  836. // CHECK:STDOUT: }
  837. // CHECK:STDOUT:
  838. // CHECK:STDOUT: fn @F() {
  839. // CHECK:STDOUT: !entry:
  840. // CHECK:STDOUT: name_binding_decl {
  841. // CHECK:STDOUT: %s.patt: %pattern_type = binding_pattern s [concrete]
  842. // CHECK:STDOUT: }
  843. // CHECK:STDOUT: %Cpp.ref.loc16_19: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  844. // CHECK:STDOUT: %ReturnsLValue.ref: %.041 = name_ref ReturnsLValue, imports.%.03d [concrete = constants.%.03d]
  845. // CHECK:STDOUT: %ReturnsLValue.call: init <error> = call imports.%ReturnsLValue.decl()
  846. // CHECK:STDOUT: %.loc16: type = splice_block %ptr [concrete = constants.%ptr] {
  847. // CHECK:STDOUT: %Cpp.ref.loc16_10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  848. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  849. // CHECK:STDOUT: %ptr: type = ptr_type %S.ref [concrete = constants.%ptr]
  850. // CHECK:STDOUT: }
  851. // CHECK:STDOUT: %s: %ptr = bind_name s, <error> [concrete = <error>]
  852. // CHECK:STDOUT: <elided>
  853. // CHECK:STDOUT: }
  854. // CHECK:STDOUT:
  855. // CHECK:STDOUT: --- fail_todo_call_return_rvalue_ref.carbon
  856. // CHECK:STDOUT:
  857. // CHECK:STDOUT: constants {
  858. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  859. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  860. // CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
  861. // CHECK:STDOUT: %.c60: type = cpp_overload_set_type @<null name> [concrete]
  862. // CHECK:STDOUT: %.99d: %.c60 = cpp_overload_set_value @<null name> [concrete]
  863. // CHECK:STDOUT: %ReturnsRValue.type: type = fn_type @ReturnsRValue [concrete]
  864. // CHECK:STDOUT: %ReturnsRValue: %ReturnsRValue.type = struct_value () [concrete]
  865. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  866. // CHECK:STDOUT: %facet_value: %type_where = facet_value %S, () [concrete]
  867. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.df1: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
  868. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cc2: %DestroyT.as_type.as.Destroy.impl.Op.type.df1 = struct_value () [concrete]
  869. // CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
  870. // CHECK:STDOUT: }
  871. // CHECK:STDOUT:
  872. // CHECK:STDOUT: imports {
  873. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  874. // CHECK:STDOUT: .S = %S.decl
  875. // CHECK:STDOUT: .ReturnsRValue = %.99d
  876. // CHECK:STDOUT: import Cpp//...
  877. // CHECK:STDOUT: }
  878. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  879. // CHECK:STDOUT: %.99d: %.c60 = cpp_overload_set_value @<null name> [concrete = constants.%.99d]
  880. // CHECK:STDOUT: %ReturnsRValue.decl: %ReturnsRValue.type = fn_decl @ReturnsRValue [concrete = constants.%ReturnsRValue] {
  881. // CHECK:STDOUT: <elided>
  882. // CHECK:STDOUT: } {
  883. // CHECK:STDOUT: <elided>
  884. // CHECK:STDOUT: }
  885. // CHECK:STDOUT: }
  886. // CHECK:STDOUT:
  887. // CHECK:STDOUT: fn @F() {
  888. // CHECK:STDOUT: !entry:
  889. // CHECK:STDOUT: name_binding_decl {
  890. // CHECK:STDOUT: %s.patt: %pattern_type.7da = binding_pattern s [concrete]
  891. // CHECK:STDOUT: %s.var_patt: %pattern_type.7da = var_pattern %s.patt [concrete]
  892. // CHECK:STDOUT: }
  893. // CHECK:STDOUT: %s.var: ref %S = var %s.var_patt
  894. // CHECK:STDOUT: %Cpp.ref.loc16_18: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  895. // CHECK:STDOUT: %ReturnsRValue.ref: %.c60 = name_ref ReturnsRValue, imports.%.99d [concrete = constants.%.99d]
  896. // CHECK:STDOUT: %ReturnsRValue.call: init <error> = call imports.%ReturnsRValue.decl()
  897. // CHECK:STDOUT: assign %s.var, <error>
  898. // CHECK:STDOUT: %.loc16_13: type = splice_block %S.ref [concrete = constants.%S] {
  899. // CHECK:STDOUT: %Cpp.ref.loc16_10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  900. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  901. // CHECK:STDOUT: }
  902. // CHECK:STDOUT: %s: ref %S = bind_name s, %s.var
  903. // CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%S, () [concrete = constants.%facet_value]
  904. // CHECK:STDOUT: %.loc16_3: %type_where = converted constants.%S, %facet_value [concrete = constants.%facet_value]
  905. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %s.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.cc2
  906. // CHECK:STDOUT: <elided>
  907. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %s.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn
  908. // CHECK:STDOUT: %addr: %ptr.5c7 = addr_of %s.var
  909. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  910. // CHECK:STDOUT: <elided>
  911. // CHECK:STDOUT: }
  912. // CHECK:STDOUT:
  913. // CHECK:STDOUT: --- fail_todo_call_return_const_lvalue_ref.carbon
  914. // CHECK:STDOUT:
  915. // CHECK:STDOUT: constants {
  916. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  917. // CHECK:STDOUT: %S: type = class_type @S [concrete]
  918. // CHECK:STDOUT: %const: type = const_type %S [concrete]
  919. // CHECK:STDOUT: %pattern_type.9be: type = pattern_type %const [concrete]
  920. // CHECK:STDOUT: %.c99: type = cpp_overload_set_type @<null name> [concrete]
  921. // CHECK:STDOUT: %.bf8: %.c99 = cpp_overload_set_value @<null name> [concrete]
  922. // CHECK:STDOUT: %ReturnConstLValue.type: type = fn_type @ReturnConstLValue [concrete]
  923. // CHECK:STDOUT: %ReturnConstLValue: %ReturnConstLValue.type = struct_value () [concrete]
  924. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  925. // CHECK:STDOUT: %facet_value: %type_where = facet_value %const, () [concrete]
  926. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.31d: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value) [concrete]
  927. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.818: %DestroyT.as_type.as.Destroy.impl.Op.type.31d = struct_value () [concrete]
  928. // CHECK:STDOUT: %ptr.ff5: type = ptr_type %const [concrete]
  929. // CHECK:STDOUT: }
  930. // CHECK:STDOUT:
  931. // CHECK:STDOUT: imports {
  932. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  933. // CHECK:STDOUT: .S = %S.decl
  934. // CHECK:STDOUT: .ReturnConstLValue = %.bf8
  935. // CHECK:STDOUT: import Cpp//...
  936. // CHECK:STDOUT: }
  937. // CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
  938. // CHECK:STDOUT: %.bf8: %.c99 = cpp_overload_set_value @<null name> [concrete = constants.%.bf8]
  939. // CHECK:STDOUT: %ReturnConstLValue.decl: %ReturnConstLValue.type = fn_decl @ReturnConstLValue [concrete = constants.%ReturnConstLValue] {
  940. // CHECK:STDOUT: <elided>
  941. // CHECK:STDOUT: } {
  942. // CHECK:STDOUT: <elided>
  943. // CHECK:STDOUT: }
  944. // CHECK:STDOUT: }
  945. // CHECK:STDOUT:
  946. // CHECK:STDOUT: fn @F() {
  947. // CHECK:STDOUT: !entry:
  948. // CHECK:STDOUT: name_binding_decl {
  949. // CHECK:STDOUT: %s.patt: %pattern_type.9be = binding_pattern s [concrete]
  950. // CHECK:STDOUT: %s.var_patt: %pattern_type.9be = var_pattern %s.patt [concrete]
  951. // CHECK:STDOUT: }
  952. // CHECK:STDOUT: %s.var: ref %const = var %s.var_patt
  953. // CHECK:STDOUT: %Cpp.ref.loc16_24: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  954. // CHECK:STDOUT: %ReturnConstLValue.ref: %.c99 = name_ref ReturnConstLValue, imports.%.bf8 [concrete = constants.%.bf8]
  955. // CHECK:STDOUT: %ReturnConstLValue.call: init <error> = call imports.%ReturnConstLValue.decl()
  956. // CHECK:STDOUT: assign %s.var, <error>
  957. // CHECK:STDOUT: %.loc16_10: type = splice_block %const [concrete = constants.%const] {
  958. // CHECK:STDOUT: %Cpp.ref.loc16_16: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  959. // CHECK:STDOUT: %S.ref: type = name_ref S, imports.%S.decl [concrete = constants.%S]
  960. // CHECK:STDOUT: %const: type = const_type %S.ref [concrete = constants.%const]
  961. // CHECK:STDOUT: }
  962. // CHECK:STDOUT: %s: ref %const = bind_name s, %s.var
  963. // CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%const, () [concrete = constants.%facet_value]
  964. // CHECK:STDOUT: %.loc16_3: %type_where = converted constants.%const, %facet_value [concrete = constants.%facet_value]
  965. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %s.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.818
  966. // CHECK:STDOUT: <elided>
  967. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %s.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn
  968. // CHECK:STDOUT: %addr: %ptr.ff5 = addr_of %s.var
  969. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  970. // CHECK:STDOUT: <elided>
  971. // CHECK:STDOUT: }
  972. // CHECK:STDOUT: