method.carbon 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. // EXTRA-ARGS: --clang-arg=-std=c++23
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/class/method.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/class/method.carbon
  13. // --- object_param_qualifiers.h
  14. struct HasQualifiers {
  15. void plain();
  16. void const_this() const;
  17. void volatile_this() volatile;
  18. void ref_this() &;
  19. void const_ref_this() const&;
  20. void ref_ref_this() &&;
  21. void const_ref_ref_this() const&&;
  22. };
  23. // --- use_object_param_qualifiers.carbon
  24. library "[[@TEST_NAME]]";
  25. import Cpp library "object_param_qualifiers.h";
  26. fn F(v: Cpp.HasQualifiers, p: Cpp.HasQualifiers*) {
  27. //@dump-sem-ir-begin
  28. v.const_this();
  29. v.const_ref_this();
  30. p->plain();
  31. p->ref_this();
  32. p->const_this();
  33. p->const_ref_this();
  34. //@dump-sem-ir-end
  35. }
  36. // --- fail_bad_object_param_qualifiers_by_value.carbon
  37. library "[[@TEST_NAME]]";
  38. import Cpp library "object_param_qualifiers.h";
  39. fn Value(v: Cpp.HasQualifiers) {
  40. // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+5]]:3: error: `addr self` method cannot be invoked on a value [AddrSelfIsNonRef]
  41. // CHECK:STDERR: v.plain();
  42. // CHECK:STDERR: ^
  43. // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon: note: initializing function parameter [InCallToFunctionParam]
  44. // CHECK:STDERR:
  45. v.plain();
  46. // TODO: This should remain invalid once we support `volatile`.
  47. // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+4]]:3: error: semantics TODO: `Unsupported: object parameter type: volatile struct HasQualifiers` [SemanticsTodo]
  48. // CHECK:STDERR: v.volatile_this();
  49. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  50. // CHECK:STDERR:
  51. v.volatile_this();
  52. // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+8]]:14: error: no matching function for call to 'ref_this' [CppInteropParseError]
  53. // CHECK:STDERR: 29 | v.ref_this();
  54. // CHECK:STDERR: | ^
  55. // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE-20]]:10: in file included here [InCppInclude]
  56. // CHECK:STDERR: ./object_param_qualifiers.h:7:8: note: candidate function not viable: expects an lvalue for object argument [CppInteropParseNote]
  57. // CHECK:STDERR: 7 | void ref_this() &;
  58. // CHECK:STDERR: | ^
  59. // CHECK:STDERR:
  60. v.ref_this();
  61. // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+4]]:3: error: semantics TODO: `Unsupported: object parameter type: struct HasQualifiers &&` [SemanticsTodo]
  62. // CHECK:STDERR: v.ref_ref_this();
  63. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  64. // CHECK:STDERR:
  65. v.ref_ref_this();
  66. // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+4]]:3: error: semantics TODO: `Unsupported: object parameter type: const struct HasQualifiers &&` [SemanticsTodo]
  67. // CHECK:STDERR: v.const_ref_ref_this();
  68. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
  69. // CHECK:STDERR:
  70. v.const_ref_ref_this();
  71. }
  72. // --- fail_todo_bad_object_param_qualifiers_by_ref.carbon
  73. library "[[@TEST_NAME]]";
  74. import Cpp library "object_param_qualifiers.h";
  75. fn Ref(p: Cpp.HasQualifiers*) {
  76. // TODO: This should eventually be accepted if we support `volatile`.
  77. // CHECK:STDERR: fail_todo_bad_object_param_qualifiers_by_ref.carbon:[[@LINE+4]]:3: error: semantics TODO: `Unsupported: object parameter type: volatile struct HasQualifiers` [SemanticsTodo]
  78. // CHECK:STDERR: p->volatile_this();
  79. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  80. // CHECK:STDERR:
  81. p->volatile_this();
  82. }
  83. // --- fail_bad_object_param_qualifiers_ref_ref.carbon
  84. library "[[@TEST_NAME]]";
  85. import Cpp library "object_param_qualifiers.h";
  86. fn Ref(p: Cpp.HasQualifiers*) {
  87. // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE+8]]:19: error: no matching function for call to 'ref_ref_this' [CppInteropParseError]
  88. // CHECK:STDERR: 15 | p->ref_ref_this();
  89. // CHECK:STDERR: | ^
  90. // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE-6]]:10: in file included here [InCppInclude]
  91. // CHECK:STDERR: ./object_param_qualifiers.h:10:8: note: candidate function not viable: expects an rvalue for object argument [CppInteropParseNote]
  92. // CHECK:STDERR: 10 | void ref_ref_this() &&;
  93. // CHECK:STDERR: | ^
  94. // CHECK:STDERR:
  95. p->ref_ref_this();
  96. // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE+8]]:25: error: no matching function for call to 'const_ref_ref_this' [CppInteropParseError]
  97. // CHECK:STDERR: 25 | p->const_ref_ref_this();
  98. // CHECK:STDERR: | ^
  99. // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE-16]]:10: in file included here [InCppInclude]
  100. // CHECK:STDERR: ./object_param_qualifiers.h:11:8: note: candidate function not viable: expects an rvalue for object argument [CppInteropParseNote]
  101. // CHECK:STDERR: 11 | void const_ref_ref_this() const&&;
  102. // CHECK:STDERR: | ^
  103. // CHECK:STDERR:
  104. p->const_ref_ref_this();
  105. }
  106. // --- object_param_qualifiers_overloaded.h
  107. struct HasQualifiers {
  108. int* _Nonnull F() &;
  109. int F() const &;
  110. void F() volatile &;
  111. };
  112. // --- use_object_param_qualifiers_overloaded.carbon
  113. library "[[@TEST_NAME]]";
  114. import Cpp library "object_param_qualifiers_overloaded.h";
  115. fn CallF(v: Cpp.HasQualifiers, p: Cpp.HasQualifiers*) {
  116. //@dump-sem-ir-begin
  117. var a: i32 = v.F();
  118. var b: i32* = p->F();
  119. //@dump-sem-ir-end
  120. }
  121. // --- explicit_object_param.h
  122. struct Another {
  123. };
  124. struct ExplicitObjectParam {
  125. void F(this ExplicitObjectParam);
  126. void G(this int);
  127. void H(this Another);
  128. };
  129. // --- call_explicit_object_param.carbon
  130. library "[[@TEST_NAME]]";
  131. import Cpp library "explicit_object_param.h";
  132. fn Call(e: Cpp.ExplicitObjectParam, n: i32, a: Cpp.Another) {
  133. //@dump-sem-ir-begin
  134. e.F();
  135. n.(Cpp.ExplicitObjectParam.G)();
  136. a.(Cpp.ExplicitObjectParam.H)();
  137. //@dump-sem-ir-end
  138. }
  139. // --- explicit_object_param_overloaded.h
  140. struct Another {
  141. };
  142. struct ExplicitObjectParam {
  143. void F(this ExplicitObjectParam);
  144. void F(this int);
  145. void F(this Another);
  146. };
  147. // --- call_explicit_object_param_overloaded.carbon
  148. library "[[@TEST_NAME]]";
  149. import Cpp library "explicit_object_param_overloaded.h";
  150. fn Call(e: Cpp.ExplicitObjectParam, n: i32, a: Cpp.Another) {
  151. //@dump-sem-ir-begin
  152. e.F();
  153. n.(Cpp.ExplicitObjectParam.F)();
  154. a.(Cpp.ExplicitObjectParam.F)();
  155. //@dump-sem-ir-end
  156. }
  157. // CHECK:STDOUT: --- use_object_param_qualifiers.carbon
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: constants {
  160. // CHECK:STDOUT: %HasQualifiers: type = class_type @HasQualifiers [concrete]
  161. // CHECK:STDOUT: %ptr.ec3: type = ptr_type %HasQualifiers [concrete]
  162. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  163. // CHECK:STDOUT: %.602: type = cpp_overload_set_type @const_ref_this__carbon_thunk [concrete]
  164. // CHECK:STDOUT: %.ce8: %.602 = cpp_overload_set_value @const_ref_this__carbon_thunk [concrete]
  165. // CHECK:STDOUT: %const: type = const_type %HasQualifiers [concrete]
  166. // CHECK:STDOUT: %ptr.2cb: type = ptr_type %const [concrete]
  167. // CHECK:STDOUT: %const_this__carbon_thunk.type: type = fn_type @const_this__carbon_thunk [concrete]
  168. // CHECK:STDOUT: %const_this__carbon_thunk: %const_this__carbon_thunk.type = struct_value () [concrete]
  169. // CHECK:STDOUT: %.bf0: type = cpp_overload_set_type @HasQualifiers.plain [concrete]
  170. // CHECK:STDOUT: %.667: %.bf0 = cpp_overload_set_value @HasQualifiers.plain [concrete]
  171. // CHECK:STDOUT: %const_ref_this__carbon_thunk.type: type = fn_type @const_ref_this__carbon_thunk [concrete]
  172. // CHECK:STDOUT: %const_ref_this__carbon_thunk: %const_ref_this__carbon_thunk.type = struct_value () [concrete]
  173. // CHECK:STDOUT: %.64b: type = cpp_overload_set_type @HasQualifiers.ref_this [concrete]
  174. // CHECK:STDOUT: %.646: %.64b = cpp_overload_set_value @HasQualifiers.ref_this [concrete]
  175. // CHECK:STDOUT: %HasQualifiers.plain.type: type = fn_type @HasQualifiers.plain [concrete]
  176. // CHECK:STDOUT: %HasQualifiers.plain: %HasQualifiers.plain.type = struct_value () [concrete]
  177. // CHECK:STDOUT: %.352: type = cpp_overload_set_type @<null name> [concrete]
  178. // CHECK:STDOUT: %.145: %.352 = cpp_overload_set_value @<null name> [concrete]
  179. // CHECK:STDOUT: %HasQualifiers.ref_this.type: type = fn_type @HasQualifiers.ref_this [concrete]
  180. // CHECK:STDOUT: %HasQualifiers.ref_this: %HasQualifiers.ref_this.type = struct_value () [concrete]
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: imports {
  184. // CHECK:STDOUT: %.ce8: %.602 = cpp_overload_set_value @const_ref_this__carbon_thunk [concrete = constants.%.ce8]
  185. // CHECK:STDOUT: %const_this__carbon_thunk.decl: %const_this__carbon_thunk.type = fn_decl @const_this__carbon_thunk [concrete = constants.%const_this__carbon_thunk] {
  186. // CHECK:STDOUT: <elided>
  187. // CHECK:STDOUT: } {
  188. // CHECK:STDOUT: <elided>
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT: %.667: %.bf0 = cpp_overload_set_value @HasQualifiers.plain [concrete = constants.%.667]
  191. // CHECK:STDOUT: %const_ref_this__carbon_thunk.decl: %const_ref_this__carbon_thunk.type = fn_decl @const_ref_this__carbon_thunk [concrete = constants.%const_ref_this__carbon_thunk] {
  192. // CHECK:STDOUT: <elided>
  193. // CHECK:STDOUT: } {
  194. // CHECK:STDOUT: <elided>
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT: %.646: %.64b = cpp_overload_set_value @HasQualifiers.ref_this [concrete = constants.%.646]
  197. // CHECK:STDOUT: %HasQualifiers.plain.decl: %HasQualifiers.plain.type = fn_decl @HasQualifiers.plain [concrete = constants.%HasQualifiers.plain] {
  198. // CHECK:STDOUT: <elided>
  199. // CHECK:STDOUT: } {
  200. // CHECK:STDOUT: <elided>
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %.145: %.352 = cpp_overload_set_value @<null name> [concrete = constants.%.145]
  203. // CHECK:STDOUT: %HasQualifiers.ref_this.decl: %HasQualifiers.ref_this.type = fn_decl @HasQualifiers.ref_this [concrete = constants.%HasQualifiers.ref_this] {
  204. // CHECK:STDOUT: <elided>
  205. // CHECK:STDOUT: } {
  206. // CHECK:STDOUT: <elided>
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: fn @F(%v.param: %HasQualifiers, %p.param: %ptr.ec3) {
  211. // CHECK:STDOUT: !entry:
  212. // CHECK:STDOUT: %v.ref.loc8: %HasQualifiers = name_ref v, %v
  213. // CHECK:STDOUT: %const_this.ref.loc8: %.602 = name_ref const_this, imports.%.ce8 [concrete = constants.%.ce8]
  214. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %v.ref.loc8, %const_this.ref.loc8
  215. // CHECK:STDOUT: %.loc8_3: ref %HasQualifiers = value_as_ref %v.ref.loc8
  216. // CHECK:STDOUT: %addr.loc8: %ptr.ec3 = addr_of %.loc8_3
  217. // CHECK:STDOUT: %.loc8_16.1: %ptr.2cb = as_compatible %addr.loc8
  218. // CHECK:STDOUT: %.loc8_16.2: %ptr.2cb = converted %addr.loc8, %.loc8_16.1
  219. // CHECK:STDOUT: %const_this__carbon_thunk.call.loc8: init %empty_tuple.type = call imports.%const_this__carbon_thunk.decl(%.loc8_16.2)
  220. // CHECK:STDOUT: %v.ref.loc9: %HasQualifiers = name_ref v, %v
  221. // CHECK:STDOUT: %const_ref_this.ref.loc9: %.bf0 = name_ref const_ref_this, imports.%.667 [concrete = constants.%.667]
  222. // CHECK:STDOUT: %bound_method.loc9: <bound method> = bound_method %v.ref.loc9, %const_ref_this.ref.loc9
  223. // CHECK:STDOUT: %.loc9_3: ref %HasQualifiers = value_as_ref %v.ref.loc9
  224. // CHECK:STDOUT: %addr.loc9: %ptr.ec3 = addr_of %.loc9_3
  225. // CHECK:STDOUT: %.loc9_20.1: %ptr.2cb = as_compatible %addr.loc9
  226. // CHECK:STDOUT: %.loc9_20.2: %ptr.2cb = converted %addr.loc9, %.loc9_20.1
  227. // CHECK:STDOUT: %const_ref_this__carbon_thunk.call.loc9: init %empty_tuple.type = call imports.%const_ref_this__carbon_thunk.decl(%.loc9_20.2)
  228. // CHECK:STDOUT: %p.ref.loc11: %ptr.ec3 = name_ref p, %p
  229. // CHECK:STDOUT: %.loc11: ref %HasQualifiers = deref %p.ref.loc11
  230. // CHECK:STDOUT: %plain.ref: %.64b = name_ref plain, imports.%.646 [concrete = constants.%.646]
  231. // CHECK:STDOUT: %bound_method.loc11: <bound method> = bound_method %.loc11, %plain.ref
  232. // CHECK:STDOUT: %addr.loc11: %ptr.ec3 = addr_of %.loc11
  233. // CHECK:STDOUT: %HasQualifiers.plain.call: init %empty_tuple.type = call imports.%HasQualifiers.plain.decl(%addr.loc11)
  234. // CHECK:STDOUT: %p.ref.loc12: %ptr.ec3 = name_ref p, %p
  235. // CHECK:STDOUT: %.loc12: ref %HasQualifiers = deref %p.ref.loc12
  236. // CHECK:STDOUT: %ref_this.ref: %.352 = name_ref ref_this, imports.%.145 [concrete = constants.%.145]
  237. // CHECK:STDOUT: %bound_method.loc12: <bound method> = bound_method %.loc12, %ref_this.ref
  238. // CHECK:STDOUT: %addr.loc12: %ptr.ec3 = addr_of %.loc12
  239. // CHECK:STDOUT: %HasQualifiers.ref_this.call: init %empty_tuple.type = call imports.%HasQualifiers.ref_this.decl(%addr.loc12)
  240. // CHECK:STDOUT: %p.ref.loc13: %ptr.ec3 = name_ref p, %p
  241. // CHECK:STDOUT: %.loc13_4.1: ref %HasQualifiers = deref %p.ref.loc13
  242. // CHECK:STDOUT: %const_this.ref.loc13: %.602 = name_ref const_this, imports.%.ce8 [concrete = constants.%.ce8]
  243. // CHECK:STDOUT: %bound_method.loc13: <bound method> = bound_method %.loc13_4.1, %const_this.ref.loc13
  244. // CHECK:STDOUT: %.loc13_4.2: %HasQualifiers = bind_value %.loc13_4.1
  245. // CHECK:STDOUT: %.loc13_4.3: ref %HasQualifiers = value_as_ref %.loc13_4.2
  246. // CHECK:STDOUT: %addr.loc13: %ptr.ec3 = addr_of %.loc13_4.3
  247. // CHECK:STDOUT: %.loc13_17.1: %ptr.2cb = as_compatible %addr.loc13
  248. // CHECK:STDOUT: %.loc13_17.2: %ptr.2cb = converted %addr.loc13, %.loc13_17.1
  249. // CHECK:STDOUT: %const_this__carbon_thunk.call.loc13: init %empty_tuple.type = call imports.%const_this__carbon_thunk.decl(%.loc13_17.2)
  250. // CHECK:STDOUT: %p.ref.loc14: %ptr.ec3 = name_ref p, %p
  251. // CHECK:STDOUT: %.loc14_4.1: ref %HasQualifiers = deref %p.ref.loc14
  252. // CHECK:STDOUT: %const_ref_this.ref.loc14: %.bf0 = name_ref const_ref_this, imports.%.667 [concrete = constants.%.667]
  253. // CHECK:STDOUT: %bound_method.loc14: <bound method> = bound_method %.loc14_4.1, %const_ref_this.ref.loc14
  254. // CHECK:STDOUT: %.loc14_4.2: %HasQualifiers = bind_value %.loc14_4.1
  255. // CHECK:STDOUT: %.loc14_4.3: ref %HasQualifiers = value_as_ref %.loc14_4.2
  256. // CHECK:STDOUT: %addr.loc14: %ptr.ec3 = addr_of %.loc14_4.3
  257. // CHECK:STDOUT: %.loc14_21.1: %ptr.2cb = as_compatible %addr.loc14
  258. // CHECK:STDOUT: %.loc14_21.2: %ptr.2cb = converted %addr.loc14, %.loc14_21.1
  259. // CHECK:STDOUT: %const_ref_this__carbon_thunk.call.loc14: init %empty_tuple.type = call imports.%const_ref_this__carbon_thunk.decl(%.loc14_21.2)
  260. // CHECK:STDOUT: <elided>
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: --- use_object_param_qualifiers_overloaded.carbon
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: constants {
  266. // CHECK:STDOUT: %HasQualifiers: type = class_type @HasQualifiers [concrete]
  267. // CHECK:STDOUT: %ptr.ec3: type = ptr_type %HasQualifiers [concrete]
  268. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  269. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  270. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  271. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  272. // CHECK:STDOUT: %.4ab: type = cpp_overload_set_type @HasQualifiers.F.1 [concrete]
  273. // CHECK:STDOUT: %.570: %.4ab = cpp_overload_set_value @HasQualifiers.F.1 [concrete]
  274. // CHECK:STDOUT: %const: type = const_type %HasQualifiers [concrete]
  275. // CHECK:STDOUT: %ptr.2cb: type = ptr_type %const [concrete]
  276. // CHECK:STDOUT: %F__carbon_thunk.type: type = fn_type @F__carbon_thunk [concrete]
  277. // CHECK:STDOUT: %F__carbon_thunk: %F__carbon_thunk.type = struct_value () [concrete]
  278. // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
  279. // CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %ptr.235 [concrete]
  280. // CHECK:STDOUT: %HasQualifiers.F.type.d208f0.2: type = fn_type @HasQualifiers.F.2 [concrete]
  281. // CHECK:STDOUT: %HasQualifiers.F.efd4e4.2: %HasQualifiers.F.type.d208f0.2 = struct_value () [concrete]
  282. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  283. // CHECK:STDOUT: %facet_value.380: %type_where = facet_value %ptr.235, () [concrete]
  284. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.e11: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.380) [concrete]
  285. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.52b: %DestroyT.as_type.as.Destroy.impl.Op.type.e11 = struct_value () [concrete]
  286. // CHECK:STDOUT: %ptr.5d5: type = ptr_type %ptr.235 [concrete]
  287. // CHECK:STDOUT: %facet_value.d23: %type_where = facet_value %i32, () [concrete]
  288. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.type.cb3: type = fn_type @DestroyT.as_type.as.Destroy.impl.Op, @DestroyT.as_type.as.Destroy.impl(%facet_value.d23) [concrete]
  289. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.cad: %DestroyT.as_type.as.Destroy.impl.Op.type.cb3 = struct_value () [concrete]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: imports {
  293. // CHECK:STDOUT: %.570: %.4ab = cpp_overload_set_value @HasQualifiers.F.1 [concrete = constants.%.570]
  294. // CHECK:STDOUT: %F__carbon_thunk.decl: %F__carbon_thunk.type = fn_decl @F__carbon_thunk [concrete = constants.%F__carbon_thunk] {
  295. // CHECK:STDOUT: <elided>
  296. // CHECK:STDOUT: } {
  297. // CHECK:STDOUT: <elided>
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT: %HasQualifiers.F.decl.f862ea.2: %HasQualifiers.F.type.d208f0.2 = fn_decl @HasQualifiers.F.2 [concrete = constants.%HasQualifiers.F.efd4e4.2] {
  300. // CHECK:STDOUT: <elided>
  301. // CHECK:STDOUT: } {
  302. // CHECK:STDOUT: <elided>
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: fn @CallF(%v.param: %HasQualifiers, %p.param: %ptr.ec3) {
  307. // CHECK:STDOUT: !entry:
  308. // CHECK:STDOUT: name_binding_decl {
  309. // CHECK:STDOUT: %a.patt: %pattern_type.7ce = binding_pattern a [concrete]
  310. // CHECK:STDOUT: %a.var_patt: %pattern_type.7ce = var_pattern %a.patt [concrete]
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT: %a.var: ref %i32 = var %a.var_patt
  313. // CHECK:STDOUT: %v.ref: %HasQualifiers = name_ref v, %v
  314. // CHECK:STDOUT: %F.ref.loc8: %.4ab = name_ref F, imports.%.570 [concrete = constants.%.570]
  315. // CHECK:STDOUT: %bound_method.loc8_17: <bound method> = bound_method %v.ref, %F.ref.loc8
  316. // CHECK:STDOUT: %.loc8_16: ref %HasQualifiers = value_as_ref %v.ref
  317. // CHECK:STDOUT: %addr.loc8_20: %ptr.ec3 = addr_of %.loc8_16
  318. // CHECK:STDOUT: %.loc8_20.1: %ptr.2cb = as_compatible %addr.loc8_20
  319. // CHECK:STDOUT: %.loc8_20.2: %ptr.2cb = converted %addr.loc8_20, %.loc8_20.1
  320. // CHECK:STDOUT: %F__carbon_thunk.call: init %i32 = call imports.%F__carbon_thunk.decl(%.loc8_20.2)
  321. // CHECK:STDOUT: assign %a.var, %F__carbon_thunk.call
  322. // CHECK:STDOUT: %.loc8_10: type = splice_block %i32.loc8 [concrete = constants.%i32] {
  323. // CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  324. // CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  325. // CHECK:STDOUT: }
  326. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  327. // CHECK:STDOUT: name_binding_decl {
  328. // CHECK:STDOUT: %b.patt: %pattern_type.fe8 = binding_pattern b [concrete]
  329. // CHECK:STDOUT: %b.var_patt: %pattern_type.fe8 = var_pattern %b.patt [concrete]
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT: %b.var: ref %ptr.235 = var %b.var_patt
  332. // CHECK:STDOUT: %p.ref: %ptr.ec3 = name_ref p, %p
  333. // CHECK:STDOUT: %.loc9_18: ref %HasQualifiers = deref %p.ref
  334. // CHECK:STDOUT: %F.ref.loc9: %.4ab = name_ref F, imports.%.570 [concrete = constants.%.570]
  335. // CHECK:STDOUT: %bound_method.loc9_18: <bound method> = bound_method %.loc9_18, %F.ref.loc9
  336. // CHECK:STDOUT: %addr.loc9_18: %ptr.ec3 = addr_of %.loc9_18
  337. // CHECK:STDOUT: %HasQualifiers.F.call: init %ptr.235 = call imports.%HasQualifiers.F.decl.f862ea.2(%addr.loc9_18)
  338. // CHECK:STDOUT: assign %b.var, %HasQualifiers.F.call
  339. // CHECK:STDOUT: %.loc9_13: type = splice_block %ptr.loc9 [concrete = constants.%ptr.235] {
  340. // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  341. // CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  342. // CHECK:STDOUT: %ptr.loc9: type = ptr_type %i32.loc9 [concrete = constants.%ptr.235]
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT: %b: ref %ptr.235 = bind_name b, %b.var
  345. // CHECK:STDOUT: %facet_value.loc9: %type_where = facet_value constants.%ptr.235, () [concrete = constants.%facet_value.380]
  346. // CHECK:STDOUT: %.loc9_3: %type_where = converted constants.%ptr.235, %facet_value.loc9 [concrete = constants.%facet_value.380]
  347. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc9: <bound method> = bound_method %b.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.52b
  348. // CHECK:STDOUT: <elided>
  349. // CHECK:STDOUT: %bound_method.loc9_3: <bound method> = bound_method %b.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.1
  350. // CHECK:STDOUT: %addr.loc9_3: %ptr.5d5 = addr_of %b.var
  351. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc9: init %empty_tuple.type = call %bound_method.loc9_3(%addr.loc9_3)
  352. // CHECK:STDOUT: %facet_value.loc8: %type_where = facet_value constants.%i32, () [concrete = constants.%facet_value.d23]
  353. // CHECK:STDOUT: %.loc8_3: %type_where = converted constants.%i32, %facet_value.loc8 [concrete = constants.%facet_value.d23]
  354. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.bound.loc8: <bound method> = bound_method %a.var, constants.%DestroyT.as_type.as.Destroy.impl.Op.cad
  355. // CHECK:STDOUT: <elided>
  356. // CHECK:STDOUT: %bound_method.loc8_3: <bound method> = bound_method %a.var, %DestroyT.as_type.as.Destroy.impl.Op.specific_fn.2
  357. // CHECK:STDOUT: %addr.loc8_3: %ptr.235 = addr_of %a.var
  358. // CHECK:STDOUT: %DestroyT.as_type.as.Destroy.impl.Op.call.loc8: init %empty_tuple.type = call %bound_method.loc8_3(%addr.loc8_3)
  359. // CHECK:STDOUT: <elided>
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: --- call_explicit_object_param.carbon
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: constants {
  365. // CHECK:STDOUT: %ExplicitObjectParam: type = class_type @ExplicitObjectParam [concrete]
  366. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  367. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  368. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  369. // CHECK:STDOUT: %Another: type = class_type @Another [concrete]
  370. // CHECK:STDOUT: %.3e2: type = cpp_overload_set_type @ExplicitObjectParam.G [concrete]
  371. // CHECK:STDOUT: %.037: %.3e2 = cpp_overload_set_value @ExplicitObjectParam.G [concrete]
  372. // CHECK:STDOUT: %ptr.7f5: type = ptr_type %ExplicitObjectParam [concrete]
  373. // CHECK:STDOUT: %F__carbon_thunk.type: type = fn_type @F__carbon_thunk [concrete]
  374. // CHECK:STDOUT: %F__carbon_thunk: %F__carbon_thunk.type = struct_value () [concrete]
  375. // CHECK:STDOUT: %.d44: type = cpp_overload_set_type @ExplicitObjectParam.H [concrete]
  376. // CHECK:STDOUT: %.151: %.d44 = cpp_overload_set_value @ExplicitObjectParam.H [concrete]
  377. // CHECK:STDOUT: %ExplicitObjectParam.G.type: type = fn_type @ExplicitObjectParam.G [concrete]
  378. // CHECK:STDOUT: %ExplicitObjectParam.G: %ExplicitObjectParam.G.type = struct_value () [concrete]
  379. // CHECK:STDOUT: %.9fb: type = cpp_overload_set_type @H__carbon_thunk [concrete]
  380. // CHECK:STDOUT: %.34a: %.9fb = cpp_overload_set_value @H__carbon_thunk [concrete]
  381. // CHECK:STDOUT: %ptr.289: type = ptr_type %Another [concrete]
  382. // CHECK:STDOUT: %H__carbon_thunk.type: type = fn_type @H__carbon_thunk [concrete]
  383. // CHECK:STDOUT: %H__carbon_thunk: %H__carbon_thunk.type = struct_value () [concrete]
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: imports {
  387. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  388. // CHECK:STDOUT: .ExplicitObjectParam = %ExplicitObjectParam.decl
  389. // CHECK:STDOUT: .Another = %Another.decl
  390. // CHECK:STDOUT: import Cpp//...
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT: %ExplicitObjectParam.decl: type = class_decl @ExplicitObjectParam [concrete = constants.%ExplicitObjectParam] {} {}
  393. // CHECK:STDOUT: %Another.decl: type = class_decl @Another [concrete = constants.%Another] {} {}
  394. // CHECK:STDOUT: %.037: %.3e2 = cpp_overload_set_value @ExplicitObjectParam.G [concrete = constants.%.037]
  395. // CHECK:STDOUT: %F__carbon_thunk.decl: %F__carbon_thunk.type = fn_decl @F__carbon_thunk [concrete = constants.%F__carbon_thunk] {
  396. // CHECK:STDOUT: <elided>
  397. // CHECK:STDOUT: } {
  398. // CHECK:STDOUT: <elided>
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT: %.151: %.d44 = cpp_overload_set_value @ExplicitObjectParam.H [concrete = constants.%.151]
  401. // CHECK:STDOUT: %ExplicitObjectParam.G.decl: %ExplicitObjectParam.G.type = fn_decl @ExplicitObjectParam.G [concrete = constants.%ExplicitObjectParam.G] {
  402. // CHECK:STDOUT: <elided>
  403. // CHECK:STDOUT: } {
  404. // CHECK:STDOUT: <elided>
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT: %.34a: %.9fb = cpp_overload_set_value @H__carbon_thunk [concrete = constants.%.34a]
  407. // CHECK:STDOUT: %H__carbon_thunk.decl: %H__carbon_thunk.type = fn_decl @H__carbon_thunk [concrete = constants.%H__carbon_thunk] {
  408. // CHECK:STDOUT: <elided>
  409. // CHECK:STDOUT: } {
  410. // CHECK:STDOUT: <elided>
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: fn @Call(%e.param: %ExplicitObjectParam, %n.param: %i32, %a.param: %Another) {
  415. // CHECK:STDOUT: !entry:
  416. // CHECK:STDOUT: %e.ref: %ExplicitObjectParam = name_ref e, %e
  417. // CHECK:STDOUT: %F.ref: %.3e2 = name_ref F, imports.%.037 [concrete = constants.%.037]
  418. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %e.ref, %F.ref
  419. // CHECK:STDOUT: %.loc8: ref %ExplicitObjectParam = value_as_ref %e.ref
  420. // CHECK:STDOUT: %addr.loc8: %ptr.7f5 = addr_of %.loc8
  421. // CHECK:STDOUT: %F__carbon_thunk.call: init %empty_tuple.type = call imports.%F__carbon_thunk.decl(%addr.loc8)
  422. // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
  423. // CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  424. // CHECK:STDOUT: %ExplicitObjectParam.ref.loc9: type = name_ref ExplicitObjectParam, imports.%ExplicitObjectParam.decl [concrete = constants.%ExplicitObjectParam]
  425. // CHECK:STDOUT: %G.ref: %.d44 = name_ref G, imports.%.151 [concrete = constants.%.151]
  426. // CHECK:STDOUT: %bound_method.loc9: <bound method> = bound_method %n.ref, %G.ref
  427. // CHECK:STDOUT: %ExplicitObjectParam.G.call: init %empty_tuple.type = call imports.%ExplicitObjectParam.G.decl(%n.ref)
  428. // CHECK:STDOUT: %a.ref: %Another = name_ref a, %a
  429. // CHECK:STDOUT: %Cpp.ref.loc10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  430. // CHECK:STDOUT: %ExplicitObjectParam.ref.loc10: type = name_ref ExplicitObjectParam, imports.%ExplicitObjectParam.decl [concrete = constants.%ExplicitObjectParam]
  431. // CHECK:STDOUT: %H.ref: %.9fb = name_ref H, imports.%.34a [concrete = constants.%.34a]
  432. // CHECK:STDOUT: %bound_method.loc10: <bound method> = bound_method %a.ref, %H.ref
  433. // CHECK:STDOUT: %.loc10: ref %Another = value_as_ref %a.ref
  434. // CHECK:STDOUT: %addr.loc10: %ptr.289 = addr_of %.loc10
  435. // CHECK:STDOUT: %H__carbon_thunk.call: init %empty_tuple.type = call imports.%H__carbon_thunk.decl(%addr.loc10)
  436. // CHECK:STDOUT: <elided>
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: --- call_explicit_object_param_overloaded.carbon
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: constants {
  442. // CHECK:STDOUT: %ExplicitObjectParam: type = class_type @ExplicitObjectParam [concrete]
  443. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  444. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  445. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  446. // CHECK:STDOUT: %Another: type = class_type @Another [concrete]
  447. // CHECK:STDOUT: %.3e2: type = cpp_overload_set_type @ExplicitObjectParam.F.1 [concrete]
  448. // CHECK:STDOUT: %.037: %.3e2 = cpp_overload_set_value @ExplicitObjectParam.F.1 [concrete]
  449. // CHECK:STDOUT: %ptr.7f5: type = ptr_type %ExplicitObjectParam [concrete]
  450. // CHECK:STDOUT: %F__carbon_thunk.type.eda1ac.1: type = fn_type @F__carbon_thunk.1 [concrete]
  451. // CHECK:STDOUT: %F__carbon_thunk.0cd6a8.1: %F__carbon_thunk.type.eda1ac.1 = struct_value () [concrete]
  452. // CHECK:STDOUT: %ExplicitObjectParam.F.type.5d25a8.2: type = fn_type @ExplicitObjectParam.F.2 [concrete]
  453. // CHECK:STDOUT: %ExplicitObjectParam.F.28cf2e.2: %ExplicitObjectParam.F.type.5d25a8.2 = struct_value () [concrete]
  454. // CHECK:STDOUT: %ptr.289: type = ptr_type %Another [concrete]
  455. // CHECK:STDOUT: %F__carbon_thunk.type.eda1ac.2: type = fn_type @F__carbon_thunk.2 [concrete]
  456. // CHECK:STDOUT: %F__carbon_thunk.0cd6a8.2: %F__carbon_thunk.type.eda1ac.2 = struct_value () [concrete]
  457. // CHECK:STDOUT: }
  458. // CHECK:STDOUT:
  459. // CHECK:STDOUT: imports {
  460. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  461. // CHECK:STDOUT: .ExplicitObjectParam = %ExplicitObjectParam.decl
  462. // CHECK:STDOUT: .Another = %Another.decl
  463. // CHECK:STDOUT: import Cpp//...
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT: %ExplicitObjectParam.decl: type = class_decl @ExplicitObjectParam [concrete = constants.%ExplicitObjectParam] {} {}
  466. // CHECK:STDOUT: %Another.decl: type = class_decl @Another [concrete = constants.%Another] {} {}
  467. // CHECK:STDOUT: %.037: %.3e2 = cpp_overload_set_value @ExplicitObjectParam.F.1 [concrete = constants.%.037]
  468. // CHECK:STDOUT: %F__carbon_thunk.decl.e1b8ec.1: %F__carbon_thunk.type.eda1ac.1 = fn_decl @F__carbon_thunk.1 [concrete = constants.%F__carbon_thunk.0cd6a8.1] {
  469. // CHECK:STDOUT: <elided>
  470. // CHECK:STDOUT: } {
  471. // CHECK:STDOUT: <elided>
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT: %ExplicitObjectParam.F.decl.28f5af.2: %ExplicitObjectParam.F.type.5d25a8.2 = fn_decl @ExplicitObjectParam.F.2 [concrete = constants.%ExplicitObjectParam.F.28cf2e.2] {
  474. // CHECK:STDOUT: <elided>
  475. // CHECK:STDOUT: } {
  476. // CHECK:STDOUT: <elided>
  477. // CHECK:STDOUT: }
  478. // CHECK:STDOUT: %F__carbon_thunk.decl.e1b8ec.2: %F__carbon_thunk.type.eda1ac.2 = fn_decl @F__carbon_thunk.2 [concrete = constants.%F__carbon_thunk.0cd6a8.2] {
  479. // CHECK:STDOUT: <elided>
  480. // CHECK:STDOUT: } {
  481. // CHECK:STDOUT: <elided>
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT: }
  484. // CHECK:STDOUT:
  485. // CHECK:STDOUT: fn @Call(%e.param: %ExplicitObjectParam, %n.param: %i32, %a.param: %Another) {
  486. // CHECK:STDOUT: !entry:
  487. // CHECK:STDOUT: %e.ref: %ExplicitObjectParam = name_ref e, %e
  488. // CHECK:STDOUT: %F.ref.loc8: %.3e2 = name_ref F, imports.%.037 [concrete = constants.%.037]
  489. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %e.ref, %F.ref.loc8
  490. // CHECK:STDOUT: %.loc8: ref %ExplicitObjectParam = value_as_ref %e.ref
  491. // CHECK:STDOUT: %addr.loc8: %ptr.7f5 = addr_of %.loc8
  492. // CHECK:STDOUT: %F__carbon_thunk.call.loc8: init %empty_tuple.type = call imports.%F__carbon_thunk.decl.e1b8ec.1(%addr.loc8)
  493. // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
  494. // CHECK:STDOUT: %Cpp.ref.loc9: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  495. // CHECK:STDOUT: %ExplicitObjectParam.ref.loc9: type = name_ref ExplicitObjectParam, imports.%ExplicitObjectParam.decl [concrete = constants.%ExplicitObjectParam]
  496. // CHECK:STDOUT: %F.ref.loc9: %.3e2 = name_ref F, imports.%.037 [concrete = constants.%.037]
  497. // CHECK:STDOUT: %bound_method.loc9: <bound method> = bound_method %n.ref, %F.ref.loc9
  498. // CHECK:STDOUT: %ExplicitObjectParam.F.call: init %empty_tuple.type = call imports.%ExplicitObjectParam.F.decl.28f5af.2(%n.ref)
  499. // CHECK:STDOUT: %a.ref: %Another = name_ref a, %a
  500. // CHECK:STDOUT: %Cpp.ref.loc10: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  501. // CHECK:STDOUT: %ExplicitObjectParam.ref.loc10: type = name_ref ExplicitObjectParam, imports.%ExplicitObjectParam.decl [concrete = constants.%ExplicitObjectParam]
  502. // CHECK:STDOUT: %F.ref.loc10: %.3e2 = name_ref F, imports.%.037 [concrete = constants.%.037]
  503. // CHECK:STDOUT: %bound_method.loc10: <bound method> = bound_method %a.ref, %F.ref.loc10
  504. // CHECK:STDOUT: %.loc10: ref %Another = value_as_ref %a.ref
  505. // CHECK:STDOUT: %addr.loc10: %ptr.289 = addr_of %.loc10
  506. // CHECK:STDOUT: %F__carbon_thunk.call.loc10: init %empty_tuple.type = call imports.%F__carbon_thunk.decl.e1b8ec.2(%addr.loc10)
  507. // CHECK:STDOUT: <elided>
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT: