blob: ecb350f43ec95eec70279a41637ae1f11f022153 [file] [log] [blame]
Richard Smith454b4af2014-01-11 01:24:05 +00001// 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// 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// 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// 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
6// Reduced from PR12208
7class X {
8public:
9 X();
10 X(const X&);
11#if __cplusplus >= 201103L
12 X(X&&);
13#endif
14 ~X();
15};
16
17// CHECK-LABEL: define void @_Z4Testv(
18X Test()
19{
20 X x;
21
22 // Check that the copy constructor for X is called with result variable as
23 // sret argument.
24 // CHECK-CXX98: call void @_ZN1XC1ERKS_(
25 // CHECK-CXX11: call void @_ZN1XC1EOS_(
26 // CHECK-CXX98-ELIDE-NOT: call void @_ZN1XC1ERKS_(
27 // CHECK-CXX11-ELIDE-NOT: call void @_ZN1XC1EOS_(
28
29 // Make sure that the destructor for X is called.
30 // FIXME: This call is present even in the -ELIDE runs, but is guarded by a
31 // branch that is never taken in those cases. We could generate better IR
32 // here.
33 // CHECK: call void @_ZN1XD1Ev(
34 return x;
35}