Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - | FileCheck %s |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 2 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 3 | // CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00" |
| 4 | // CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00" |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 5 | // CHECK: private unnamed_addr constant [49 x i8] c"void functionTemplateExplicitSpecialization(int)\00" |
| 6 | |
| 7 | // CHECK: private unnamed_addr constant [95 x i8] c"void SpecializedClassTemplate<char>::memberFunctionTemplate(T, U) const [T = char, U = double]\00" |
| 8 | // CHECK: private unnamed_addr constant [85 x i8] c"void SpecializedClassTemplate<int>::memberFunctionTemplate(int, U) const [U = float]\00" |
| 9 | // CHECK: private unnamed_addr constant [57 x i8] c"void NonTypeTemplateParam<42>::size() const [Count = 42]\00" |
| 10 | // CHECK: private unnamed_addr constant [122 x i8] c"static void ClassWithTemplateTemplateParam<char, NS::ClassTemplate>::staticMember() [T = char, Param = NS::ClassTemplate]\00" |
| 11 | // CHECK: private unnamed_addr constant [106 x i8] c"void OuterClass<int *>::MiddleClass::InnerClass<float>::memberFunction(T, U) const [T = int *, U = float]\00" |
| 12 | // CHECK: private unnamed_addr constant [65 x i8] c"void functionTemplateWithUnnamedTemplateParameter(T) [T = float]\00" |
| 13 | |
| 14 | // CHECK: private unnamed_addr constant [60 x i8] c"void functionTemplateExplicitSpecialization(T) [T = double]\00" |
| 15 | // CHECK: private unnamed_addr constant [52 x i8] c"T *functionTemplateWithCompoundTypes(T *) [T = int]\00" |
| 16 | // CHECK: private unnamed_addr constant [54 x i8] c"T functionTemplateWithTemplateReturnType() [T = char]\00" |
| 17 | // CHECK: private unnamed_addr constant [57 x i8] c"void functionTemplateWithoutParameterList() [T = double]\00" |
| 18 | // CHECK: private unnamed_addr constant [62 x i8] c"void functionTemplateWithTwoParams(T, U) [T = int, U = float]\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 19 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 20 | // CHECK: private unnamed_addr constant [22 x i8] c"classTemplateFunction\00" |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 21 | // CHECK: private unnamed_addr constant [77 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction() [T = NS::Base *]\00" |
| 22 | // CHECK: private unnamed_addr constant [63 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction() [T = int]\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 23 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 24 | // CHECK: private unnamed_addr constant [18 x i8] c"functionTemplate1\00" |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 25 | // CHECK: private unnamed_addr constant [53 x i8] c"void NS::Base::functionTemplate1(T) [T = NS::Base *]\00" |
| 26 | // CHECK: private unnamed_addr constant [46 x i8] c"void NS::Base::functionTemplate1(T) [T = int]\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 27 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 28 | // CHECK: private unnamed_addr constant [23 x i8] c"anonymousUnionFunction\00" |
| 29 | // CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous union>::anonymousUnionFunction()\00" |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 30 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 31 | // CHECK: private unnamed_addr constant [24 x i8] c"anonymousStructFunction\00" |
| 32 | // CHECK: private unnamed_addr constant [85 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous struct>::anonymousStructFunction()\00" |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 33 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 34 | // CHECK: private unnamed_addr constant [23 x i8] c"anonymousClassFunction\00" |
| 35 | // CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous class>::anonymousClassFunction()\00" |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 36 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 37 | // CHECK: private unnamed_addr constant [12 x i8] c"~Destructor\00" |
| 38 | // CHECK: private unnamed_addr constant [30 x i8] c"NS::Destructor::~Destructor()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 39 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 40 | // CHECK: private unnamed_addr constant [12 x i8] c"Constructor\00" |
| 41 | // CHECK: private unnamed_addr constant [41 x i8] c"NS::Constructor::Constructor(NS::Base *)\00" |
| 42 | // CHECK: private unnamed_addr constant [34 x i8] c"NS::Constructor::Constructor(int)\00" |
| 43 | // CHECK: private unnamed_addr constant [31 x i8] c"NS::Constructor::Constructor()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 44 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 45 | // CHECK: private unnamed_addr constant [16 x i8] c"virtualFunction\00" |
| 46 | // CHECK: private unnamed_addr constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 47 | |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 48 | // CHECK: private unnamed_addr constant [21 x i8] c"refQualifiedFunction\00" |
| 49 | // CHECK: private unnamed_addr constant [41 x i8] c"void NS::Base::refQualifiedFunction() &&\00" |
| 50 | // CHECK: private unnamed_addr constant [40 x i8] c"void NS::Base::refQualifiedFunction() &\00" |
| 51 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 52 | // CHECK: private unnamed_addr constant [22 x i8] c"constVolatileFunction\00" |
| 53 | // CHECK: private unnamed_addr constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00" |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 54 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 55 | // CHECK: private unnamed_addr constant [17 x i8] c"volatileFunction\00" |
| 56 | // CHECK: private unnamed_addr constant [43 x i8] c"void NS::Base::volatileFunction() volatile\00" |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 57 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 58 | // CHECK: private unnamed_addr constant [14 x i8] c"constFunction\00" |
| 59 | // CHECK: private unnamed_addr constant [37 x i8] c"void NS::Base::constFunction() const\00" |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 60 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 61 | // CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate2\00" |
| 62 | // CHECK: private unnamed_addr constant [64 x i8] c"ClassTemplate<NS::Base *> NS::Base::functionReturingTemplate2()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 63 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 64 | // CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate1\00" |
| 65 | // CHECK: private unnamed_addr constant [57 x i8] c"ClassTemplate<int> NS::Base::functionReturingTemplate1()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 66 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 67 | // CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter2\00" |
| 68 | // CHECK: private unnamed_addr constant [65 x i8] c"void NS::Base::withTemplateParameter2(ClassTemplate<NS::Base *>)\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 69 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 70 | // CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter1\00" |
| 71 | // CHECK: private unnamed_addr constant [58 x i8] c"void NS::Base::withTemplateParameter1(ClassTemplate<int>)\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 72 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 73 | // CHECK: private unnamed_addr constant [23 x i8] c"functionReturningClass\00" |
| 74 | // CHECK: private unnamed_addr constant [45 x i8] c"NS::Base *NS::Base::functionReturningClass()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 75 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 76 | // CHECK: private unnamed_addr constant [23 x i8] c"functionWithParameters\00" |
| 77 | // CHECK: private unnamed_addr constant [64 x i8] c"void NS::Base::functionWithParameters(int, float *, NS::Base *)\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 78 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 79 | // CHECK: private unnamed_addr constant [17 x i8] c"variadicFunction\00" |
| 80 | // CHECK: private unnamed_addr constant [42 x i8] c"void NS::Base::variadicFunction(int, ...)\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 81 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 82 | // CHECK: private unnamed_addr constant [41 x i8] c"virtual void NS::Base::virtualFunction()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 83 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 84 | // CHECK: private unnamed_addr constant [15 x i8] c"inlineFunction\00" |
| 85 | // CHECK: private unnamed_addr constant [32 x i8] c"void NS::Base::inlineFunction()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 86 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 87 | // CHECK: private unnamed_addr constant [15 x i8] c"staticFunction\00" |
| 88 | // CHECK: private unnamed_addr constant [39 x i8] c"static void NS::Base::staticFunction()\00" |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 89 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 90 | // CHECK: private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00" |
| 91 | // CHECK: private unnamed_addr constant [59 x i8] c"void ClassInTopLevelNamespace::topLevelNamespaceFunction()\00" |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 92 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 93 | // CHECK: private unnamed_addr constant [27 x i8] c"anonymousNamespaceFunction\00" |
| 94 | // CHECK: private unnamed_addr constant [84 x i8] c"void <anonymous namespace>::ClassInAnonymousNamespace::anonymousNamespaceFunction()\00" |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 95 | |
Rafael Espindola | 1257bc6 | 2011-01-10 22:34:03 +0000 | [diff] [blame] | 96 | // CHECK: private unnamed_addr constant [19 x i8] c"localClassFunction\00" |
| 97 | // CHECK: private unnamed_addr constant [59 x i8] c"void NS::localClass(int)::LocalClass::localClassFunction()\00" |
Sam Weinig | 3521d01 | 2009-12-28 03:19:38 +0000 | [diff] [blame] | 98 | |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 99 | |
| 100 | |
Mike Stump | 76bee4b | 2009-10-08 23:05:06 +0000 | [diff] [blame] | 101 | int printf(const char * _Format, ...); |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 102 | |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 103 | class ClassInTopLevelNamespace { |
| 104 | public: |
| 105 | void topLevelNamespaceFunction() { |
| 106 | printf("__func__ %s\n", __func__); |
| 107 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 108 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | namespace { |
| 113 | |
| 114 | class ClassInAnonymousNamespace { |
| 115 | public: |
| 116 | void anonymousNamespaceFunction() { |
| 117 | printf("__func__ %s\n", __func__); |
| 118 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 119 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 120 | } |
| 121 | }; |
| 122 | |
| 123 | } // end anonymous namespace |
| 124 | |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 125 | namespace NS { |
| 126 | |
| 127 | template<typename T> |
| 128 | class ClassTemplate { |
| 129 | public: |
| 130 | void classTemplateFunction() { |
| 131 | printf("__func__ %s\n", __func__); |
| 132 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 133 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 134 | } |
| 135 | }; |
| 136 | |
| 137 | class Base { |
| 138 | public: |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 139 | static void staticFunction() { |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 140 | printf("__func__ %s\n", __func__); |
| 141 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 142 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 143 | } |
| 144 | |
Argyrios Kyrtzidis | 4ae711b | 2012-12-14 19:44:11 +0000 | [diff] [blame] | 145 | inline void (inlineFunction)() { |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 146 | printf("__func__ %s\n", __func__); |
| 147 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 148 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 149 | } |
| 150 | |
| 151 | virtual void virtualFunction() { |
| 152 | printf("__func__ %s\n", __func__); |
| 153 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 154 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 155 | } |
| 156 | |
| 157 | void functionWithParameters(int, float*, Base* base) { |
| 158 | printf("__func__ %s\n", __func__); |
| 159 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 160 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 161 | } |
| 162 | |
| 163 | Base *functionReturningClass() { |
| 164 | printf("__func__ %s\n", __func__); |
| 165 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 166 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | void variadicFunction(int, ...) { |
| 171 | printf("__func__ %s\n", __func__); |
| 172 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 173 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 174 | } |
| 175 | |
| 176 | void withTemplateParameter1(ClassTemplate<int>) { |
| 177 | printf("__func__ %s\n", __func__); |
| 178 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 179 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 180 | } |
| 181 | |
| 182 | void withTemplateParameter2(ClassTemplate<Base *>) { |
| 183 | printf("__func__ %s\n", __func__); |
| 184 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 185 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 186 | } |
| 187 | |
| 188 | ClassTemplate<int> functionReturingTemplate1() { |
| 189 | printf("__func__ %s\n", __func__); |
| 190 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 191 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 192 | return ClassTemplate<int>(); |
| 193 | } |
| 194 | |
| 195 | ClassTemplate<Base *> functionReturingTemplate2() { |
| 196 | printf("__func__ %s\n", __func__); |
| 197 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 198 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 199 | return ClassTemplate<Base *>(); |
| 200 | } |
| 201 | |
| 202 | template<typename T> |
| 203 | void functionTemplate1(T t) { |
| 204 | printf("__func__ %s\n", __func__); |
| 205 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 206 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 207 | } |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 208 | |
| 209 | void constFunction() const { |
| 210 | printf("__func__ %s\n", __func__); |
| 211 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 212 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 213 | } |
| 214 | |
| 215 | void volatileFunction() volatile { |
| 216 | printf("__func__ %s\n", __func__); |
| 217 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 218 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 219 | } |
| 220 | |
| 221 | void constVolatileFunction() const volatile { |
| 222 | printf("__func__ %s\n", __func__); |
| 223 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 224 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 225 | } |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 226 | |
| 227 | void refQualifiedFunction() & { |
| 228 | printf("__func__ %s\n", __func__); |
| 229 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 230 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 231 | } |
| 232 | |
| 233 | void refQualifiedFunction() && { |
| 234 | printf("__func__ %s\n", __func__); |
| 235 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 236 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 237 | } |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | class Derived : public Base { |
| 241 | public: |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 242 | // Virtual function without being explicitly written. |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 243 | void virtualFunction() { |
| 244 | printf("__func__ %s\n", __func__); |
| 245 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 246 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 247 | } |
| 248 | }; |
| 249 | |
| 250 | class Constructor { |
| 251 | public: |
| 252 | Constructor() { |
| 253 | printf("__func__ %s\n", __func__); |
| 254 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 255 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 256 | } |
| 257 | |
| 258 | Constructor(int) { |
| 259 | printf("__func__ %s\n", __func__); |
| 260 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 261 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 262 | } |
| 263 | |
| 264 | Constructor(Base *) { |
| 265 | printf("__func__ %s\n", __func__); |
| 266 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 267 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 268 | } |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 269 | }; |
| 270 | |
| 271 | class Destructor { |
| 272 | public: |
| 273 | ~Destructor() { |
| 274 | printf("__func__ %s\n", __func__); |
| 275 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 276 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 277 | } |
| 278 | }; |
| 279 | |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 280 | class ContainerForAnonymousRecords { |
| 281 | public: |
| 282 | class { |
| 283 | public: |
| 284 | void anonymousClassFunction() { |
| 285 | printf("__func__ %s\n", __func__); |
| 286 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 287 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 288 | } |
| 289 | } anonymousClass; |
| 290 | |
| 291 | struct { |
| 292 | void anonymousStructFunction() { |
| 293 | printf("__func__ %s\n", __func__); |
| 294 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 295 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 296 | } |
| 297 | } anonymousStruct; |
| 298 | |
| 299 | union { |
| 300 | void anonymousUnionFunction() { |
| 301 | printf("__func__ %s\n", __func__); |
| 302 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 303 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 304 | } |
| 305 | } anonymousUnion; |
| 306 | }; |
| 307 | |
Sam Weinig | 3521d01 | 2009-12-28 03:19:38 +0000 | [diff] [blame] | 308 | void localClass(int) { |
| 309 | class LocalClass { |
| 310 | public: |
| 311 | void localClassFunction() { |
| 312 | printf("__func__ %s\n", __func__); |
| 313 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 314 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 315 | } |
| 316 | }; |
| 317 | LocalClass lc; |
| 318 | lc.localClassFunction(); |
| 319 | } |
| 320 | |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 321 | extern void externFunction() { |
| 322 | printf("__func__ %s\n", __func__); |
| 323 | printf("__FUNCTION__ %s\n", __FUNCTION__); |
| 324 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 325 | } |
| 326 | |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 327 | } // end NS namespace |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 328 | |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 329 | // additional tests for __PRETTY_FUNCTION__ |
| 330 | template <typename T, typename U> |
| 331 | void functionTemplateWithTwoParams(T, U) |
| 332 | { |
| 333 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 334 | } |
| 335 | |
| 336 | template <typename T> |
| 337 | void functionTemplateWithoutParameterList() |
| 338 | { |
| 339 | T t = T(); |
| 340 | |
| 341 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 342 | } |
| 343 | |
| 344 | template <typename T> |
| 345 | T functionTemplateWithTemplateReturnType() |
| 346 | { |
| 347 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 348 | |
| 349 | return T(); |
| 350 | } |
| 351 | |
| 352 | template <typename T> |
| 353 | T * functionTemplateWithCompoundTypes(T a[]) |
| 354 | { |
| 355 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 356 | |
| 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | template <typename T> |
| 361 | void functionTemplateExplicitSpecialization(T t) |
| 362 | { |
| 363 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 364 | } |
| 365 | |
| 366 | template <> |
| 367 | void functionTemplateExplicitSpecialization<int>(int i) |
| 368 | { |
| 369 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 370 | } |
| 371 | |
| 372 | template <typename, typename T> |
| 373 | void functionTemplateWithUnnamedTemplateParameter(T t) |
| 374 | { |
| 375 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 376 | } |
| 377 | |
| 378 | template <typename T> |
| 379 | class OuterClass |
| 380 | { |
| 381 | public: |
| 382 | class MiddleClass |
| 383 | { |
| 384 | public: |
| 385 | template <typename U> |
| 386 | class InnerClass |
| 387 | { |
| 388 | public: |
| 389 | void memberFunction(T x, U y) const |
| 390 | { |
| 391 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 392 | } |
| 393 | }; |
| 394 | }; |
| 395 | }; |
| 396 | |
| 397 | template <typename T, template <typename> class Param = NS::ClassTemplate> |
| 398 | class ClassWithTemplateTemplateParam |
| 399 | { |
| 400 | public: |
| 401 | static void staticMember() |
| 402 | { |
| 403 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 404 | } |
| 405 | }; |
| 406 | |
| 407 | template <int Count> |
| 408 | class NonTypeTemplateParam |
| 409 | { |
| 410 | public: |
| 411 | void size() const |
| 412 | { |
| 413 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 414 | } |
| 415 | }; |
| 416 | |
| 417 | template <typename T> |
| 418 | class SpecializedClassTemplate |
| 419 | { |
| 420 | public: |
| 421 | template <typename U> |
| 422 | void memberFunctionTemplate(T t, U u) const |
| 423 | { |
| 424 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 425 | } |
| 426 | }; |
| 427 | |
| 428 | template <> |
| 429 | class SpecializedClassTemplate<int> |
| 430 | { |
| 431 | public: |
| 432 | template <typename U> |
| 433 | void memberFunctionTemplate(int i, U u) const |
| 434 | { |
| 435 | printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__); |
| 436 | } |
| 437 | }; |
| 438 | |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 439 | int main() { |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 440 | ClassInAnonymousNamespace anonymousNamespace; |
| 441 | anonymousNamespace.anonymousNamespaceFunction(); |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 442 | |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 443 | ClassInTopLevelNamespace topLevelNamespace; |
| 444 | topLevelNamespace.topLevelNamespaceFunction(); |
| 445 | |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 446 | NS::Base::staticFunction(); |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 447 | |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 448 | NS::Base b; |
| 449 | b.inlineFunction(); |
| 450 | b.virtualFunction(); |
| 451 | b.variadicFunction(0); |
| 452 | b.functionWithParameters(0, 0, 0); |
| 453 | b.functionReturningClass(); |
| 454 | |
| 455 | b.withTemplateParameter1(NS::ClassTemplate<int>()); |
| 456 | b.withTemplateParameter2(NS::ClassTemplate<NS::Base *>()); |
| 457 | b.functionReturingTemplate1(); |
| 458 | b.functionReturingTemplate2(); |
| 459 | b.functionTemplate1<int>(0); |
| 460 | b.functionTemplate1<NS::Base *>(0); |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 461 | b.constFunction(); |
| 462 | b.volatileFunction(); |
| 463 | b.constVolatileFunction(); |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 464 | b.refQualifiedFunction(); |
| 465 | NS::Base().refQualifiedFunction(); |
Sam Weinig | 4eadcc5 | 2009-12-27 01:38:20 +0000 | [diff] [blame] | 466 | |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 467 | NS::Derived d; |
| 468 | d.virtualFunction(); |
| 469 | |
| 470 | NS::ClassTemplate<int> t1; |
| 471 | t1.classTemplateFunction(); |
| 472 | NS::ClassTemplate<NS::Base *> t2; |
| 473 | t2.classTemplateFunction(); |
| 474 | |
| 475 | NS::Constructor c1; |
| 476 | NS::Constructor c2(0); |
| 477 | NS::Constructor c3((NS::Base *)0); |
| 478 | |
| 479 | { |
| 480 | NS::Destructor destructor; |
| 481 | } |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 482 | |
| 483 | NS::ContainerForAnonymousRecords anonymous; |
| 484 | anonymous.anonymousClass.anonymousClassFunction(); |
| 485 | anonymous.anonymousStruct.anonymousStructFunction(); |
| 486 | anonymous.anonymousUnion.anonymousUnionFunction(); |
| 487 | |
Sam Weinig | 3521d01 | 2009-12-28 03:19:38 +0000 | [diff] [blame] | 488 | NS::localClass(0); |
| 489 | |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 490 | NS::externFunction(); |
Sam Weinig | 6be1120 | 2009-12-24 23:15:03 +0000 | [diff] [blame] | 491 | |
Douglas Gregor | abf65ce | 2012-04-10 20:14:15 +0000 | [diff] [blame] | 492 | // additional tests for __PRETTY_FUNCTION__ |
| 493 | |
| 494 | functionTemplateWithTwoParams(0, 0.0f); |
| 495 | functionTemplateWithoutParameterList<double>(); |
| 496 | functionTemplateWithTemplateReturnType<char>(); |
| 497 | int array[] = { 1, 2, 3 }; |
| 498 | functionTemplateWithCompoundTypes(array); |
| 499 | functionTemplateExplicitSpecialization(0); |
| 500 | functionTemplateExplicitSpecialization(0.0); |
| 501 | functionTemplateWithUnnamedTemplateParameter<int, float>(0.0f); |
| 502 | |
| 503 | OuterClass<int *>::MiddleClass::InnerClass<float> omi; |
| 504 | omi.memberFunction(0, 0.0f); |
| 505 | |
| 506 | ClassWithTemplateTemplateParam<char>::staticMember(); |
| 507 | |
| 508 | NonTypeTemplateParam<42> ntt; |
| 509 | ntt.size(); |
| 510 | |
| 511 | SpecializedClassTemplate<int> sct1; |
| 512 | sct1.memberFunctionTemplate(0, 0.0f); |
| 513 | SpecializedClassTemplate<char> sct2; |
| 514 | sct2.memberFunctionTemplate('0', 0.0); |
| 515 | |
Anders Carlsson | 3a082d8 | 2009-09-08 18:24:21 +0000 | [diff] [blame] | 516 | return 0; |
| 517 | } |