1 // RUN: %clang_cc1 %std_cxx11-14 -no-enable-noundef-analysis -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,PRE17
2 // RUN: %clang_cc1 %std_cxx17- -no-enable-noundef-analysis -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CXX17
4 struct A
{ int x
; A(int); ~A(); };
6 // CHECK-LABEL: define{{.*}} void @_Z1fv
7 // CHECK: call {{.*}} @_ZN1AC1Ei
8 // CHECK-NEXT: ret void
10 // Verify that we do not elide copies when constructing a base class before C++17.
11 namespace no_elide_base
{
18 operator Base() const;
21 struct Derived
: public virtual Base
{
22 Derived(const Other
&O
);
25 // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(ptr {{[^,]*}} returned {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %O) unnamed_addr
26 Derived::Derived(const Other
&O
)
27 // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv
28 // PRE17: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_
29 // PRE17: call {{.*}} @_ZN13no_elide_base4BaseD1Ev
44 A
& operator=(const A
&);
52 // Verify that we don't mark the copy constructor in this expression as elidable.
53 // CHECK: call {{.*}} @_ZN6PR86831AC1ERKS0_
62 A(A
const &, int value
= 2) : value(value
) { }
65 static A
makeA() { A a
; a
.value
= 2; return a
; }
68 // CHECK-LABEL: define{{.*}} i32 @_ZN7PR121394testEv
70 // CHECK: call void @_ZN7PR121391A5makeAEv
71 // CHECK-NEXT: call ptr @_ZN7PR121391AC1ERKS0_i
73 // CHECK-NEXT: getelementptr inbounds
75 // CHECK-NEXT: ret i32
80 namespace ElidableCallIsNotCopyCtor
{
81 struct A
{ A(const A
&); };
88 // Before C++17, we construct via B(int) then B(A). The B(A) construction is
89 // elidable, but we don't have an AST representation for the case where we
90 // must elide not only a constructor call but also some argument
91 // conversions, so we don't elide it.
92 // CHECK-LABEL: define{{.*}} void @_ZN25ElidableCallIsNotCopyCtor1fEv(
93 // CHECK: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1BC1Ei(
94 // PRE17: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1AC1ERKS0_(
95 // PRE17: call {{.*}} @_ZN25ElidableCallIsNotCopyCtor1BC1ENS_1AE(