1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++11 | FileCheck %s -check-prefixes=CHECK,NULL-INVALID,CHECK-CXX11
2 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++17 | FileCheck %s -check-prefixes=CHECK,NULL-INVALID,CHECK-CXX17
3 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++11 -fno-delete-null-pointer-checks | FileCheck %s -check-prefixes=CHECK,NULL-VALID,CHECK-CXX11
6 const unsigned int n
= 1234;
7 extern const int &r
= (const int&)n
;
8 // CHECK: @_ZGRN7PR162631rE_ = internal constant i32 1234,
9 // CHECK: @_ZN7PR162631rE ={{.*}} constant ptr @_ZGRN7PR162631rE_,
11 extern const int &s
= reinterpret_cast<const int&>(n
);
12 // CHECK: @_ZN7PR16263L1nE = internal constant i32 1234, align 4
13 // CHECK: @_ZN7PR162631sE ={{.*}} constant ptr @_ZN7PR16263L1nE, align 8
18 extern const A
&&a
= (A
&&)(A
&&)(C
&&)(C
{});
19 // CHECK: @_ZGRN7PR162631aE_ = internal global {{.*}} zeroinitializer,
20 // CHECK: @_ZN7PR162631aE ={{.*}} constant {{.*}} @_ZGRN7PR162631aE_
22 extern const int &&t
= ((B
&&)C
{}).n
;
23 // CHECK: @_ZGRN7PR162631tE_ = internal global {{.*}} zeroinitializer,
24 // CHECK: @_ZN7PR162631tE ={{.*}} constant ptr {{.*}} @_ZGRN7PR162631tE_, {{.*}} 4
26 struct D
{ double d
; C c
; };
27 extern const int &&u
= (123, static_cast<B
&&>(0, ((D
&&)D
{}).*&D::c
).n
);
28 // CHECK: @_ZGRN7PR162631uE_ = internal global {{.*}} zeroinitializer
29 // CHECK: @_ZN7PR162631uE ={{.*}} constant ptr {{.*}} @_ZGRN7PR162631uE_, {{.*}} 12
34 struct B
{ virtual ~B(); };
37 A
&&a
= dynamic_cast<A
&&>(A
{});
38 // CHECK: @_ZGRN7PR202271aE_ = internal global
40 B
&&b
= dynamic_cast<C
&&>(dynamic_cast<B
&&>(C
{}));
41 // CHECK: @_ZGRN7PR202271bE_ = internal global
43 B
&&c
= static_cast<C
&&>(static_cast<B
&&>(C
{}));
44 // CHECK: @_ZGRN7PR202271cE_ = internal global
48 typedef const int &CIR
;
50 // CHECK-CXX11: @_ZGRN9BraceInit1xE_ = internal constant i32 3
51 // FIXME: This should still be emitted as 'constant' in C++17.
52 // CHECK-CXX17: @_ZGRN9BraceInit1xE_ = internal global i32 3
53 // CHECK: @_ZN9BraceInit1xE ={{.*}} constant ptr @_ZGRN9BraceInit1xE_
56 namespace RefTempSubobject
{
57 struct SelfReferential
{
59 int ints
[3] = {1, 2, 3};
62 // CHECK: @_ZGRN16RefTempSubobject2srE_ = internal global { ptr, [3 x i32] } { {{.*}} getelementptr {{.*}} @_ZGRN16RefTempSubobject2srE_, {{.*}}, [3 x i32] [i32 1, i32 2, i32 3] }
63 // CHECK: @_ZN16RefTempSubobject2srE = constant {{.*}} @_ZGRN16RefTempSubobject2srE_
64 constexpr const SelfReferential
&sr
= SelfReferential();
74 // CHECK: call void @_ZN1AC1Ev
75 // CHECK: call void @_ZN1AD1Ev
78 // CHECK: call void @_ZN1AC1Ev
79 // CHECK: call void @_ZN1AD1Ev
92 // CHECK-NOT: call void @_ZN1BC1Ev
93 // CHECK: call void @_ZN1BD1Ev
97 // Member function calls
106 // CHECK: call void @_ZN1CC1Ev
107 // CHECK: call void @_ZN1CD1Ev
108 // CHECK: call void @_ZN1CD1Ev
112 // Function call operator
121 // CHECK: call void @_ZN1DC1Ev
122 // CHECK: call void @_ZN1DD1Ev
123 // CHECK: call void @_ZN1DD1Ev
127 // Overloaded operators
131 E
operator+(const E
&);
136 // CHECK: call void @_ZN1EC1Ev
137 // CHECK: call void @_ZN1EC1Ev
138 // CHECK: call void @_ZN1ED1Ev
139 // CHECK: call void @_ZN1ED1Ev
140 // CHECK: call void @_ZN1ED1Ev
143 // CHECK: call void @_ZN1EC1Ev
144 // CHECK: call void @_ZN1ED1Ev
145 // CHECK: call void @_ZN1ED1Ev
156 // CHECK: call void @_ZN1FC1Ev
157 // CHECK: call void @_ZN1FD1Ev
171 // CHECK: call void @_ZN1AC1Ev
172 // CHECK: call void @_Z1aRK1A
173 // CHECK: call void @_ZN1AD1Ev
176 // CHECK: call void @_ZN1GC1Ev
177 // CHECK: call void @_ZN1Gcv1AEv
178 // CHECK: call void @_Z1aRK1A
179 // CHECK: call void @_ZN1AD1Ev
180 // CHECK: call void @_ZN1GD1Ev
203 // CHECK: call void @_ZN6PR50771AC1Ev
204 // CHECK: call noundef i32 @_ZN6PR50771A1fEv
205 // CHECK: call void @_ZN6PR50771AD1Ev
207 // CHECK: call void @_ZN6PR50771AC1Ev
208 // CHECK: call noundef i32 @_ZN6PR50771gERKNS_1AE
209 // CHECK: call void @_ZN6PR50771AD1Ev
212 // CHECK: call void @_ZN6PR50771fEv
219 // CHECK: call void @_ZN1AC1Ev
220 // CHECK-NOT: call void @_ZN1AD1Ev
232 // CHECK: call void @_ZN1HC1Ev
233 // CHECK: call void @_Z2f91H
234 // CHECK: call void @_ZN1HD1Ev
237 // CHECK: call void @_ZN1HC1ERKS_
238 // CHECK: call void @_Z2f91H
239 // CHECK: call void @_ZN1HD1Ev
246 // CHECK: call void @_ZN1HC1Ev
247 // CHECK: call void @_Z3f10RK1H
248 // CHECK: call void @_ZN1HD1Ev
251 // CHECK: call void @_Z3f10RK1H
252 // CHECK-NOT: call void @_ZN1HD1Ev
265 // CHECK: call void @_ZN1IC1EPKc
266 // CHECK-NOT: call void @_ZN1ID1Ev
280 // CHECK-LABEL: define{{.*}} void @_ZN6PR58671gEv
282 // CHECK: call void @_ZN6PR58671SC1Ev
283 // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi
284 // CHECK-NEXT: call void @_ZN6PR58671SD1Ev
285 // CHECK-NEXT: ret void
289 // CHECK-LABEL: define linkonce_odr void @_ZN6PR58672g2IiEEvT_
292 // CHECK: call void @_ZN6PR58671SC1Ev
293 // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi
294 // CHECK-NEXT: call void @_ZN6PR58671SD1Ev
295 // CHECK-NEXT: ret void
308 struct B
{ operator A(); };
310 // CHECK-LABEL: define weak_odr void @_ZN6PR61992f2IiEENS_1AET_
311 template<typename T
> A
f2(T
) {
313 // CHECK: call void @_ZN6PR61991BcvNS_1AEEv
314 // CHECK-NEXT: ret void
318 template A f2
<int>(int);
332 // CHECK-LABEL: define{{.*}} void @_ZN3T121gEv
334 // CHECK: call void @_ZN3T121AC1Ev
335 // CHECK-NEXT: call noundef i32 @_ZN3T121A1fEv(
336 // CHECK-NEXT: call noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN3T121fEi(
337 // CHECK-NEXT: call void @_ZN3T121AD1Ev(
351 // NULL-INVALID: call noundef nonnull align 1 ptr @_ZN6PR66483zedENS_1BE
352 // NULL-VALID: call noundef align 1 ptr @_ZN6PR66483zedENS_1BE
357 namespace UserConvertToValue
{
366 // CHECK: void @_ZN18UserConvertToValue1gEv()
368 // CHECK: call void @_ZN18UserConvertToValue1XC1Ei
369 // CHECK: call void @_ZN18UserConvertToValue1fENS_1XE
370 // CHECK: call void @_ZN18UserConvertToValue1XD1Ev
378 struct B
{ int i
; ~B(); };
379 struct C
{ int C::*pm
; ~C(); };
380 // CHECK-LABEL: define{{.*}} void @_ZN6PR75563fooEv()
382 // CHECK: call void @_ZN6PR75561AD1Ev
384 // CHECK: call void @llvm.memset.p0.i64
385 // CHECK: call void @_ZN6PR75561BD1Ev
387 // CHECK: call void @llvm.memcpy.p0.p0.i64
388 // CHECK: call void @_ZN6PR75561CD1Ev
390 // CHECK-NEXT: ret void
396 A(); A(const A
&); ~A();
405 // CHECK-LABEL: define{{.*}} void @_ZN7Elision5test0Ev()
407 // CHECK: [[I:%.*]] = alloca [[A:%.*]], align 8
408 // CHECK-NEXT: [[J:%.*]] = alloca [[A]], align 8
409 // CHECK-NEXT: [[T0:%.*]] = alloca [[A]], align 8
410 // CHECK-NEXT: [[K:%.*]] = alloca [[A]], align 8
411 // CHECK-NEXT: [[T1:%.*]] = alloca [[A]], align 8
413 // CHECK-NEXT: call void @_ZN7Elision3fooEv()
414 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[I]])
417 // CHECK-NEXT: call void @_ZN7Elision4fooAEv(ptr sret([[A]]) align 8 [[T0]])
418 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[J]])
419 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[T0]])
422 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[T1]])
423 // CHECK-NEXT: call void @_ZN7Elision4fooAEv(ptr sret([[A]]) align 8 [[K]])
424 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[T1]])
427 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[K]])
428 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[J]])
429 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[I]])
433 // CHECK-LABEL: define{{.*}} void @_ZN7Elision5test1EbNS_1AE(
434 void test1(bool c
, A x
) {
435 // CHECK: [[I:%.*]] = alloca [[A]], align 8
436 // CHECK-NEXT: [[J:%.*]] = alloca [[A]], align 8
438 // CHECK: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[I]])
439 // CHECK: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[I]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[X:%.*]])
442 // CHECK: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[J]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[X]])
443 // CHECK: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[J]])
446 // CHECK: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[J]])
447 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[I]])
450 // CHECK: define{{.*}} void @_ZN7Elision5test2Ev(ptr noalias sret([[A]]) align 8
452 // CHECK: call void @_ZN7Elision3fooEv()
453 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[RET:%.*]])
454 // CHECK-NEXT: ret void
458 // CHECK: define{{.*}} void @_ZN7Elision5test3EiNS_1AE(ptr noalias sret([[A]]) align 8
459 A
test3(int v
, A x
) {
461 // CHECK: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[RET:%.*]])
462 // CHECK: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[RET]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[X:%.*]])
463 return (v
< 0 ? A() : x
);
465 // CHECK: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[RET]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[X]])
466 // CHECK: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[RET]])
467 return (v
> 10 ? x
: A());
472 // CHECK-LABEL: define{{.*}} void @_ZN7Elision5test4Ev()
474 // CHECK: [[X:%.*]] = alloca [[A]], align 8
475 // CHECK-NEXT: [[XS:%.*]] = alloca [2 x [[A]]], align 16
477 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[X]])
480 // CHECK-NEXT: [[XS0:%.*]] = getelementptr inbounds [2 x [[A]]], ptr [[XS]], i64 0, i64 0
481 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev(ptr {{[^,]*}} [[XS0]])
482 // CHECK-NEXT: [[XS1:%.*]] = getelementptr inbounds [[A]], ptr [[XS0]], i64 1
483 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[XS1]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[X]])
486 // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [2 x [[A]]], ptr [[XS]], i32 0, i32 0
487 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]], ptr [[BEGIN]], i64 2
488 // CHECK-NEXT: br label
489 // CHECK: [[AFTER:%.*]] = phi ptr
490 // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds [[A]], ptr [[AFTER]], i64 -1
491 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[CUR]])
492 // CHECK-NEXT: [[T0:%.*]] = icmp eq ptr [[CUR]], [[BEGIN]]
493 // CHECK-NEXT: br i1 [[T0]],
495 // CHECK: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[X]])
498 // CHECK: define{{.*}} void @_ZN7Elision5test5Ev(ptr noalias sret([[A]]) align 8
499 struct B
{ A a
; B(); };
501 // CHECK: [[AT0:%.*]] = alloca [[A]], align 8
502 // CHECK-NEXT: [[BT0:%.*]] = alloca [[B:%.*]], align 8
503 // CHECK-NEXT: [[X:%.*]] = alloca [[A]], align 8
504 // CHECK-NEXT: [[BT1:%.*]] = alloca [[B]], align 8
505 // CHECK-NEXT: [[BT2:%.*]] = alloca [[B]], align 8
507 // CHECK: call void @_ZN7Elision1BC1Ev(ptr {{[^,]*}} [[BT0]])
508 // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]], ptr [[BT0]], i32 0, i32 0
509 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[AT0]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[AM]])
510 // CHECK-NEXT: call void @_ZN7Elision5takeAENS_1AE(ptr noundef [[AT0]])
511 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[AT0]])
512 // CHECK-NEXT: call void @_ZN7Elision1BD1Ev(ptr {{[^,]*}} [[BT0]])
515 // CHECK-NEXT: call void @_ZN7Elision1BC1Ev(ptr {{[^,]*}} [[BT1]])
516 // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]], ptr [[BT1]], i32 0, i32 0
517 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[X]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[AM]])
518 // CHECK-NEXT: call void @_ZN7Elision1BD1Ev(ptr {{[^,]*}} [[BT1]])
521 // CHECK-NEXT: call void @_ZN7Elision1BC1Ev(ptr {{[^,]*}} [[BT2]])
522 // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]], ptr [[BT2]], i32 0, i32 0
523 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_(ptr {{[^,]*}} [[RET:%.*]], ptr noundef {{(nonnull )?}}align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[AM]])
524 // CHECK-NEXT: call void @_ZN7Elision1BD1Ev(ptr {{[^,]*}} [[BT2]])
527 // CHECK: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[X]])
530 // Reduced from webkit.
531 // CHECK: define{{.*}} void @_ZN7Elision5test6EPKNS_1CE(ptr
532 struct C
{ operator A() const; };
533 void test6(const C
*x
) {
534 // CHECK: [[T0:%.*]] = alloca [[A]], align 8
535 // CHECK: [[X:%.*]] = load ptr, ptr {{%.*}}, align 8
536 // CHECK-NEXT: call void @_ZNK7Elision1CcvNS_1AEEv(ptr sret([[A]]) align 8 [[T0]], ptr {{[^,]*}} [[X]])
537 // CHECK-NEXT: call void @_ZNK7Elision1A3fooEv(ptr {{[^,]*}} [[T0]])
538 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev(ptr {{[^,]*}} [[T0]])
539 // CHECK-NEXT: ret void
545 struct A
{ A(int); ~A(); };
547 // CHECK-LABEL: define{{.*}} void @_ZN6PR86233fooEb(
549 // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1
550 // CHECK-NEXT: [[LCONS:%.*]] = alloca i1
551 // CHECK-NEXT: [[RCONS:%.*]] = alloca i1
552 // CHECK: store i1 false, ptr [[LCONS]]
553 // CHECK-NEXT: store i1 false, ptr [[RCONS]]
555 // CHECK: call void @_ZN6PR86231AC1Ei(ptr {{[^,]*}} [[TMP]], i32 noundef 2)
556 // CHECK-NEXT: store i1 true, ptr [[LCONS]]
557 // CHECK-NEXT: br label
558 // CHECK: call void @_ZN6PR86231AC1Ei(ptr {{[^,]*}} [[TMP]], i32 noundef 3)
559 // CHECK-NEXT: store i1 true, ptr [[RCONS]]
560 // CHECK-NEXT: br label
561 // CHECK: load i1, ptr [[RCONS]]
563 // CHECK: call void @_ZN6PR86231AD1Ev(ptr {{[^,]*}} [[TMP]])
564 // CHECK-NEXT: br label
565 // CHECK: load i1, ptr [[LCONS]]
567 // CHECK: call void @_ZN6PR86231AD1Ev(ptr {{[^,]*}} [[TMP]])
568 // CHECK-NEXT: br label
575 struct A
{ A(); ~A(); };
577 // CHECK-LABEL: define{{.*}} void @_ZN7PR113653fooEv(
579 // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [3 x [[A:%.*]]], ptr {{.*}}, i32 0, i32 0
580 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]], ptr [[BEGIN]], i64 3
581 // CHECK-NEXT: br label
583 // CHECK: [[PHI:%.*]] = phi
584 // CHECK-NEXT: [[ELEM:%.*]] = getelementptr inbounds [[A]], ptr [[PHI]], i64 -1
585 // CHECK-NEXT: call void @_ZN7PR113651AD1Ev(ptr {{[^,]*}} [[ELEM]])
586 // CHECK-NEXT: icmp eq ptr [[ELEM]], [[BEGIN]]
592 namespace AssignmentOp
{
594 struct B
{ A
operator=(const B
&); };
595 struct C
: B
{ B b1
, b2
; };
596 // CHECK-LABEL: define{{.*}} void @_ZN12AssignmentOp1fE
597 void f(C
&c1
, const C
&c2
) {
598 // CHECK: call {{.*}} @_ZN12AssignmentOp1CaSERKS0_(
602 // Ensure that each 'A' temporary is destroyed before the next subobject is
604 // CHECK: define {{.*}} @_ZN12AssignmentOp1CaSERKS0_(
605 // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS
606 // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev(
607 // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS
608 // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev(
609 // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS
610 // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev(
613 namespace BindToSubobject
{
622 // CHECK: call void @_ZN15BindToSubobject1AC1Ev({{.*}} @_ZGRN15BindToSubobject1aE_)
623 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN15BindToSubobject1AD1Ev, ptr @_ZGRN15BindToSubobject1aE_, ptr @__dso_handle)
624 // CHECK: store ptr @_ZGRN15BindToSubobject1aE_, ptr @_ZN15BindToSubobject1aE, align 8
627 // CHECK: call void @_ZN15BindToSubobject1fEv()
628 // CHECK: call void @_ZN15BindToSubobject1AC1Ev({{.*}} @_ZGRN15BindToSubobject1bE_)
629 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN15BindToSubobject1AD1Ev, ptr @_ZGRN15BindToSubobject1bE_, ptr @__dso_handle)
630 // CHECK: store ptr @_ZGRN15BindToSubobject1bE_, ptr @_ZN15BindToSubobject1bE, align 8
631 int &&b
= (f(), A().a
);
635 // CHECK: call void @_ZN15BindToSubobject1fEv()
636 // CHECK: call void @_ZN15BindToSubobject1gEv()
637 // CHECK: call void @_ZN15BindToSubobject1AC1Ev({{.*}} @_ZGRN15BindToSubobject1cE_)
638 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN15BindToSubobject1AD1Ev, ptr @_ZGRN15BindToSubobject1cE_, ptr @__dso_handle)
639 // CHECK: call {{.*}} @_ZN15BindToSubobject1hE
640 // CHECK: getelementptr
641 // CHECK: store ptr {{.*}}, ptr @_ZN15BindToSubobject1cE, align 8
642 int &&c
= (f(), (g(), A().*h()));
649 // CHECK: call void @_ZN15BindToSubobject1BC1Ev({{.*}} @_ZGRN15BindToSubobject1dE_)
650 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN15BindToSubobject1BD1Ev, ptr @_ZGRN15BindToSubobject1dE_, ptr @__dso_handle)
651 // CHECK: call {{.*}} @_ZN15BindToSubobject1hE
652 // CHECK: getelementptr {{.*}} getelementptr
653 // CHECK: store ptr {{.*}}, ptr @_ZN15BindToSubobject1dE, align 8
654 int &&d
= (B().a
).*h();
658 struct S
{ int a
: 5; ~S(); };
660 // Do not lifetime extend the S() temporary here.
662 // CHECK: call {{.*}}memset
663 // CHECK: store i32 {{.*}}, ptr @_ZGRN8Bitfield1rE_
664 // CHECK: call void @_ZN8Bitfield1SD1
665 // CHECK: store ptr @_ZGRN8Bitfield1rE_, ptr @_ZN8Bitfield1rE, align 8
670 typedef __attribute__((vector_size(16))) int vi4a
;
671 typedef __attribute__((ext_vector_type(4))) int vi4b
;
677 // CHECK: extractelement
678 // CHECK: store i32 {{.*}}, ptr @_ZGRN6Vector1rE_
679 // CHECK: store ptr @_ZGRN6Vector1rE_, ptr @_ZN6Vector1rE,
683 // CHECK: extractelement
684 // CHECK: store i32 {{.*}}, ptr @_ZGRN6Vector1sE_
685 // CHECK: store ptr @_ZGRN6Vector1sE_, ptr @_ZN6Vector1sE,
687 // FIXME PR16204: The following code leads to an assertion in Sema.
691 namespace ImplicitTemporaryCleanup
{
692 struct A
{ A(int); ~A(); };
695 // CHECK-LABEL: define{{.*}} void @_ZN24ImplicitTemporaryCleanup1fEv(
697 // CHECK: call {{.*}} @_ZN24ImplicitTemporaryCleanup1AC1Ei(
700 // CHECK: call {{.*}} @_ZN24ImplicitTemporaryCleanup1gEv(
703 // CHECK: call {{.*}} @_ZN24ImplicitTemporaryCleanup1AD1Ev(
707 namespace MultipleExtension
{
708 struct A
{ A(); ~A(); };
709 struct B
{ B(); ~B(); };
710 struct C
{ C(); ~C(); };
711 struct D
{ D(); ~D(); int n
; C c
; };
712 struct E
{ const A
&a
; B b
; const C
&c
; ~E(); };
714 E
&&e1
= { A(), B(), D().c
};
716 // CHECK: call void @_ZN17MultipleExtension1AC1Ev({{.*}} @[[TEMPA:_ZGRN17MultipleExtension2e1E.*]])
717 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1AD1Ev, {{.*}} @[[TEMPA]]
718 // CHECK: store {{.*}} @[[TEMPA]], {{.*}} @[[TEMPE:_ZGRN17MultipleExtension2e1E.*]],
720 // CHECK: call void @_ZN17MultipleExtension1BC1Ev({{.*}} getelementptr inbounds ({{.*}} @[[TEMPE]], i32 0, i32 1))
722 // CHECK: call void @_ZN17MultipleExtension1DC1Ev({{.*}} @[[TEMPD:_ZGRN17MultipleExtension2e1E.*]])
723 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1DD1Ev, {{.*}} @[[TEMPD]]
724 // CHECK: store {{.*}} @[[TEMPD]], {{.*}} getelementptr inbounds ({{.*}} @[[TEMPE]], i32 0, i32 2)
725 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1ED1Ev, {{.*}} @[[TEMPE]]
726 // CHECK: store {{.*}} @[[TEMPE]], ptr @_ZN17MultipleExtension2e1E, align 8
728 E e2
= { A(), B(), D().c
};
730 // CHECK: call void @_ZN17MultipleExtension1AC1Ev({{.*}} @[[TEMPA:_ZGRN17MultipleExtension2e2E.*]])
731 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1AD1Ev, {{.*}} @[[TEMPA]]
732 // CHECK: store {{.*}} @[[TEMPA]], {{.*}} @[[E:_ZN17MultipleExtension2e2E]]
734 // CHECK: call void @_ZN17MultipleExtension1BC1Ev({{.*}} getelementptr inbounds ({{.*}} @[[E]], i32 0, i32 1))
736 // CHECK: call void @_ZN17MultipleExtension1DC1Ev({{.*}} @[[TEMPD:_ZGRN17MultipleExtension2e2E.*]])
737 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1DD1Ev, {{.*}} @[[TEMPD]]
738 // CHECK: store {{.*}} @[[TEMPD]], {{.*}} getelementptr inbounds ({{.*}} @[[E]], i32 0, i32 2)
739 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1ED1Ev, {{.*}} @[[E]]
743 // CHECK: define{{.*}} void @[[NS:_ZN17MultipleExtension]]1fEv(
745 E
&&e1
= { A(), B(), D().c
};
746 // CHECK: %[[TEMPE1_A:.*]] = getelementptr inbounds {{.*}} %[[TEMPE1:.*]], i32 0, i32 0
747 // CHECK: call void @[[NS]]1AC1Ev({{.*}} %[[TEMPA1:.*]])
748 // CHECK: store {{.*}} %[[TEMPA1]], {{.*}} %[[TEMPE1_A]]
749 // CHECK: %[[TEMPE1_B:.*]] = getelementptr inbounds {{.*}} %[[TEMPE1]], i32 0, i32 1
750 // CHECK: call void @[[NS]]1BC1Ev({{.*}} %[[TEMPE1_B]])
751 // CHECK: %[[TEMPE1_C:.*]] = getelementptr inbounds {{.*}} %[[TEMPE1]], i32 0, i32 2
752 // CHECK: call void @[[NS]]1DC1Ev({{.*}} %[[TEMPD1:.*]])
753 // CHECK: %[[TEMPD1_C:.*]] = getelementptr inbounds {{.*}} %[[TEMPD1]], i32 0, i32 1
754 // CHECK: store {{.*}} %[[TEMPD1_C]], {{.*}} %[[TEMPE1_C]]
755 // CHECK: store {{.*}} %[[TEMPE1]], {{.*}} %[[E1:.*]]
758 // CHECK: call void @[[NS]]1gEv()
760 E e2
= { A(), B(), D().c
};
761 // CHECK: %[[TEMPE2_A:.*]] = getelementptr inbounds {{.*}} %[[E2:.*]], i32 0, i32 0
762 // CHECK: call void @[[NS]]1AC1Ev({{.*}} %[[TEMPA2:.*]])
763 // CHECK: store {{.*}} %[[TEMPA2]], {{.*}} %[[TEMPE2_A]]
764 // CHECK: %[[TEMPE2_B:.*]] = getelementptr inbounds {{.*}} %[[E2]], i32 0, i32 1
765 // CHECK: call void @[[NS]]1BC1Ev({{.*}} %[[TEMPE2_B]])
766 // CHECK: %[[TEMPE2_C:.*]] = getelementptr inbounds {{.*}} %[[E2]], i32 0, i32 2
767 // CHECK: call void @[[NS]]1DC1Ev({{.*}} %[[TEMPD2:.*]])
768 // CHECK: %[[TEMPD2_C:.*]] = getelementptr inbounds {{.*}} %[[TEMPD2]], i32 0, i32 1
769 // CHECK: store {{.*}} %[[TEMPD2_C]], ptr %[[TEMPE2_C]]
772 // CHECK: call void @[[NS]]1gEv()
774 // CHECK: call void @[[NS]]1ED1Ev({{.*}} %[[E2]])
775 // CHECK: call void @[[NS]]1DD1Ev({{.*}} %[[TEMPD2]])
776 // CHECK: call void @[[NS]]1AD1Ev({{.*}} %[[TEMPA2]])
777 // CHECK: call void @[[NS]]1ED1Ev({{.*}} %[[TEMPE1]])
778 // CHECK: call void @[[NS]]1DD1Ev({{.*}} %[[TEMPD1]])
779 // CHECK: call void @[[NS]]1AD1Ev({{.*}} %[[TEMPA1]])
783 namespace ArrayAccess
{
784 struct A
{ A(int); ~A(); };
789 // CHECK: call void @_ZN11ArrayAccess1AC1Ei({{.*}}, i32 noundef 1
790 // CHECK-NOT: @_ZN11ArrayAccess1AD
791 // CHECK: call void @_ZN11ArrayAccess1AC1Ei({{.*}}, i32 noundef 2
792 // CHECK-NOT: @_ZN11ArrayAccess1AD
793 // CHECK: call void @_ZN11ArrayAccess1AC1Ei({{.*}}, i32 noundef 3
794 // CHECK-NOT: @_ZN11ArrayAccess1AD
795 A
&&a
= T
{1, 2, 3}[1];
797 // CHECK: call void @_ZN11ArrayAccess1AC1Ei({{.*}}, i32 noundef 4
798 // CHECK-NOT: @_ZN11ArrayAccess1AD
799 // CHECK: call void @_ZN11ArrayAccess1AC1Ei({{.*}}, i32 noundef 5
800 // CHECK-NOT: @_ZN11ArrayAccess1AD
801 // CHECK: call void @_ZN11ArrayAccess1AC1Ei({{.*}}, i32 noundef 6
802 // CHECK-NOT: @_ZN11ArrayAccess1AD
803 A
&&b
= 2[T
{4, 5, 6}];
805 // CHECK: call void @_ZN11ArrayAccess1gEv(
808 // CHECK: call void @_ZN11ArrayAccess1AD
809 // CHECK: call void @_ZN11ArrayAccess1AD
814 struct S
{ S(int); };
817 // CHECK: call void @_ZN7PR141301SC1Ei({{.*}} @_ZGRN7PR141301vE_, i32 noundef 0)
818 // CHECK: store {{.*}} @_ZGRN7PR141301vE_, {{.*}} @_ZN7PR141301vE
821 namespace Conditional
{
823 struct B
: A
{ B(); ~B(); };
824 struct C
: A
{ C(); ~C(); };
828 // CHECK-LABEL: define {{.*}} @_ZN11Conditional1fEb(
830 // CHECK: store i1 false, ptr %[[CLEANUP_B:.*]],
831 // CHECK: store i1 false, ptr %[[CLEANUP_C:.*]],
834 // CHECK: call {{.*}} @_ZN11Conditional1BC1Ev(
835 // CHECK: store i1 true, ptr %[[CLEANUP_B]],
838 // CHECK: call {{.*}} @_ZN11Conditional1CC1Ev(
839 // CHECK: store i1 true, ptr %[[CLEANUP_C]],
841 A
&&r
= b
? static_cast<A
&&>(B()) : static_cast<A
&&>(C());
843 // CHECK: call {{.*}} @_ZN11Conditional1gEv(
846 // CHECK: load {{.*}} %[[CLEANUP_C]]
848 // CHECK: call {{.*}} @_ZN11Conditional1CD1Ev(
851 // CHECK: load {{.*}} %[[CLEANUP_B]]
853 // CHECK: call {{.*}} @_ZN11Conditional1BD1Ev(
858 // CHECK-LABEL: define {{.*}} @_ZN11Conditional10f_indirectEb(
859 void f_indirect(bool b
) {
860 // CHECK: store i1 false, ptr %[[CLEANUP_B:.*]],
861 // CHECK: store i1 false, ptr %[[CLEANUP_C:.*]],
864 // CHECK: call {{.*}} @_ZN11Conditional1BC1Ev(
865 // CHECK: store i1 true, ptr %[[CLEANUP_B]],
868 // CHECK: call {{.*}} @_ZN11Conditional1CC1Ev(
869 // CHECK: store i1 true, ptr %[[CLEANUP_C]],
871 D d
= b
? D
{B()} : D
{C()};
873 // In C++17, the expression D{...} directly initializes the 'd' object, so
874 // lifetime-extending the temporaries to the lifetime of the D object
875 // extends them past the call to g().
877 // In C++14 and before, D is move-constructed from the result of the
878 // conditional expression, so no lifetime extension occurs.
880 // CHECK-CXX17: call {{.*}} @_ZN11Conditional1gEv(
882 // CHECK: load {{.*}} %[[CLEANUP_C]]
884 // CHECK: call {{.*}} @_ZN11Conditional1CD1Ev(
887 // CHECK: load {{.*}} %[[CLEANUP_B]]
889 // CHECK: call {{.*}} @_ZN11Conditional1BD1Ev(
892 // CHECK-CXX11: call {{.*}} @_ZN11Conditional1gEv(
897 // CHECK: load {{.*}} @_ZN11Conditional1b
900 // CHECK: call {{.*}} @_ZN11Conditional1BC1Ev({{.*}} @_ZGRN11Conditional1rE_)
901 // CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN11Conditional1BD1Ev, ptr @_ZGRN11Conditional1rE_,
904 // CHECK: call {{.*}} @_ZN11Conditional1CC1Ev({{.*}} @_ZGRN11Conditional1rE0_)
905 // CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN11Conditional1CD1Ev, ptr @_ZGRN11Conditional1rE0_,
907 A
&&r
= b
? static_cast<A
&&>(B()) : static_cast<A
&&>(C());
910 #if __cplusplus >= 201703L
912 struct X
{ X(); ~X(); };
916 // CHECK-CXX17-LABEL: define{{.*}} @_ZN7PR422201fEv(
918 // CHECK-CXX17: call{{.*}} @_ZN7PR422201XC1Ev(
920 // CHECK-CXX17-NOT: call{{.*}} @_ZN7PR422201XD1Ev(
921 // CHECK-CXX17: call{{.*}} @_ZN7PR422201gEv(
923 // CHECK-CXX17: call{{.*}} @_ZN7PR422201XD1Ev(