1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -fblocks %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00"
4f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00"
5f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [49 x i8] c"void functionTemplateExplicitSpecialization(int)\00"
6f4a2713aSLionel Sambuc
7f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [95 x i8] c"void SpecializedClassTemplate<char>::memberFunctionTemplate(T, U) const [T = char, U = double]\00"
8f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [85 x i8] c"void SpecializedClassTemplate<int>::memberFunctionTemplate(int, U) const [U = float]\00"
9f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [57 x i8] c"void NonTypeTemplateParam<42>::size() const [Count = 42]\00"
10f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [122 x i8] c"static void ClassWithTemplateTemplateParam<char, NS::ClassTemplate>::staticMember() [T = char, Param = NS::ClassTemplate]\00"
11f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [106 x i8] c"void OuterClass<int *>::MiddleClass::InnerClass<float>::memberFunction(T, U) const [T = int *, U = float]\00"
12f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [51 x i8] c"void functionTemplateWithCapturedStmt(T) [T = int]\00"
13*0a6a1f1dSLionel Sambuc // CHECK: private unnamed_addr constant [76 x i8] c"auto functionTemplateWithLambda(int)::(anonymous class)::operator()() const\00"
14f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [65 x i8] c"void functionTemplateWithUnnamedTemplateParameter(T) [T = float]\00"
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [60 x i8] c"void functionTemplateExplicitSpecialization(T) [T = double]\00"
17f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [52 x i8] c"T *functionTemplateWithCompoundTypes(T *) [T = int]\00"
18f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [54 x i8] c"T functionTemplateWithTemplateReturnType() [T = char]\00"
19f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [57 x i8] c"void functionTemplateWithoutParameterList() [T = double]\00"
20f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [62 x i8] c"void functionTemplateWithTwoParams(T, U) [T = int, U = float]\00"
21f4a2713aSLionel Sambuc
22f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
23f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [77 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction() [T = NS::Base *]\00"
24f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [63 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction() [T = int]\00"
25f4a2713aSLionel Sambuc
26f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [18 x i8] c"functionTemplate1\00"
27f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [53 x i8] c"void NS::Base::functionTemplate1(T) [T = NS::Base *]\00"
28f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [46 x i8] c"void NS::Base::functionTemplate1(T) [T = int]\00"
29f4a2713aSLionel Sambuc
30f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [23 x i8] c"anonymousUnionFunction\00"
31*0a6a1f1dSLionel Sambuc // CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::(anonymous union)::anonymousUnionFunction()\00"
32f4a2713aSLionel Sambuc
33f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [24 x i8] c"anonymousStructFunction\00"
34*0a6a1f1dSLionel Sambuc // CHECK: private unnamed_addr constant [85 x i8] c"void NS::ContainerForAnonymousRecords::(anonymous struct)::anonymousStructFunction()\00"
35f4a2713aSLionel Sambuc
36f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [23 x i8] c"anonymousClassFunction\00"
37*0a6a1f1dSLionel Sambuc // CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::(anonymous class)::anonymousClassFunction()\00"
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [12 x i8] c"~Destructor\00"
40f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [30 x i8] c"NS::Destructor::~Destructor()\00"
41f4a2713aSLionel Sambuc
42f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [12 x i8] c"Constructor\00"
43f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [41 x i8] c"NS::Constructor::Constructor(NS::Base *)\00"
44f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [34 x i8] c"NS::Constructor::Constructor(int)\00"
45f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [31 x i8] c"NS::Constructor::Constructor()\00"
46f4a2713aSLionel Sambuc
47f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [16 x i8] c"virtualFunction\00"
48f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00"
49f4a2713aSLionel Sambuc
50f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [21 x i8] c"refQualifiedFunction\00"
51f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [41 x i8] c"void NS::Base::refQualifiedFunction() &&\00"
52f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [40 x i8] c"void NS::Base::refQualifiedFunction() &\00"
53f4a2713aSLionel Sambuc
54f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [22 x i8] c"constVolatileFunction\00"
55f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00"
56f4a2713aSLionel Sambuc
57f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [17 x i8] c"volatileFunction\00"
58f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [43 x i8] c"void NS::Base::volatileFunction() volatile\00"
59f4a2713aSLionel Sambuc
60f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [14 x i8] c"constFunction\00"
61f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [37 x i8] c"void NS::Base::constFunction() const\00"
62f4a2713aSLionel Sambuc
63f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate2\00"
64f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [64 x i8] c"ClassTemplate<NS::Base *> NS::Base::functionReturingTemplate2()\00"
65f4a2713aSLionel Sambuc
66f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate1\00"
67f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [57 x i8] c"ClassTemplate<int> NS::Base::functionReturingTemplate1()\00"
68f4a2713aSLionel Sambuc
69f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter2\00"
70f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [65 x i8] c"void NS::Base::withTemplateParameter2(ClassTemplate<NS::Base *>)\00"
71f4a2713aSLionel Sambuc
72f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter1\00"
73f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [58 x i8] c"void NS::Base::withTemplateParameter1(ClassTemplate<int>)\00"
74f4a2713aSLionel Sambuc
75f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [23 x i8] c"functionReturningClass\00"
76f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [45 x i8] c"NS::Base *NS::Base::functionReturningClass()\00"
77f4a2713aSLionel Sambuc
78f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [23 x i8] c"functionWithParameters\00"
79f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [64 x i8] c"void NS::Base::functionWithParameters(int, float *, NS::Base *)\00"
80f4a2713aSLionel Sambuc
81f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [17 x i8] c"variadicFunction\00"
82f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [42 x i8] c"void NS::Base::variadicFunction(int, ...)\00"
83f4a2713aSLionel Sambuc
84f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [41 x i8] c"virtual void NS::Base::virtualFunction()\00"
85f4a2713aSLionel Sambuc
86f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [15 x i8] c"inlineFunction\00"
87f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [32 x i8] c"void NS::Base::inlineFunction()\00"
88f4a2713aSLionel Sambuc
89f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [15 x i8] c"staticFunction\00"
90f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [39 x i8] c"static void NS::Base::staticFunction()\00"
91f4a2713aSLionel Sambuc
92f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00"
93f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [59 x i8] c"void ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
94f4a2713aSLionel Sambuc
95f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [27 x i8] c"anonymousNamespaceFunction\00"
96*0a6a1f1dSLionel Sambuc // CHECK: private unnamed_addr constant [84 x i8] c"void (anonymous namespace)::ClassInAnonymousNamespace::anonymousNamespaceFunction()\00"
97f4a2713aSLionel Sambuc
98f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [19 x i8] c"localClassFunction\00"
99f4a2713aSLionel Sambuc // CHECK: private unnamed_addr constant [59 x i8] c"void NS::localClass(int)::LocalClass::localClassFunction()\00"
100f4a2713aSLionel Sambuc
101f4a2713aSLionel Sambuc
102f4a2713aSLionel Sambuc
103f4a2713aSLionel Sambuc int printf(const char * _Format, ...);
104f4a2713aSLionel Sambuc
105f4a2713aSLionel Sambuc class ClassInTopLevelNamespace {
106f4a2713aSLionel Sambuc public:
topLevelNamespaceFunction()107f4a2713aSLionel Sambuc void topLevelNamespaceFunction() {
108f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
109f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
110f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
111f4a2713aSLionel Sambuc }
112f4a2713aSLionel Sambuc };
113f4a2713aSLionel Sambuc
114f4a2713aSLionel Sambuc namespace {
115f4a2713aSLionel Sambuc
116f4a2713aSLionel Sambuc class ClassInAnonymousNamespace {
117f4a2713aSLionel Sambuc public:
anonymousNamespaceFunction()118f4a2713aSLionel Sambuc void anonymousNamespaceFunction() {
119f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
120f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
121f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
122f4a2713aSLionel Sambuc }
123f4a2713aSLionel Sambuc };
124f4a2713aSLionel Sambuc
125f4a2713aSLionel Sambuc } // end anonymous namespace
126f4a2713aSLionel Sambuc
127f4a2713aSLionel Sambuc namespace NS {
128f4a2713aSLionel Sambuc
129f4a2713aSLionel Sambuc template<typename T>
130f4a2713aSLionel Sambuc class ClassTemplate {
131f4a2713aSLionel Sambuc public:
classTemplateFunction()132f4a2713aSLionel Sambuc void classTemplateFunction() {
133f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
134f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
135f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
136f4a2713aSLionel Sambuc }
137f4a2713aSLionel Sambuc };
138f4a2713aSLionel Sambuc
139f4a2713aSLionel Sambuc class Base {
140f4a2713aSLionel Sambuc public:
staticFunction()141f4a2713aSLionel Sambuc static void staticFunction() {
142f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
143f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
144f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
145f4a2713aSLionel Sambuc }
146f4a2713aSLionel Sambuc
147f4a2713aSLionel Sambuc inline void (inlineFunction)() {
148f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
149f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
150f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
151f4a2713aSLionel Sambuc }
152f4a2713aSLionel Sambuc
virtualFunction()153f4a2713aSLionel Sambuc virtual void virtualFunction() {
154f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
155f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
156f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
157f4a2713aSLionel Sambuc }
158f4a2713aSLionel Sambuc
functionWithParameters(int,float *,Base * base)159f4a2713aSLionel Sambuc void functionWithParameters(int, float*, Base* base) {
160f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
161f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
162f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
163f4a2713aSLionel Sambuc }
164f4a2713aSLionel Sambuc
functionReturningClass()165f4a2713aSLionel Sambuc Base *functionReturningClass() {
166f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
167f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
168f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
169f4a2713aSLionel Sambuc return 0;
170f4a2713aSLionel Sambuc }
171f4a2713aSLionel Sambuc
variadicFunction(int,...)172f4a2713aSLionel Sambuc void variadicFunction(int, ...) {
173f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
174f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
175f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
176f4a2713aSLionel Sambuc }
177f4a2713aSLionel Sambuc
withTemplateParameter1(ClassTemplate<int>)178f4a2713aSLionel Sambuc void withTemplateParameter1(ClassTemplate<int>) {
179f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
180f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
181f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
182f4a2713aSLionel Sambuc }
183f4a2713aSLionel Sambuc
withTemplateParameter2(ClassTemplate<Base * >)184f4a2713aSLionel Sambuc void withTemplateParameter2(ClassTemplate<Base *>) {
185f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
186f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
187f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
188f4a2713aSLionel Sambuc }
189f4a2713aSLionel Sambuc
functionReturingTemplate1()190f4a2713aSLionel Sambuc ClassTemplate<int> functionReturingTemplate1() {
191f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
192f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
193f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
194f4a2713aSLionel Sambuc return ClassTemplate<int>();
195f4a2713aSLionel Sambuc }
196f4a2713aSLionel Sambuc
functionReturingTemplate2()197f4a2713aSLionel Sambuc ClassTemplate<Base *> functionReturingTemplate2() {
198f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
199f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
200f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
201f4a2713aSLionel Sambuc return ClassTemplate<Base *>();
202f4a2713aSLionel Sambuc }
203f4a2713aSLionel Sambuc
204f4a2713aSLionel Sambuc template<typename T>
functionTemplate1(T t)205f4a2713aSLionel Sambuc void functionTemplate1(T t) {
206f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
207f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
208f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
209f4a2713aSLionel Sambuc }
210f4a2713aSLionel Sambuc
constFunction() const211f4a2713aSLionel Sambuc void constFunction() const {
212f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
213f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
214f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
215f4a2713aSLionel Sambuc }
216f4a2713aSLionel Sambuc
volatileFunction()217f4a2713aSLionel Sambuc void volatileFunction() volatile {
218f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
219f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
220f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
221f4a2713aSLionel Sambuc }
222f4a2713aSLionel Sambuc
constVolatileFunction() const223f4a2713aSLionel Sambuc void constVolatileFunction() const volatile {
224f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
225f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
226f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
227f4a2713aSLionel Sambuc }
228f4a2713aSLionel Sambuc
refQualifiedFunction()229f4a2713aSLionel Sambuc void refQualifiedFunction() & {
230f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
231f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
232f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
233f4a2713aSLionel Sambuc }
234f4a2713aSLionel Sambuc
refQualifiedFunction()235f4a2713aSLionel Sambuc void refQualifiedFunction() && {
236f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
237f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
238f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
239f4a2713aSLionel Sambuc }
240f4a2713aSLionel Sambuc };
241f4a2713aSLionel Sambuc
242f4a2713aSLionel Sambuc class Derived : public Base {
243f4a2713aSLionel Sambuc public:
244f4a2713aSLionel Sambuc // Virtual function without being explicitly written.
virtualFunction()245f4a2713aSLionel Sambuc void virtualFunction() {
246f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
247f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
248f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
249f4a2713aSLionel Sambuc }
250f4a2713aSLionel Sambuc };
251f4a2713aSLionel Sambuc
252f4a2713aSLionel Sambuc class Constructor {
253f4a2713aSLionel Sambuc public:
Constructor()254f4a2713aSLionel Sambuc Constructor() {
255f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
256f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
257f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
258f4a2713aSLionel Sambuc }
259f4a2713aSLionel Sambuc
Constructor(int)260f4a2713aSLionel Sambuc Constructor(int) {
261f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
262f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
263f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
264f4a2713aSLionel Sambuc }
265f4a2713aSLionel Sambuc
Constructor(Base *)266f4a2713aSLionel Sambuc Constructor(Base *) {
267f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
268f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
269f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
270f4a2713aSLionel Sambuc }
271f4a2713aSLionel Sambuc };
272f4a2713aSLionel Sambuc
273f4a2713aSLionel Sambuc class Destructor {
274f4a2713aSLionel Sambuc public:
~Destructor()275f4a2713aSLionel Sambuc ~Destructor() {
276f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
277f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
278f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
279f4a2713aSLionel Sambuc }
280f4a2713aSLionel Sambuc };
281f4a2713aSLionel Sambuc
282f4a2713aSLionel Sambuc class ContainerForAnonymousRecords {
283f4a2713aSLionel Sambuc public:
284f4a2713aSLionel Sambuc class {
285f4a2713aSLionel Sambuc public:
anonymousClassFunction()286f4a2713aSLionel Sambuc void anonymousClassFunction() {
287f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
288f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
289f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
290f4a2713aSLionel Sambuc }
291f4a2713aSLionel Sambuc } anonymousClass;
292f4a2713aSLionel Sambuc
293f4a2713aSLionel Sambuc struct {
anonymousStructFunctionNS::ContainerForAnonymousRecords::__anon8268cb4f0308294f4a2713aSLionel Sambuc void anonymousStructFunction() {
295f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
296f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
297f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
298f4a2713aSLionel Sambuc }
299f4a2713aSLionel Sambuc } anonymousStruct;
300f4a2713aSLionel Sambuc
301f4a2713aSLionel Sambuc union {
anonymousUnionFunction()302f4a2713aSLionel Sambuc void anonymousUnionFunction() {
303f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
304f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
305f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
306f4a2713aSLionel Sambuc }
307f4a2713aSLionel Sambuc } anonymousUnion;
308f4a2713aSLionel Sambuc };
309f4a2713aSLionel Sambuc
localClass(int)310f4a2713aSLionel Sambuc void localClass(int) {
311f4a2713aSLionel Sambuc class LocalClass {
312f4a2713aSLionel Sambuc public:
313f4a2713aSLionel Sambuc void localClassFunction() {
314f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
315f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
316f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
317f4a2713aSLionel Sambuc }
318f4a2713aSLionel Sambuc };
319f4a2713aSLionel Sambuc LocalClass lc;
320f4a2713aSLionel Sambuc lc.localClassFunction();
321f4a2713aSLionel Sambuc }
322f4a2713aSLionel Sambuc
externFunction()323f4a2713aSLionel Sambuc extern void externFunction() {
324f4a2713aSLionel Sambuc printf("__func__ %s\n", __func__);
325f4a2713aSLionel Sambuc printf("__FUNCTION__ %s\n", __FUNCTION__);
326f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
327f4a2713aSLionel Sambuc }
328f4a2713aSLionel Sambuc
329f4a2713aSLionel Sambuc } // end NS namespace
330f4a2713aSLionel Sambuc
331f4a2713aSLionel Sambuc // additional tests for __PRETTY_FUNCTION__
332f4a2713aSLionel Sambuc template <typename T, typename U>
functionTemplateWithTwoParams(T,U)333f4a2713aSLionel Sambuc void functionTemplateWithTwoParams(T, U)
334f4a2713aSLionel Sambuc {
335f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
336f4a2713aSLionel Sambuc }
337f4a2713aSLionel Sambuc
338f4a2713aSLionel Sambuc template <typename T>
functionTemplateWithoutParameterList()339f4a2713aSLionel Sambuc void functionTemplateWithoutParameterList()
340f4a2713aSLionel Sambuc {
341f4a2713aSLionel Sambuc T t = T();
342f4a2713aSLionel Sambuc
343f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
344f4a2713aSLionel Sambuc }
345f4a2713aSLionel Sambuc
346f4a2713aSLionel Sambuc template <typename T>
functionTemplateWithTemplateReturnType()347f4a2713aSLionel Sambuc T functionTemplateWithTemplateReturnType()
348f4a2713aSLionel Sambuc {
349f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
350f4a2713aSLionel Sambuc
351f4a2713aSLionel Sambuc return T();
352f4a2713aSLionel Sambuc }
353f4a2713aSLionel Sambuc
354f4a2713aSLionel Sambuc template <typename T>
functionTemplateWithCompoundTypes(T a[])355f4a2713aSLionel Sambuc T * functionTemplateWithCompoundTypes(T a[])
356f4a2713aSLionel Sambuc {
357f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
358f4a2713aSLionel Sambuc
359f4a2713aSLionel Sambuc return 0;
360f4a2713aSLionel Sambuc }
361f4a2713aSLionel Sambuc
362f4a2713aSLionel Sambuc template <typename T>
functionTemplateExplicitSpecialization(T t)363f4a2713aSLionel Sambuc void functionTemplateExplicitSpecialization(T t)
364f4a2713aSLionel Sambuc {
365f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
366f4a2713aSLionel Sambuc }
367f4a2713aSLionel Sambuc
368f4a2713aSLionel Sambuc template <>
functionTemplateExplicitSpecialization(int i)369f4a2713aSLionel Sambuc void functionTemplateExplicitSpecialization<int>(int i)
370f4a2713aSLionel Sambuc {
371f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
372f4a2713aSLionel Sambuc }
373f4a2713aSLionel Sambuc
374f4a2713aSLionel Sambuc template <typename, typename T>
functionTemplateWithUnnamedTemplateParameter(T t)375f4a2713aSLionel Sambuc void functionTemplateWithUnnamedTemplateParameter(T t)
376f4a2713aSLionel Sambuc {
377f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
378f4a2713aSLionel Sambuc }
379f4a2713aSLionel Sambuc
380f4a2713aSLionel Sambuc template <typename T>
functionTemplateWithLambda(T t)381f4a2713aSLionel Sambuc void functionTemplateWithLambda(T t)
382f4a2713aSLionel Sambuc {
383f4a2713aSLionel Sambuc []() {
384f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
385f4a2713aSLionel Sambuc } ();
386f4a2713aSLionel Sambuc }
387f4a2713aSLionel Sambuc
388f4a2713aSLionel Sambuc template <typename T>
functionTemplateWithCapturedStmt(T t)389f4a2713aSLionel Sambuc void functionTemplateWithCapturedStmt(T t)
390f4a2713aSLionel Sambuc {
391f4a2713aSLionel Sambuc #pragma clang __debug captured
392f4a2713aSLionel Sambuc {
393f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
394f4a2713aSLionel Sambuc }
395f4a2713aSLionel Sambuc }
396f4a2713aSLionel Sambuc
397f4a2713aSLionel Sambuc template <typename T>
398f4a2713aSLionel Sambuc class OuterClass
399f4a2713aSLionel Sambuc {
400f4a2713aSLionel Sambuc public:
401f4a2713aSLionel Sambuc class MiddleClass
402f4a2713aSLionel Sambuc {
403f4a2713aSLionel Sambuc public:
404f4a2713aSLionel Sambuc template <typename U>
405f4a2713aSLionel Sambuc class InnerClass
406f4a2713aSLionel Sambuc {
407f4a2713aSLionel Sambuc public:
memberFunction(T x,U y) const408f4a2713aSLionel Sambuc void memberFunction(T x, U y) const
409f4a2713aSLionel Sambuc {
410f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
411f4a2713aSLionel Sambuc }
412f4a2713aSLionel Sambuc };
413f4a2713aSLionel Sambuc };
414f4a2713aSLionel Sambuc };
415f4a2713aSLionel Sambuc
416f4a2713aSLionel Sambuc template <typename T, template <typename> class Param = NS::ClassTemplate>
417f4a2713aSLionel Sambuc class ClassWithTemplateTemplateParam
418f4a2713aSLionel Sambuc {
419f4a2713aSLionel Sambuc public:
staticMember()420f4a2713aSLionel Sambuc static void staticMember()
421f4a2713aSLionel Sambuc {
422f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
423f4a2713aSLionel Sambuc }
424f4a2713aSLionel Sambuc };
425f4a2713aSLionel Sambuc
426f4a2713aSLionel Sambuc template <int Count>
427f4a2713aSLionel Sambuc class NonTypeTemplateParam
428f4a2713aSLionel Sambuc {
429f4a2713aSLionel Sambuc public:
size() const430f4a2713aSLionel Sambuc void size() const
431f4a2713aSLionel Sambuc {
432f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
433f4a2713aSLionel Sambuc }
434f4a2713aSLionel Sambuc };
435f4a2713aSLionel Sambuc
436f4a2713aSLionel Sambuc template <typename T>
437f4a2713aSLionel Sambuc class SpecializedClassTemplate
438f4a2713aSLionel Sambuc {
439f4a2713aSLionel Sambuc public:
440f4a2713aSLionel Sambuc template <typename U>
memberFunctionTemplate(T t,U u) const441f4a2713aSLionel Sambuc void memberFunctionTemplate(T t, U u) const
442f4a2713aSLionel Sambuc {
443f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
444f4a2713aSLionel Sambuc }
445f4a2713aSLionel Sambuc };
446f4a2713aSLionel Sambuc
447f4a2713aSLionel Sambuc template <>
448f4a2713aSLionel Sambuc class SpecializedClassTemplate<int>
449f4a2713aSLionel Sambuc {
450f4a2713aSLionel Sambuc public:
451f4a2713aSLionel Sambuc template <typename U>
memberFunctionTemplate(int i,U u) const452f4a2713aSLionel Sambuc void memberFunctionTemplate(int i, U u) const
453f4a2713aSLionel Sambuc {
454f4a2713aSLionel Sambuc printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
455f4a2713aSLionel Sambuc }
456f4a2713aSLionel Sambuc };
457f4a2713aSLionel Sambuc
main()458f4a2713aSLionel Sambuc int main() {
459f4a2713aSLionel Sambuc ClassInAnonymousNamespace anonymousNamespace;
460f4a2713aSLionel Sambuc anonymousNamespace.anonymousNamespaceFunction();
461f4a2713aSLionel Sambuc
462f4a2713aSLionel Sambuc ClassInTopLevelNamespace topLevelNamespace;
463f4a2713aSLionel Sambuc topLevelNamespace.topLevelNamespaceFunction();
464f4a2713aSLionel Sambuc
465f4a2713aSLionel Sambuc NS::Base::staticFunction();
466f4a2713aSLionel Sambuc
467f4a2713aSLionel Sambuc NS::Base b;
468f4a2713aSLionel Sambuc b.inlineFunction();
469f4a2713aSLionel Sambuc b.virtualFunction();
470f4a2713aSLionel Sambuc b.variadicFunction(0);
471f4a2713aSLionel Sambuc b.functionWithParameters(0, 0, 0);
472f4a2713aSLionel Sambuc b.functionReturningClass();
473f4a2713aSLionel Sambuc
474f4a2713aSLionel Sambuc b.withTemplateParameter1(NS::ClassTemplate<int>());
475f4a2713aSLionel Sambuc b.withTemplateParameter2(NS::ClassTemplate<NS::Base *>());
476f4a2713aSLionel Sambuc b.functionReturingTemplate1();
477f4a2713aSLionel Sambuc b.functionReturingTemplate2();
478f4a2713aSLionel Sambuc b.functionTemplate1<int>(0);
479f4a2713aSLionel Sambuc b.functionTemplate1<NS::Base *>(0);
480f4a2713aSLionel Sambuc b.constFunction();
481f4a2713aSLionel Sambuc b.volatileFunction();
482f4a2713aSLionel Sambuc b.constVolatileFunction();
483f4a2713aSLionel Sambuc b.refQualifiedFunction();
484f4a2713aSLionel Sambuc NS::Base().refQualifiedFunction();
485f4a2713aSLionel Sambuc
486f4a2713aSLionel Sambuc NS::Derived d;
487f4a2713aSLionel Sambuc d.virtualFunction();
488f4a2713aSLionel Sambuc
489f4a2713aSLionel Sambuc NS::ClassTemplate<int> t1;
490f4a2713aSLionel Sambuc t1.classTemplateFunction();
491f4a2713aSLionel Sambuc NS::ClassTemplate<NS::Base *> t2;
492f4a2713aSLionel Sambuc t2.classTemplateFunction();
493f4a2713aSLionel Sambuc
494f4a2713aSLionel Sambuc NS::Constructor c1;
495f4a2713aSLionel Sambuc NS::Constructor c2(0);
496f4a2713aSLionel Sambuc NS::Constructor c3((NS::Base *)0);
497f4a2713aSLionel Sambuc
498f4a2713aSLionel Sambuc {
499f4a2713aSLionel Sambuc NS::Destructor destructor;
500f4a2713aSLionel Sambuc }
501f4a2713aSLionel Sambuc
502f4a2713aSLionel Sambuc NS::ContainerForAnonymousRecords anonymous;
503f4a2713aSLionel Sambuc anonymous.anonymousClass.anonymousClassFunction();
504f4a2713aSLionel Sambuc anonymous.anonymousStruct.anonymousStructFunction();
505f4a2713aSLionel Sambuc anonymous.anonymousUnion.anonymousUnionFunction();
506f4a2713aSLionel Sambuc
507f4a2713aSLionel Sambuc NS::localClass(0);
508f4a2713aSLionel Sambuc
509f4a2713aSLionel Sambuc NS::externFunction();
510f4a2713aSLionel Sambuc
511f4a2713aSLionel Sambuc // additional tests for __PRETTY_FUNCTION__
512f4a2713aSLionel Sambuc
513f4a2713aSLionel Sambuc functionTemplateWithTwoParams(0, 0.0f);
514f4a2713aSLionel Sambuc functionTemplateWithoutParameterList<double>();
515f4a2713aSLionel Sambuc functionTemplateWithTemplateReturnType<char>();
516f4a2713aSLionel Sambuc int array[] = { 1, 2, 3 };
517f4a2713aSLionel Sambuc functionTemplateWithCompoundTypes(array);
518f4a2713aSLionel Sambuc functionTemplateExplicitSpecialization(0);
519f4a2713aSLionel Sambuc functionTemplateExplicitSpecialization(0.0);
520f4a2713aSLionel Sambuc functionTemplateWithUnnamedTemplateParameter<int, float>(0.0f);
521f4a2713aSLionel Sambuc
522f4a2713aSLionel Sambuc functionTemplateWithLambda<int>(0);
523f4a2713aSLionel Sambuc functionTemplateWithCapturedStmt<int>(0);
524f4a2713aSLionel Sambuc
525f4a2713aSLionel Sambuc OuterClass<int *>::MiddleClass::InnerClass<float> omi;
526f4a2713aSLionel Sambuc omi.memberFunction(0, 0.0f);
527f4a2713aSLionel Sambuc
528f4a2713aSLionel Sambuc ClassWithTemplateTemplateParam<char>::staticMember();
529f4a2713aSLionel Sambuc
530f4a2713aSLionel Sambuc NonTypeTemplateParam<42> ntt;
531f4a2713aSLionel Sambuc ntt.size();
532f4a2713aSLionel Sambuc
533f4a2713aSLionel Sambuc SpecializedClassTemplate<int> sct1;
534f4a2713aSLionel Sambuc sct1.memberFunctionTemplate(0, 0.0f);
535f4a2713aSLionel Sambuc SpecializedClassTemplate<char> sct2;
536f4a2713aSLionel Sambuc sct2.memberFunctionTemplate('0', 0.0);
537f4a2713aSLionel Sambuc
538f4a2713aSLionel Sambuc return 0;
539f4a2713aSLionel Sambuc }
540*0a6a1f1dSLionel Sambuc
541*0a6a1f1dSLionel Sambuc // rdar://19065361
542*0a6a1f1dSLionel Sambuc class XXX {
543*0a6a1f1dSLionel Sambuc XXX();
544*0a6a1f1dSLionel Sambuc ~XXX();
545*0a6a1f1dSLionel Sambuc };
546*0a6a1f1dSLionel Sambuc
XXLog(const char * functionName)547*0a6a1f1dSLionel Sambuc void XXLog(const char *functionName) { }
548*0a6a1f1dSLionel Sambuc
549*0a6a1f1dSLionel Sambuc typedef void (^notify_handler_t)(int token);
550*0a6a1f1dSLionel Sambuc
551*0a6a1f1dSLionel Sambuc typedef void (^dispatch_block_t)(void);
552*0a6a1f1dSLionel Sambuc
553*0a6a1f1dSLionel Sambuc void notify_register_dispatch(notify_handler_t handler);
554*0a6a1f1dSLionel Sambuc
555*0a6a1f1dSLionel Sambuc void _dispatch_once(dispatch_block_t block);
556*0a6a1f1dSLionel Sambuc
XXX()557*0a6a1f1dSLionel Sambuc XXX::XXX()
558*0a6a1f1dSLionel Sambuc {
559*0a6a1f1dSLionel Sambuc _dispatch_once(^{ notify_register_dispatch( ^(int token) { XXLog(__FUNCTION__); });
560*0a6a1f1dSLionel Sambuc });
561*0a6a1f1dSLionel Sambuc }
562*0a6a1f1dSLionel Sambuc // CHECK: define internal void @___ZN3XXXC2Ev_block_invoke_
563*0a6a1f1dSLionel Sambuc
~XXX()564*0a6a1f1dSLionel Sambuc XXX::~XXX()
565*0a6a1f1dSLionel Sambuc {
566*0a6a1f1dSLionel Sambuc _dispatch_once(^{ notify_register_dispatch( ^(int token) { XXLog(__FUNCTION__); });
567*0a6a1f1dSLionel Sambuc });
568*0a6a1f1dSLionel Sambuc }
569*0a6a1f1dSLionel Sambuc // CHECK: define internal void @___ZN3XXXD2Ev_block_invoke_
570