copy-constructor-elim.cpp revision d029cbbd18689a8110ea47aa33ed3387a7cf3674
1// RUN: %clang_cc1 -emit-llvm -o %t %s
2// RUN: not grep "_ZN1CC1ERK1C" %t
3// RUN: not grep "_ZN1SC1ERK1S" %t
4
5extern "C" int printf(...);
6
7
8struct C {
9  C() : iC(6) {printf("C()\n"); }
10  C(const C& c) { printf("C(const C& c)\n"); }
11  int iC;
12};
13
14C foo() {
15  return C();
16};
17
18class X { // ...
19public:
20  X(int) {}
21  X(const X&, int i = 1, int j = 2, C c = foo()) {
22    printf("X(const X&, %d, %d, %d)\n", i, j, c.iC);
23  }
24};
25
26
27struct S {
28  S();
29};
30
31S::S() { printf("S()\n"); }
32
33void Call(S) {};
34
35int main() {
36  X a(1);
37  X b(a, 2);
38  X c = b;
39  X d(a, 5, 6);
40  S s;
41  Call(s);
42}
43