1// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
2
3// CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00"
4// CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00"
5
6// CHECK: private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
7// CHECK: private unnamed_addr constant [60 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction()\00"
8// CHECK: private unnamed_addr constant [53 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction()\00"
9
10// CHECK: private unnamed_addr constant [18 x i8] c"functionTemplate1\00"
11// CHECK: private unnamed_addr constant [45 x i8] c"void NS::Base::functionTemplate1(NS::Base *)\00"
12// CHECK: private unnamed_addr constant [38 x i8] c"void NS::Base::functionTemplate1(int)\00"
13
14// CHECK: private unnamed_addr constant [23 x i8] c"anonymousUnionFunction\00"
15// CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous union>::anonymousUnionFunction()\00"
16
17// CHECK: private unnamed_addr constant [24 x i8] c"anonymousStructFunction\00"
18// CHECK: private unnamed_addr constant [85 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous struct>::anonymousStructFunction()\00"
19
20// CHECK: private unnamed_addr constant [23 x i8] c"anonymousClassFunction\00"
21// CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous class>::anonymousClassFunction()\00"
22
23// CHECK: private unnamed_addr constant [12 x i8] c"~Destructor\00"
24// CHECK: private unnamed_addr constant [30 x i8] c"NS::Destructor::~Destructor()\00"
25
26// CHECK: private unnamed_addr constant [12 x i8] c"Constructor\00"
27// CHECK: private unnamed_addr constant [41 x i8] c"NS::Constructor::Constructor(NS::Base *)\00"
28// CHECK: private unnamed_addr constant [34 x i8] c"NS::Constructor::Constructor(int)\00"
29// CHECK: private unnamed_addr constant [31 x i8] c"NS::Constructor::Constructor()\00"
30
31// CHECK: private unnamed_addr constant [16 x i8] c"virtualFunction\00"
32// CHECK: private unnamed_addr constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00"
33
34// CHECK: private unnamed_addr constant [22 x i8] c"constVolatileFunction\00"
35// CHECK: private unnamed_addr constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00"
36
37// CHECK: private unnamed_addr constant [17 x i8] c"volatileFunction\00"
38// CHECK: private unnamed_addr constant [43 x i8] c"void NS::Base::volatileFunction() volatile\00"
39
40// CHECK: private unnamed_addr constant [14 x i8] c"constFunction\00"
41// CHECK: private unnamed_addr constant [37 x i8] c"void NS::Base::constFunction() const\00"
42
43// CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate2\00"
44// CHECK: private unnamed_addr constant [64 x i8] c"ClassTemplate<NS::Base *> NS::Base::functionReturingTemplate2()\00"
45
46// CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate1\00"
47// CHECK: private unnamed_addr constant [57 x i8] c"ClassTemplate<int> NS::Base::functionReturingTemplate1()\00"
48
49// CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter2\00"
50// CHECK: private unnamed_addr constant [65 x i8] c"void NS::Base::withTemplateParameter2(ClassTemplate<NS::Base *>)\00"
51
52// CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter1\00"
53// CHECK: private unnamed_addr constant [58 x i8] c"void NS::Base::withTemplateParameter1(ClassTemplate<int>)\00"
54
55// CHECK: private unnamed_addr constant [23 x i8] c"functionReturningClass\00"
56// CHECK: private unnamed_addr constant [45 x i8] c"NS::Base *NS::Base::functionReturningClass()\00"
57
58// CHECK: private unnamed_addr constant [23 x i8] c"functionWithParameters\00"
59// CHECK: private unnamed_addr constant [64 x i8] c"void NS::Base::functionWithParameters(int, float *, NS::Base *)\00"
60
61// CHECK: private unnamed_addr constant [17 x i8] c"variadicFunction\00"
62// CHECK: private unnamed_addr constant [42 x i8] c"void NS::Base::variadicFunction(int, ...)\00"
63
64// CHECK: private unnamed_addr constant [41 x i8] c"virtual void NS::Base::virtualFunction()\00"
65
66// CHECK: private unnamed_addr constant [15 x i8] c"inlineFunction\00"
67// CHECK: private unnamed_addr constant [32 x i8] c"void NS::Base::inlineFunction()\00"
68
69// CHECK: private unnamed_addr constant [15 x i8] c"staticFunction\00"
70// CHECK: private unnamed_addr constant [39 x i8] c"static void NS::Base::staticFunction()\00"
71
72// CHECK: private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00"
73// CHECK: private unnamed_addr constant [59 x i8] c"void ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
74
75// CHECK: private unnamed_addr constant [27 x i8] c"anonymousNamespaceFunction\00"
76// CHECK: private unnamed_addr constant [84 x i8] c"void <anonymous namespace>::ClassInAnonymousNamespace::anonymousNamespaceFunction()\00"
77
78// CHECK: private unnamed_addr constant [19 x i8] c"localClassFunction\00"
79// CHECK: private unnamed_addr constant [59 x i8] c"void NS::localClass(int)::LocalClass::localClassFunction()\00"
80
81int printf(const char * _Format, ...);
82
83class ClassInTopLevelNamespace {
84public:
85  void topLevelNamespaceFunction() {
86    printf("__func__ %s\n", __func__);
87    printf("__FUNCTION__ %s\n", __FUNCTION__);
88    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
89  }
90};
91
92namespace {
93
94  class ClassInAnonymousNamespace {
95  public:
96    void anonymousNamespaceFunction() {
97      printf("__func__ %s\n", __func__);
98      printf("__FUNCTION__ %s\n", __FUNCTION__);
99      printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
100    }
101  };
102
103} // end anonymous namespace
104
105namespace NS {
106
107template<typename T>
108class ClassTemplate {
109public:
110  void classTemplateFunction() {
111    printf("__func__ %s\n", __func__);
112    printf("__FUNCTION__ %s\n", __FUNCTION__);
113    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
114  }
115};
116
117class Base {
118public:
119  static void staticFunction() {
120    printf("__func__ %s\n", __func__);
121    printf("__FUNCTION__ %s\n", __FUNCTION__);
122    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
123  }
124
125  inline void inlineFunction() {
126    printf("__func__ %s\n", __func__);
127    printf("__FUNCTION__ %s\n", __FUNCTION__);
128    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
129  }
130
131  virtual void virtualFunction() {
132    printf("__func__ %s\n", __func__);
133    printf("__FUNCTION__ %s\n", __FUNCTION__);
134    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
135  }
136
137  void functionWithParameters(int, float*, Base* base) {
138    printf("__func__ %s\n", __func__);
139    printf("__FUNCTION__ %s\n", __FUNCTION__);
140    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
141  }
142
143  Base *functionReturningClass() {
144    printf("__func__ %s\n", __func__);
145    printf("__FUNCTION__ %s\n", __FUNCTION__);
146    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
147    return 0;
148  }
149
150  void variadicFunction(int, ...) {
151    printf("__func__ %s\n", __func__);
152    printf("__FUNCTION__ %s\n", __FUNCTION__);
153    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
154  }
155
156  void withTemplateParameter1(ClassTemplate<int>) {
157    printf("__func__ %s\n", __func__);
158    printf("__FUNCTION__ %s\n", __FUNCTION__);
159    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
160  }
161
162  void withTemplateParameter2(ClassTemplate<Base *>) {
163    printf("__func__ %s\n", __func__);
164    printf("__FUNCTION__ %s\n", __FUNCTION__);
165    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
166  }
167
168  ClassTemplate<int> functionReturingTemplate1() {
169    printf("__func__ %s\n", __func__);
170    printf("__FUNCTION__ %s\n", __FUNCTION__);
171    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
172    return ClassTemplate<int>();
173  }
174
175  ClassTemplate<Base *> functionReturingTemplate2() {
176    printf("__func__ %s\n", __func__);
177    printf("__FUNCTION__ %s\n", __FUNCTION__);
178    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
179    return ClassTemplate<Base *>();
180  }
181
182  template<typename T>
183  void functionTemplate1(T t) {
184    printf("__func__ %s\n", __func__);
185    printf("__FUNCTION__ %s\n", __FUNCTION__);
186    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
187  }
188
189  void constFunction() const {
190    printf("__func__ %s\n", __func__);
191    printf("__FUNCTION__ %s\n", __FUNCTION__);
192    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
193  }
194
195  void volatileFunction() volatile {
196    printf("__func__ %s\n", __func__);
197    printf("__FUNCTION__ %s\n", __FUNCTION__);
198    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
199  }
200
201  void constVolatileFunction() const volatile {
202    printf("__func__ %s\n", __func__);
203    printf("__FUNCTION__ %s\n", __FUNCTION__);
204    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
205  }
206};
207
208class Derived : public Base {
209public:
210  // Virtual function without being explicitally written.
211  void virtualFunction() {
212    printf("__func__ %s\n", __func__);
213    printf("__FUNCTION__ %s\n", __FUNCTION__);
214    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
215  }
216};
217
218class Constructor {
219public:
220  Constructor() {
221    printf("__func__ %s\n", __func__);
222    printf("__FUNCTION__ %s\n", __FUNCTION__);
223    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
224  }
225
226  Constructor(int) {
227    printf("__func__ %s\n", __func__);
228    printf("__FUNCTION__ %s\n", __FUNCTION__);
229    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
230  }
231
232  Constructor(Base *) {
233    printf("__func__ %s\n", __func__);
234    printf("__FUNCTION__ %s\n", __FUNCTION__);
235    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
236  }
237};
238
239class Destructor {
240public:
241  ~Destructor() {
242    printf("__func__ %s\n", __func__);
243    printf("__FUNCTION__ %s\n", __FUNCTION__);
244    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
245  }
246};
247
248class ContainerForAnonymousRecords {
249public:
250  class {
251  public:
252    void anonymousClassFunction() {
253      printf("__func__ %s\n", __func__);
254      printf("__FUNCTION__ %s\n", __FUNCTION__);
255      printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
256    }
257  } anonymousClass;
258
259  struct {
260    void anonymousStructFunction() {
261      printf("__func__ %s\n", __func__);
262      printf("__FUNCTION__ %s\n", __FUNCTION__);
263      printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
264    }
265  } anonymousStruct;
266
267  union {
268    void anonymousUnionFunction() {
269      printf("__func__ %s\n", __func__);
270      printf("__FUNCTION__ %s\n", __FUNCTION__);
271      printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
272    }
273  } anonymousUnion;
274};
275
276void localClass(int) {
277  class LocalClass {
278  public:
279    void localClassFunction() {
280      printf("__func__ %s\n", __func__);
281      printf("__FUNCTION__ %s\n", __FUNCTION__);
282      printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
283    }
284  };
285  LocalClass lc;
286  lc.localClassFunction();
287}
288
289extern void externFunction() {
290  printf("__func__ %s\n", __func__);
291  printf("__FUNCTION__ %s\n", __FUNCTION__);
292  printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
293}
294
295} // end NS namespace
296
297int main() {
298  ClassInAnonymousNamespace anonymousNamespace;
299  anonymousNamespace.anonymousNamespaceFunction();
300
301  ClassInTopLevelNamespace topLevelNamespace;
302  topLevelNamespace.topLevelNamespaceFunction();
303
304  NS::Base::staticFunction();
305
306  NS::Base b;
307  b.inlineFunction();
308  b.virtualFunction();
309  b.variadicFunction(0);
310  b.functionWithParameters(0, 0, 0);
311  b.functionReturningClass();
312
313  b.withTemplateParameter1(NS::ClassTemplate<int>());
314  b.withTemplateParameter2(NS::ClassTemplate<NS::Base *>());
315  b.functionReturingTemplate1();
316  b.functionReturingTemplate2();
317  b.functionTemplate1<int>(0);
318  b.functionTemplate1<NS::Base *>(0);
319  b.constFunction();
320  b.volatileFunction();
321  b.constVolatileFunction();
322
323  NS::Derived d;
324  d.virtualFunction();
325
326  NS::ClassTemplate<int> t1;
327  t1.classTemplateFunction();
328  NS::ClassTemplate<NS::Base *> t2;
329  t2.classTemplateFunction();
330
331  NS::Constructor c1;
332  NS::Constructor c2(0);
333  NS::Constructor c3((NS::Base *)0);
334
335  {
336    NS::Destructor destructor;
337  }
338
339  NS::ContainerForAnonymousRecords anonymous;
340  anonymous.anonymousClass.anonymousClassFunction();
341  anonymous.anonymousStruct.anonymousStructFunction();
342  anonymous.anonymousUnion.anonymousUnionFunction();
343
344  NS::localClass(0);
345
346  NS::externFunction();
347
348  return 0;
349}
350