diff options
Diffstat (limited to 'clang/test/CodeGenCXX/predefined-expr-cxx14.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/predefined-expr-cxx14.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/predefined-expr-cxx14.cpp b/clang/test/CodeGenCXX/predefined-expr-cxx14.cpp new file mode 100644 index 00000000000..62c86df294c --- /dev/null +++ b/clang/test/CodeGenCXX/predefined-expr-cxx14.cpp @@ -0,0 +1,83 @@ +// RUN: %clang_cc1 -std=c++14 %s -triple %itanium_abi_triple -fblocks -emit-llvm -o - | FileCheck %s + +// CHECK-DAG: @__func__._ZN13ClassTemplateIiE21classTemplateFunctionERi = private unnamed_addr constant [22 x i8] c"classTemplateFunction\00" +// CHECK-DAG: @__PRETTY_FUNCTION__._ZN13ClassTemplateIiE21classTemplateFunctionERi = private unnamed_addr constant [69 x i8] c"const auto &ClassTemplate<int>::classTemplateFunction(T &) [T = int]\00" + +// CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace16functionTemplateIiEERDaRT_ = private unnamed_addr constant [17 x i8] c"functionTemplate\00" +// CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace16functionTemplateIiEERDaRT_ = private unnamed_addr constant [64 x i8] c"auto &ClassInTopLevelNamespace::functionTemplate(T &) [T = int]\00" + +// CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace16variadicFunctionEPiz = private unnamed_addr constant [17 x i8] c"variadicFunction\00" +// CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace16variadicFunctionEPiz = private unnamed_addr constant [70 x i8] c"decltype(auto) ClassInTopLevelNamespace::variadicFunction(int *, ...)\00" + +// CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00" +// CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [60 x i8] c"auto *ClassInTopLevelNamespace::topLevelNamespaceFunction()\00" + +// CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrD1Ev_block_invoke\00" +// CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrC1Ev_block_invoke\00" + +int printf(const char * _Format, ...); + +class ClassInTopLevelNamespace { +public: + auto *topLevelNamespaceFunction() { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + return static_cast<int *>(nullptr); + } + + decltype(auto) variadicFunction(int *a, ...) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + return a; + } + + template<typename T> + auto &functionTemplate(T &t) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + return t; + } +}; + +template<typename T> +class ClassTemplate { +public: + const auto &classTemplateFunction(T &t) { + printf("__func__ %s\n", __func__); + printf("__FUNCTION__ %s\n", __FUNCTION__); + printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); + return t; + } +}; + +struct ClassBlockConstr { + const char *s; + ClassBlockConstr() { + const char * (^b)() = ^() { + return __func__; + }; + s = b(); + } + ~ClassBlockConstr() { + const char * (^b)() = ^() { + return __func__; + }; + s = b(); + } +}; + +int main() { + int a; + ClassInTopLevelNamespace topLevelNamespace; + ClassBlockConstr classBlockConstr; + topLevelNamespace.topLevelNamespaceFunction(); + topLevelNamespace.variadicFunction(&a); + topLevelNamespace.functionTemplate(a); + + ClassTemplate<int> t; + t.classTemplateFunction(a); + return 0; +} |