xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/member-functions.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin9 -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct C {
4*f4a2713aSLionel Sambuc   void f();
5*f4a2713aSLionel Sambuc   void g(int, ...);
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1C1fEv
f()9*f4a2713aSLionel Sambuc void C::f() {
10*f4a2713aSLionel Sambuc }
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z5test1v
test1()13*f4a2713aSLionel Sambuc void test1() {
14*f4a2713aSLionel Sambuc   C c;
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc   // CHECK: call void @_ZN1C1fEv
17*f4a2713aSLionel Sambuc   c.f();
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc   // CHECK: call void (%struct.C*, i32, ...)* @_ZN1C1gEiz
20*f4a2713aSLionel Sambuc   c.g(1, 2, 3);
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc struct S {
SS25*f4a2713aSLionel Sambuc   inline S() { }
~SS26*f4a2713aSLionel Sambuc   inline ~S() { }
27*f4a2713aSLionel Sambuc 
f_inline1S28*f4a2713aSLionel Sambuc   void f_inline1() { }
f_inline2S29*f4a2713aSLionel Sambuc   inline void f_inline2() { }
30*f4a2713aSLionel Sambuc 
gS31*f4a2713aSLionel Sambuc   static void g() { }
32*f4a2713aSLionel Sambuc   static void f();
33*f4a2713aSLionel Sambuc 
vS34*f4a2713aSLionel Sambuc   virtual void v() {}
35*f4a2713aSLionel Sambuc };
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1S1fEv
f()38*f4a2713aSLionel Sambuc void S::f() {
39*f4a2713aSLionel Sambuc }
40*f4a2713aSLionel Sambuc 
test2()41*f4a2713aSLionel Sambuc void test2() {
42*f4a2713aSLionel Sambuc   S s;
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc   s.f_inline1();
45*f4a2713aSLionel Sambuc   s.f_inline2();
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc   S::g();
48*f4a2713aSLionel Sambuc }
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc // S::S()
51*f4a2713aSLionel Sambuc // CHECK: define linkonce_odr void @_ZN1SC1Ev{{.*}} unnamed_addr
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc // S::f_inline1()
54*f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN1S9f_inline1Ev
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc // S::f_inline2()
57*f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN1S9f_inline2Ev
58*f4a2713aSLionel Sambuc 
59*f4a2713aSLionel Sambuc // S::g()
60*f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN1S1gEv
61*f4a2713aSLionel Sambuc 
62*f4a2713aSLionel Sambuc // S::~S()
63*f4a2713aSLionel Sambuc // CHECK: define linkonce_odr void @_ZN1SD1Ev{{.*}} unnamed_addr
64*f4a2713aSLionel Sambuc 
65*f4a2713aSLionel Sambuc struct T {
66*f4a2713aSLionel Sambuc   T operator+(const T&);
67*f4a2713aSLionel Sambuc };
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z5test3v
test3()70*f4a2713aSLionel Sambuc void test3() {
71*f4a2713aSLionel Sambuc   T t1, t2;
72*f4a2713aSLionel Sambuc 
73*f4a2713aSLionel Sambuc   // CHECK: call void @_ZN1TplERKS_
74*f4a2713aSLionel Sambuc   T result = t1 + t2;
75*f4a2713aSLionel Sambuc }
76*f4a2713aSLionel Sambuc 
77*f4a2713aSLionel Sambuc // S::~S()
78*f4a2713aSLionel Sambuc // CHECK: define linkonce_odr void @_ZN1SD2Ev{{.*}} unnamed_addr
79*f4a2713aSLionel Sambuc 
80*f4a2713aSLionel Sambuc // S::S()
81*f4a2713aSLionel Sambuc // CHECK: define linkonce_odr void @_ZN1SC2Ev{{.*}} unnamed_addr
82*f4a2713aSLionel Sambuc 
83*f4a2713aSLionel Sambuc // S::v()
84*f4a2713aSLionel Sambuc // CHECK: define linkonce_odr void @_ZN1S1vEv{{.*}}unnamed_addr
85*f4a2713aSLionel Sambuc 
86