1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++98 -triple i386-unknown-unknown -fno-elide-constructors -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CXX98
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown -fno-elide-constructors -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CXX11
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++98 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CXX98-ELIDE
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CXX11-ELIDE
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc // Reduced from PR12208
7*0a6a1f1dSLionel Sambuc class X {
8*0a6a1f1dSLionel Sambuc public:
9*0a6a1f1dSLionel Sambuc X();
10*0a6a1f1dSLionel Sambuc X(const X&);
11*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L
12*0a6a1f1dSLionel Sambuc X(X&&);
13*0a6a1f1dSLionel Sambuc #endif
14*0a6a1f1dSLionel Sambuc ~X();
15*0a6a1f1dSLionel Sambuc };
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @_Z4Testv(
Test()18*0a6a1f1dSLionel Sambuc X Test()
19*0a6a1f1dSLionel Sambuc {
20*0a6a1f1dSLionel Sambuc X x;
21*0a6a1f1dSLionel Sambuc
22*0a6a1f1dSLionel Sambuc // Check that the copy constructor for X is called with result variable as
23*0a6a1f1dSLionel Sambuc // sret argument.
24*0a6a1f1dSLionel Sambuc // CHECK-CXX98: call void @_ZN1XC1ERKS_(
25*0a6a1f1dSLionel Sambuc // CHECK-CXX11: call void @_ZN1XC1EOS_(
26*0a6a1f1dSLionel Sambuc // CHECK-CXX98-ELIDE-NOT: call void @_ZN1XC1ERKS_(
27*0a6a1f1dSLionel Sambuc // CHECK-CXX11-ELIDE-NOT: call void @_ZN1XC1EOS_(
28*0a6a1f1dSLionel Sambuc
29*0a6a1f1dSLionel Sambuc // Make sure that the destructor for X is called.
30*0a6a1f1dSLionel Sambuc // FIXME: This call is present even in the -ELIDE runs, but is guarded by a
31*0a6a1f1dSLionel Sambuc // branch that is never taken in those cases. We could generate better IR
32*0a6a1f1dSLionel Sambuc // here.
33*0a6a1f1dSLionel Sambuc // CHECK: call void @_ZN1XD1Ev(
34*0a6a1f1dSLionel Sambuc return x;
35*0a6a1f1dSLionel Sambuc }
36