1 // RUN: %clang_cc1 -std=c++14 %s -triple %itanium_abi_triple -fblocks -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -x c++ -std=c++14 -triple %itanium_abi_triple -fblocks -emit-pch -o %t %s
3 // RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -std=c++14 -fblocks -include-pch %t %s -emit-llvm -o - | FileCheck %s
4
5 #ifndef HEADER
6 #define HEADER
7
8 // CHECK-DAG: @__func__._ZN13ClassTemplateIiE21classTemplateFunctionERi = private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
9 // CHECK-DAG: @__PRETTY_FUNCTION__._ZN13ClassTemplateIiE21classTemplateFunctionERi = private unnamed_addr constant [69 x i8] c"const auto &ClassTemplate<int>::classTemplateFunction(T &) [T = int]\00"
10
11 // CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace16functionTemplateIiEERDaRT_ = private unnamed_addr constant [17 x i8] c"functionTemplate\00"
12 // CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace16functionTemplateIiEERDaRT_ = private unnamed_addr constant [64 x i8] c"auto &ClassInTopLevelNamespace::functionTemplate(T &) [T = int]\00"
13
14 // CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace16variadicFunctionEPiz = private unnamed_addr constant [17 x i8] c"variadicFunction\00"
15 // CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace16variadicFunctionEPiz = private unnamed_addr constant [70 x i8] c"decltype(auto) ClassInTopLevelNamespace::variadicFunction(int *, ...)\00"
16
17 // CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00"
18 // CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [60 x i8] c"auto *ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
19
20 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrD2Ev_block_invoke\00"
21 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrC2Ev_block_invoke\00"
22
23 int printf(const char * _Format, ...);
24
25 class ClassInTopLevelNamespace {
26 public:
topLevelNamespaceFunction()27 auto *topLevelNamespaceFunction() {
28 printf("__func__ %s\n", __func__);
29 printf("__FUNCTION__ %s\n", __FUNCTION__);
30 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
31 return static_cast<int *>(nullptr);
32 }
33
variadicFunction(int * a,...)34 decltype(auto) variadicFunction(int *a, ...) {
35 printf("__func__ %s\n", __func__);
36 printf("__FUNCTION__ %s\n", __FUNCTION__);
37 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
38 return a;
39 }
40
41 template<typename T>
functionTemplate(T & t)42 auto &functionTemplate(T &t) {
43 printf("__func__ %s\n", __func__);
44 printf("__FUNCTION__ %s\n", __FUNCTION__);
45 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
46 return t;
47 }
48 };
49
50 template<typename T>
51 class ClassTemplate {
52 public:
classTemplateFunction(T & t)53 const auto &classTemplateFunction(T &t) {
54 printf("__func__ %s\n", __func__);
55 printf("__FUNCTION__ %s\n", __FUNCTION__);
56 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
57 return t;
58 }
59 };
60
61 struct ClassBlockConstr {
62 const char *s;
ClassBlockConstrClassBlockConstr63 ClassBlockConstr() {
64 const char * (^b)() = ^() {
65 return __func__;
66 };
67 s = b();
68 }
~ClassBlockConstrClassBlockConstr69 ~ClassBlockConstr() {
70 const char * (^b)() = ^() {
71 return __func__;
72 };
73 s = b();
74 }
75 };
76
77 template <class T>
78 class FuncTemplate {
79 const char *Func;
80
81 public:
FuncTemplate()82 FuncTemplate() : Func(__func__) {}
getFunc() const83 const char *getFunc() const { return Func; }
84 };
85
86 int
main()87 main() {
88 int a;
89 ClassInTopLevelNamespace topLevelNamespace;
90 ClassBlockConstr classBlockConstr;
91 topLevelNamespace.topLevelNamespaceFunction();
92 topLevelNamespace.variadicFunction(&a);
93 topLevelNamespace.functionTemplate(a);
94
95 ClassTemplate<int> t;
96 t.classTemplateFunction(a);
97 return 0;
98 }
99 #else
Foo()100 void Foo() {
101 FuncTemplate<int> FTi;
102 (void)FTi.getFunc();
103 }
104 #endif
105
106