blob: dd531e3112b6e22b60539c547d606429518e9ab5 [file] [log] [blame]
Alexey Bataevec474782014-10-09 08:45:04 +00001// RUN: %clang_cc1 -std=c++14 %s -triple %itanium_abi_triple -fblocks -emit-llvm -o - | FileCheck %s
Alexey Bataev769562a2014-10-10 18:58:13 +00002// 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
Alexey Bataevec474782014-10-09 08:45:04 +00007
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
Mehdi Aminidc9bf8f2016-11-16 07:07:28 +000020// CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [31 x i8] c"~ClassBlockConstr_block_invoke\00"
21// CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [30 x i8] c"ClassBlockConstr_block_invoke\00"
Alexey Bataevec474782014-10-09 08:45:04 +000022
23int printf(const char * _Format, ...);
24
25class ClassInTopLevelNamespace {
26public:
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
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>
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
50template<typename T>
51class ClassTemplate {
52public:
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
61struct ClassBlockConstr {
62 const char *s;
63 ClassBlockConstr() {
64 const char * (^b)() = ^() {
65 return __func__;
66 };
67 s = b();
68 }
69 ~ClassBlockConstr() {
70 const char * (^b)() = ^() {
71 return __func__;
72 };
73 s = b();
74 }
75};
76
Alexey Bataev4dcead42014-10-13 03:27:35 +000077template <class T>
78class FuncTemplate {
79 const char *Func;
80
81public:
82 FuncTemplate() : Func(__func__) {}
83 const char *getFunc() const { return Func; }
84};
85
86int
87main() {
Alexey Bataevec474782014-10-09 08:45:04 +000088 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}
Alexey Bataev4dcead42014-10-13 03:27:35 +000099#else
100void Foo() {
101 FuncTemplate<int> FTi;
102 (void)FTi.getFunc();
103}
Alexey Bataev769562a2014-10-10 18:58:13 +0000104#endif
105