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 [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" 22 23 // CHECK-DAG: private unnamed_addr constant [32 x i8] c"const char *ConstexprPrettyFn()\00" 24 25 int printf(const char * _Format, ...); 26 27 class ClassInTopLevelNamespace { 28 public: 29 auto *topLevelNamespaceFunction() { 30 printf("__func__ %s\n", __func__); 31 printf("__FUNCTION__ %s\n", __FUNCTION__); 32 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); 33 return static_cast<int *>(nullptr); 34 } 35 36 decltype(auto) variadicFunction(int *a, ...) { 37 printf("__func__ %s\n", __func__); 38 printf("__FUNCTION__ %s\n", __FUNCTION__); 39 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); 40 return a; 41 } 42 43 template<typename T> 44 auto &functionTemplate(T &t) { 45 printf("__func__ %s\n", __func__); 46 printf("__FUNCTION__ %s\n", __FUNCTION__); 47 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); 48 return t; 49 } 50 }; 51 52 template<typename T> 53 class ClassTemplate { 54 public: 55 const auto &classTemplateFunction(T &t) { 56 printf("__func__ %s\n", __func__); 57 printf("__FUNCTION__ %s\n", __FUNCTION__); 58 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); 59 return t; 60 } 61 }; 62 63 struct ClassBlockConstr { 64 const char *s; 65 ClassBlockConstr() { 66 const char * (^b)() = ^() { 67 return __func__; 68 }; 69 s = b(); 70 } 71 ~ClassBlockConstr() { 72 const char * (^b)() = ^() { 73 return __func__; 74 }; 75 s = b(); 76 } 77 }; 78 79 template <class T> 80 class FuncTemplate { 81 const char *Func; 82 83 public: 84 FuncTemplate() : Func(__func__) {} 85 const char *getFunc() const { return Func; } 86 }; 87 88 constexpr const char* ConstexprPrettyFn() { 89 return __PRETTY_FUNCTION__; 90 } 91 const char* ConstexprPrettyVar = ConstexprPrettyFn(); 92 93 int 94 main() { 95 int a; 96 ClassInTopLevelNamespace topLevelNamespace; 97 ClassBlockConstr classBlockConstr; 98 topLevelNamespace.topLevelNamespaceFunction(); 99 topLevelNamespace.variadicFunction(&a); 100 topLevelNamespace.functionTemplate(a); 101 102 ClassTemplate<int> t; 103 t.classTemplateFunction(a); 104 return 0; 105 } 106 #else 107 void Foo() { 108 FuncTemplate<int> FTi; 109 (void)FTi.getFunc(); 110 } 111 #endif 112 113