Alexey Bataev | ec47478 | 2014-10-09 08:45:04 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++14 %s -triple %itanium_abi_triple -fblocks -emit-llvm -o - | FileCheck %s |
Alexey Bataev | 769562a | 2014-10-10 18:58:13 +0000 | [diff] [blame^] | 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 |
Alexey Bataev | ec47478 | 2014-10-09 08:45:04 +0000 | [diff] [blame] | 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"___ZN16ClassBlockConstrD1Ev_block_invoke\00" |
| 21 | // CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrC1Ev_block_invoke\00" |
| 22 | |
| 23 | int printf(const char * _Format, ...); |
| 24 | |
| 25 | class ClassInTopLevelNamespace { |
| 26 | public: |
| 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 | |
| 50 | template<typename T> |
| 51 | class ClassTemplate { |
| 52 | public: |
| 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; |
| 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 | |
| 77 | int main() { |
| 78 | int a; |
| 79 | ClassInTopLevelNamespace topLevelNamespace; |
| 80 | ClassBlockConstr classBlockConstr; |
| 81 | topLevelNamespace.topLevelNamespaceFunction(); |
| 82 | topLevelNamespace.variadicFunction(&a); |
| 83 | topLevelNamespace.functionTemplate(a); |
| 84 | |
| 85 | ClassTemplate<int> t; |
| 86 | t.classTemplateFunction(a); |
| 87 | return 0; |
| 88 | } |
Alexey Bataev | 769562a | 2014-10-10 18:58:13 +0000 | [diff] [blame^] | 89 | #endif |
| 90 | |