summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/temp-1.cpp
blob: 9b97f0083c83db87a3bfb4d0a301b8d5cb2ca1b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// RUN: clang-cc -emit-llvm %s -o %t -triple=x86_64-apple-darwin9 && 
struct A {
  A();
  ~A();
  void f();
};

// RUN: grep "call void @_ZN1AC1Ev" %t | count 2 &&
// RUN: grep "call void @_ZN1AD1Ev" %t | count 2 &&
void f1() {
  (void)A();
  A().f();
}

// Function calls
struct B {
  B();
  ~B();
};

B g();

// RUN: grep "call void @_ZN1BC1Ev" %t | count 0 &&
// RUN: grep "call void @_ZN1BD1Ev" %t | count 1 &&
void f2() {
  (void)g();
}

// Member function calls
struct C {
  C();
  ~C();
  
  C f();
};

// RUN: grep "call void @_ZN1CC1Ev" %t | count 1 &&
// RUN: grep "call void @_ZN1CD1Ev" %t | count 2 &&
void f3() {
  C().f();
}

// Function call operator
struct D {
  D();
  ~D();
  
  D operator()();
};

// RUN: grep "call void @_ZN1DC1Ev" %t | count 1 &&
// RUN: grep "call void @_ZN1DD1Ev" %t | count 2 &&
void f4() {
  D()();
}

// Overloaded operators
struct E {
  E();
  ~E();
  E operator+(const E&);
  E operator!();
};

// RUN: grep "call void @_ZN1EC1Ev" %t | count 3 &&
// RUN: grep "call void @_ZN1ED1Ev" %t | count 5 &&
void f5() {
  E() + E();
  !E();
}

struct F {
  F();
  ~F();
  F& f();
};

// RUN: grep "call void @_ZN1FC1Ev" %t | count 1 &&
// RUN: grep "call void @_ZN1FD1Ev" %t | count 1 
void f6() {
  F().f();
}

OpenPOWER on IntegriCloud