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