Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / predefined-expr-cxx14.cpp
blobec7c3db7bd42b69612d2ae63e5d49d26df5a72bf
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
5 #ifndef HEADER
6 #define HEADER
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"
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"
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"
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"
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"
23 // CHECK-DAG: private unnamed_addr constant [32 x i8] c"const char *ConstexprPrettyFn()\00"
25 int printf(const char * _Format, ...);
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);
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;
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;
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;
63 struct ClassBlockConstr {
64 const char *s;
65 ClassBlockConstr() {
66 const char * (^b)() = ^() {
67 return __func__;
69 s = b();
71 ~ClassBlockConstr() {
72 const char * (^b)() = ^() {
73 return __func__;
75 s = b();
79 template <class T>
80 class FuncTemplate {
81 const char *Func;
83 public:
84 FuncTemplate() : Func(__func__) {}
85 const char *getFunc() const { return Func; }
88 constexpr const char* ConstexprPrettyFn() {
89 return __PRETTY_FUNCTION__;
91 const char* ConstexprPrettyVar = ConstexprPrettyFn();
93 int
94 main() {
95 int a;
96 ClassInTopLevelNamespace topLevelNamespace;
97 ClassBlockConstr classBlockConstr;
98 topLevelNamespace.topLevelNamespaceFunction();
99 topLevelNamespace.variadicFunction(&a);
100 topLevelNamespace.functionTemplate(a);
102 ClassTemplate<int> t;
103 t.classTemplateFunction(a);
104 return 0;
106 #else
107 void Foo() {
108 FuncTemplate<int> FTi;
109 (void)FTi.getFunc();
111 #endif