Sebastian Redl | 06a59bb | 2009-10-23 22:13:42 +0000 | [diff] [blame] | 1 | //===--- DeclTemplate.cpp - Template Declaration AST Node Implementation --===// |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the C++ related Decl classes for templates. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/AST/DeclCXX.h" |
| 15 | #include "clang/AST/DeclTemplate.h" |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 16 | #include "clang/AST/Expr.h" |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 17 | #include "clang/AST/ASTContext.h" |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 18 | #include "clang/AST/TypeLoc.h" |
Argyrios Kyrtzidis | bef1a7b | 2010-10-28 07:38:42 +0000 | [diff] [blame] | 19 | #include "clang/AST/ASTMutationListener.h" |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 20 | #include "clang/Basic/IdentifierTable.h" |
| 21 | #include "llvm/ADT/STLExtras.h" |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 22 | #include <memory> |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 23 | using namespace clang; |
| 24 | |
| 25 | //===----------------------------------------------------------------------===// |
| 26 | // TemplateParameterList Implementation |
| 27 | //===----------------------------------------------------------------------===// |
| 28 | |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 29 | TemplateParameterList::TemplateParameterList(SourceLocation TemplateLoc, |
| 30 | SourceLocation LAngleLoc, |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 31 | NamedDecl **Params, unsigned NumParams, |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 32 | SourceLocation RAngleLoc) |
| 33 | : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc), |
| 34 | NumParams(NumParams) { |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 35 | for (unsigned Idx = 0; Idx < NumParams; ++Idx) |
| 36 | begin()[Idx] = Params[Idx]; |
| 37 | } |
| 38 | |
| 39 | TemplateParameterList * |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 40 | TemplateParameterList::Create(ASTContext &C, SourceLocation TemplateLoc, |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 41 | SourceLocation LAngleLoc, NamedDecl **Params, |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 42 | unsigned NumParams, SourceLocation RAngleLoc) { |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 43 | unsigned Size = sizeof(TemplateParameterList) |
| 44 | + sizeof(NamedDecl *) * NumParams; |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 45 | unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment; |
| 46 | void *Mem = C.Allocate(Size, Align); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 47 | return new (Mem) TemplateParameterList(TemplateLoc, LAngleLoc, Params, |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 48 | NumParams, RAngleLoc); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 51 | unsigned TemplateParameterList::getMinRequiredArguments() const { |
| 52 | unsigned NumRequiredArgs = size(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 53 | iterator Param = const_cast<TemplateParameterList *>(this)->end(), |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 54 | ParamBegin = const_cast<TemplateParameterList *>(this)->begin(); |
| 55 | while (Param != ParamBegin) { |
| 56 | --Param; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 57 | |
Anders Carlsson | 0ceffb5 | 2009-06-13 02:08:00 +0000 | [diff] [blame] | 58 | if (!(*Param)->isTemplateParameterPack() && |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 59 | !(isa<TemplateTypeParmDecl>(*Param) && |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 60 | cast<TemplateTypeParmDecl>(*Param)->hasDefaultArgument()) && |
| 61 | !(isa<NonTypeTemplateParmDecl>(*Param) && |
| 62 | cast<NonTypeTemplateParmDecl>(*Param)->hasDefaultArgument()) && |
| 63 | !(isa<TemplateTemplateParmDecl>(*Param) && |
| 64 | cast<TemplateTemplateParmDecl>(*Param)->hasDefaultArgument())) |
| 65 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 66 | |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 67 | --NumRequiredArgs; |
| 68 | } |
| 69 | |
| 70 | return NumRequiredArgs; |
| 71 | } |
| 72 | |
Douglas Gregor | ed9c0f9 | 2009-10-29 00:04:11 +0000 | [diff] [blame] | 73 | unsigned TemplateParameterList::getDepth() const { |
| 74 | if (size() == 0) |
| 75 | return 0; |
| 76 | |
| 77 | const NamedDecl *FirstParm = getParam(0); |
| 78 | if (const TemplateTypeParmDecl *TTP |
| 79 | = dyn_cast<TemplateTypeParmDecl>(FirstParm)) |
| 80 | return TTP->getDepth(); |
| 81 | else if (const NonTypeTemplateParmDecl *NTTP |
| 82 | = dyn_cast<NonTypeTemplateParmDecl>(FirstParm)) |
| 83 | return NTTP->getDepth(); |
| 84 | else |
| 85 | return cast<TemplateTemplateParmDecl>(FirstParm)->getDepth(); |
| 86 | } |
| 87 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 88 | //===----------------------------------------------------------------------===// |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 89 | // RedeclarableTemplateDecl Implementation |
| 90 | //===----------------------------------------------------------------------===// |
| 91 | |
| 92 | RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() { |
| 93 | // Find the first declaration of this function template. |
| 94 | RedeclarableTemplateDecl *First = getCanonicalDecl(); |
| 95 | |
| 96 | if (First->CommonOrPrev.isNull()) { |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 97 | CommonBase *CommonPtr = First->newCommon(getASTContext()); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 98 | First->CommonOrPrev = CommonPtr; |
Peter Collingbourne | 8a798a7 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 99 | CommonPtr->Latest = First; |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 100 | } |
| 101 | return First->CommonOrPrev.get<CommonBase*>(); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | RedeclarableTemplateDecl *RedeclarableTemplateDecl::getCanonicalDeclImpl() { |
| 106 | RedeclarableTemplateDecl *Tmpl = this; |
| 107 | while (Tmpl->getPreviousDeclaration()) |
| 108 | Tmpl = Tmpl->getPreviousDeclaration(); |
| 109 | return Tmpl; |
| 110 | } |
| 111 | |
Peter Collingbourne | 8a798a7 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 112 | void RedeclarableTemplateDecl::setPreviousDeclarationImpl( |
| 113 | RedeclarableTemplateDecl *Prev) { |
| 114 | if (Prev) { |
| 115 | CommonBase *Common = Prev->getCommonPtr(); |
| 116 | Prev = Common->Latest; |
| 117 | Common->Latest = this; |
| 118 | CommonOrPrev = Prev; |
| 119 | } else { |
| 120 | assert(CommonOrPrev.is<CommonBase*>() && "Cannot reset TemplateDecl Prev"); |
| 121 | } |
| 122 | } |
| 123 | |
Peter Collingbourne | f88718e | 2010-07-29 16:12:09 +0000 | [diff] [blame] | 124 | RedeclarableTemplateDecl *RedeclarableTemplateDecl::getNextRedeclaration() { |
| 125 | if (CommonOrPrev.is<RedeclarableTemplateDecl*>()) |
| 126 | return CommonOrPrev.get<RedeclarableTemplateDecl*>(); |
| 127 | CommonBase *Common = CommonOrPrev.get<CommonBase*>(); |
| 128 | return Common ? Common->Latest : this; |
| 129 | } |
| 130 | |
Peter Collingbourne | 4048590 | 2010-07-30 17:09:04 +0000 | [diff] [blame] | 131 | template <class EntryType> |
| 132 | typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType* |
| 133 | RedeclarableTemplateDecl::findSpecializationImpl( |
| 134 | llvm::FoldingSet<EntryType> &Specs, |
| 135 | const TemplateArgument *Args, unsigned NumArgs, |
| 136 | void *&InsertPos) { |
| 137 | typedef SpecEntryTraits<EntryType> SETraits; |
| 138 | llvm::FoldingSetNodeID ID; |
| 139 | EntryType::Profile(ID,Args,NumArgs, getASTContext()); |
| 140 | EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos); |
| 141 | return Entry ? SETraits::getMostRecentDeclaration(Entry) : 0; |
| 142 | } |
| 143 | |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 144 | //===----------------------------------------------------------------------===// |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 145 | // FunctionTemplateDecl Implementation |
| 146 | //===----------------------------------------------------------------------===// |
| 147 | |
Douglas Gregor | 0054531 | 2010-05-23 18:26:36 +0000 | [diff] [blame] | 148 | void FunctionTemplateDecl::DeallocateCommon(void *Ptr) { |
| 149 | static_cast<Common *>(Ptr)->~Common(); |
| 150 | } |
| 151 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 152 | FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C, |
| 153 | DeclContext *DC, |
| 154 | SourceLocation L, |
| 155 | DeclarationName Name, |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 156 | TemplateParameterList *Params, |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 157 | NamedDecl *Decl) { |
| 158 | return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl); |
| 159 | } |
| 160 | |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 161 | RedeclarableTemplateDecl::CommonBase * |
| 162 | FunctionTemplateDecl::newCommon(ASTContext &C) { |
| 163 | Common *CommonPtr = new (C) Common; |
| 164 | C.AddDeallocation(DeallocateCommon, CommonPtr); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 165 | return CommonPtr; |
| 166 | } |
| 167 | |
Argyrios Kyrtzidis | 2c853e4 | 2010-07-20 13:59:58 +0000 | [diff] [blame] | 168 | FunctionDecl * |
| 169 | FunctionTemplateDecl::findSpecialization(const TemplateArgument *Args, |
| 170 | unsigned NumArgs, void *&InsertPos) { |
Peter Collingbourne | 4048590 | 2010-07-30 17:09:04 +0000 | [diff] [blame] | 171 | return findSpecializationImpl(getSpecializations(), Args, NumArgs, InsertPos); |
Argyrios Kyrtzidis | 2c853e4 | 2010-07-20 13:59:58 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 174 | //===----------------------------------------------------------------------===// |
| 175 | // ClassTemplateDecl Implementation |
| 176 | //===----------------------------------------------------------------------===// |
| 177 | |
Douglas Gregor | 0054531 | 2010-05-23 18:26:36 +0000 | [diff] [blame] | 178 | void ClassTemplateDecl::DeallocateCommon(void *Ptr) { |
| 179 | static_cast<Common *>(Ptr)->~Common(); |
| 180 | } |
| 181 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 182 | ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, |
| 183 | DeclContext *DC, |
| 184 | SourceLocation L, |
| 185 | DeclarationName Name, |
| 186 | TemplateParameterList *Params, |
Douglas Gregor | 5953d8b | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 187 | NamedDecl *Decl, |
| 188 | ClassTemplateDecl *PrevDecl) { |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 189 | ClassTemplateDecl *New = new (C) ClassTemplateDecl(DC, L, Name, Params, Decl); |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame] | 190 | New->setPreviousDeclaration(PrevDecl); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 191 | return New; |
Douglas Gregor | 5953d8b | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Douglas Gregor | c8e5cf8 | 2010-10-27 22:21:36 +0000 | [diff] [blame] | 194 | void ClassTemplateDecl::LoadLazySpecializations() { |
| 195 | Common *CommonPtr = getCommonPtr(); |
| 196 | if (CommonPtr->LazySpecializations) { |
| 197 | ASTContext &Context = getASTContext(); |
| 198 | uint32_t *Specs = CommonPtr->LazySpecializations; |
| 199 | CommonPtr->LazySpecializations = 0; |
| 200 | for (uint32_t I = 0, N = *Specs++; I != N; ++I) |
| 201 | (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | llvm::FoldingSet<ClassTemplateSpecializationDecl> & |
| 206 | ClassTemplateDecl::getSpecializations() { |
| 207 | LoadLazySpecializations(); |
| 208 | return getCommonPtr()->Specializations; |
| 209 | } |
| 210 | |
| 211 | llvm::FoldingSet<ClassTemplatePartialSpecializationDecl> & |
| 212 | ClassTemplateDecl::getPartialSpecializations() { |
| 213 | LoadLazySpecializations(); |
| 214 | return getCommonPtr()->PartialSpecializations; |
| 215 | } |
| 216 | |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 217 | RedeclarableTemplateDecl::CommonBase * |
| 218 | ClassTemplateDecl::newCommon(ASTContext &C) { |
| 219 | Common *CommonPtr = new (C) Common; |
| 220 | C.AddDeallocation(DeallocateCommon, CommonPtr); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 221 | return CommonPtr; |
| 222 | } |
| 223 | |
Argyrios Kyrtzidis | cc0b1bc | 2010-07-20 13:59:28 +0000 | [diff] [blame] | 224 | ClassTemplateSpecializationDecl * |
| 225 | ClassTemplateDecl::findSpecialization(const TemplateArgument *Args, |
| 226 | unsigned NumArgs, void *&InsertPos) { |
Peter Collingbourne | 4048590 | 2010-07-30 17:09:04 +0000 | [diff] [blame] | 227 | return findSpecializationImpl(getSpecializations(), Args, NumArgs, InsertPos); |
Argyrios Kyrtzidis | cc0b1bc | 2010-07-20 13:59:28 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Argyrios Kyrtzidis | bef1a7b | 2010-10-28 07:38:42 +0000 | [diff] [blame] | 230 | void ClassTemplateDecl::AddSpecialization(ClassTemplateSpecializationDecl *D, |
| 231 | void *InsertPos) { |
| 232 | getSpecializations().InsertNode(D, InsertPos); |
| 233 | if (ASTMutationListener *L = getASTMutationListener()) |
| 234 | L->AddedCXXTemplateSpecialization(this, D); |
| 235 | } |
| 236 | |
Argyrios Kyrtzidis | cc0b1bc | 2010-07-20 13:59:28 +0000 | [diff] [blame] | 237 | ClassTemplatePartialSpecializationDecl * |
| 238 | ClassTemplateDecl::findPartialSpecialization(const TemplateArgument *Args, |
| 239 | unsigned NumArgs, |
| 240 | void *&InsertPos) { |
Peter Collingbourne | 4048590 | 2010-07-30 17:09:04 +0000 | [diff] [blame] | 241 | return findSpecializationImpl(getPartialSpecializations(), Args, NumArgs, |
| 242 | InsertPos); |
Argyrios Kyrtzidis | cc0b1bc | 2010-07-20 13:59:28 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Argyrios Kyrtzidis | bef1a7b | 2010-10-28 07:38:42 +0000 | [diff] [blame] | 245 | void ClassTemplateDecl::AddPartialSpecialization( |
| 246 | ClassTemplatePartialSpecializationDecl *D, |
| 247 | void *InsertPos) { |
| 248 | getPartialSpecializations().InsertNode(D, InsertPos); |
| 249 | if (ASTMutationListener *L = getASTMutationListener()) |
| 250 | L->AddedCXXTemplateSpecialization(this, D); |
| 251 | } |
| 252 | |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 253 | void ClassTemplateDecl::getPartialSpecializations( |
| 254 | llvm::SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) { |
| 255 | llvm::FoldingSet<ClassTemplatePartialSpecializationDecl> &PartialSpecs |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame] | 256 | = getPartialSpecializations(); |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 257 | PS.clear(); |
| 258 | PS.resize(PartialSpecs.size()); |
| 259 | for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator |
| 260 | P = PartialSpecs.begin(), PEnd = PartialSpecs.end(); |
| 261 | P != PEnd; ++P) { |
| 262 | assert(!PS[P->getSequenceNumber()]); |
Argyrios Kyrtzidis | cc0b1bc | 2010-07-20 13:59:28 +0000 | [diff] [blame] | 263 | PS[P->getSequenceNumber()] = P->getMostRecentDeclaration(); |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 264 | } |
| 265 | } |
| 266 | |
Douglas Gregor | b88e888 | 2009-07-30 17:40:51 +0000 | [diff] [blame] | 267 | ClassTemplatePartialSpecializationDecl * |
| 268 | ClassTemplateDecl::findPartialSpecialization(QualType T) { |
| 269 | ASTContext &Context = getASTContext(); |
| 270 | typedef llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator |
| 271 | partial_spec_iterator; |
| 272 | for (partial_spec_iterator P = getPartialSpecializations().begin(), |
| 273 | PEnd = getPartialSpecializations().end(); |
| 274 | P != PEnd; ++P) { |
John McCall | 31f17ec | 2010-04-27 00:57:59 +0000 | [diff] [blame] | 275 | if (Context.hasSameType(P->getInjectedSpecializationType(), T)) |
Argyrios Kyrtzidis | cc0b1bc | 2010-07-20 13:59:28 +0000 | [diff] [blame] | 276 | return P->getMostRecentDeclaration(); |
| 277 | } |
| 278 | |
| 279 | return 0; |
| 280 | } |
| 281 | |
| 282 | ClassTemplatePartialSpecializationDecl * |
| 283 | ClassTemplateDecl::findPartialSpecInstantiatedFromMember( |
| 284 | ClassTemplatePartialSpecializationDecl *D) { |
| 285 | Decl *DCanon = D->getCanonicalDecl(); |
| 286 | for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator |
| 287 | P = getPartialSpecializations().begin(), |
| 288 | PEnd = getPartialSpecializations().end(); |
| 289 | P != PEnd; ++P) { |
| 290 | if (P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon) |
| 291 | return P->getMostRecentDeclaration(); |
Douglas Gregor | b88e888 | 2009-07-30 17:40:51 +0000 | [diff] [blame] | 292 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 293 | |
Douglas Gregor | b88e888 | 2009-07-30 17:40:51 +0000 | [diff] [blame] | 294 | return 0; |
| 295 | } |
| 296 | |
John McCall | 3cb0ebd | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 297 | QualType |
Douglas Gregor | 24bae92 | 2010-07-08 18:37:38 +0000 | [diff] [blame] | 298 | ClassTemplateDecl::getInjectedClassNameSpecialization() { |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame] | 299 | Common *CommonPtr = getCommonPtr(); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 300 | if (!CommonPtr->InjectedClassNameType.isNull()) |
| 301 | return CommonPtr->InjectedClassNameType; |
| 302 | |
| 303 | // FIXME: n2800 14.6.1p1 should say how the template arguments |
| 304 | // corresponding to template parameter packs should be pack |
| 305 | // expansions. We already say that in 14.6.2.1p2, so it would be |
| 306 | // better to fix that redundancy. |
Douglas Gregor | 24bae92 | 2010-07-08 18:37:38 +0000 | [diff] [blame] | 307 | ASTContext &Context = getASTContext(); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 308 | TemplateParameterList *Params = getTemplateParameters(); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 309 | llvm::SmallVector<TemplateArgument, 16> TemplateArgs; |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 310 | TemplateArgs.reserve(Params->size()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 311 | for (TemplateParameterList::iterator Param = Params->begin(), |
| 312 | ParamEnd = Params->end(); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 313 | Param != ParamEnd; ++Param) { |
| 314 | if (isa<TemplateTypeParmDecl>(*Param)) { |
| 315 | QualType ParamType = Context.getTypeDeclType(cast<TypeDecl>(*Param)); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 316 | TemplateArgs.push_back(TemplateArgument(ParamType)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 317 | } else if (NonTypeTemplateParmDecl *NTTP = |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 318 | dyn_cast<NonTypeTemplateParmDecl>(*Param)) { |
Chandler Carruth | b7de181 | 2010-01-31 07:24:03 +0000 | [diff] [blame] | 319 | Expr *E = new (Context) DeclRefExpr(NTTP, |
Douglas Gregor | 6398235 | 2010-07-13 18:40:04 +0000 | [diff] [blame] | 320 | NTTP->getType().getNonLValueExprType(Context), |
Douglas Gregor | 0da76df | 2009-11-23 11:41:28 +0000 | [diff] [blame] | 321 | NTTP->getLocation()); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 322 | TemplateArgs.push_back(TemplateArgument(E)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 323 | } else { |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 324 | TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(*Param); |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 325 | TemplateArgs.push_back(TemplateArgument(TemplateName(TTP))); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 329 | CommonPtr->InjectedClassNameType |
Douglas Gregor | 1275ae0 | 2009-07-28 23:00:59 +0000 | [diff] [blame] | 330 | = Context.getTemplateSpecializationType(TemplateName(this), |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 331 | &TemplateArgs[0], |
Douglas Gregor | 1275ae0 | 2009-07-28 23:00:59 +0000 | [diff] [blame] | 332 | TemplateArgs.size()); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 333 | return CommonPtr->InjectedClassNameType; |
| 334 | } |
| 335 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 336 | //===----------------------------------------------------------------------===// |
| 337 | // TemplateTypeParm Allocation/Deallocation Method Implementations |
| 338 | //===----------------------------------------------------------------------===// |
| 339 | |
| 340 | TemplateTypeParmDecl * |
| 341 | TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC, |
| 342 | SourceLocation L, unsigned D, unsigned P, |
Anders Carlsson | 6d845ae | 2009-06-12 22:23:22 +0000 | [diff] [blame] | 343 | IdentifierInfo *Id, bool Typename, |
| 344 | bool ParameterPack) { |
Douglas Gregor | efed5c8 | 2010-06-16 15:23:05 +0000 | [diff] [blame] | 345 | QualType Type = C.getTemplateTypeParmType(D, P, ParameterPack, Id); |
| 346 | return new (C) TemplateTypeParmDecl(DC, L, Id, Typename, Type, ParameterPack); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 347 | } |
| 348 | |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 349 | TemplateTypeParmDecl * |
| 350 | TemplateTypeParmDecl::Create(ASTContext &C, EmptyShell Empty) { |
| 351 | return new (C) TemplateTypeParmDecl(0, SourceLocation(), 0, false, |
| 352 | QualType(), false); |
| 353 | } |
| 354 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 355 | SourceLocation TemplateTypeParmDecl::getDefaultArgumentLoc() const { |
Abramo Bagnara | bd054db | 2010-05-20 10:00:11 +0000 | [diff] [blame] | 356 | return DefaultArgument->getTypeLoc().getSourceRange().getBegin(); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 357 | } |
| 358 | |
Douglas Gregor | ed9c0f9 | 2009-10-29 00:04:11 +0000 | [diff] [blame] | 359 | unsigned TemplateTypeParmDecl::getDepth() const { |
| 360 | return TypeForDecl->getAs<TemplateTypeParmType>()->getDepth(); |
| 361 | } |
| 362 | |
| 363 | unsigned TemplateTypeParmDecl::getIndex() const { |
| 364 | return TypeForDecl->getAs<TemplateTypeParmType>()->getIndex(); |
| 365 | } |
| 366 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 367 | //===----------------------------------------------------------------------===// |
| 368 | // NonTypeTemplateParmDecl Method Implementations |
| 369 | //===----------------------------------------------------------------------===// |
| 370 | |
| 371 | NonTypeTemplateParmDecl * |
| 372 | NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, |
| 373 | SourceLocation L, unsigned D, unsigned P, |
| 374 | IdentifierInfo *Id, QualType T, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 375 | TypeSourceInfo *TInfo) { |
| 376 | return new (C) NonTypeTemplateParmDecl(DC, L, D, P, Id, T, TInfo); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 377 | } |
| 378 | |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 379 | SourceLocation NonTypeTemplateParmDecl::getDefaultArgumentLoc() const { |
Abramo Bagnara | d92f7a2 | 2010-06-09 09:26:05 +0000 | [diff] [blame] | 380 | return hasDefaultArgument() |
| 381 | ? getDefaultArgument()->getSourceRange().getBegin() |
| 382 | : SourceLocation(); |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 383 | } |
| 384 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 385 | //===----------------------------------------------------------------------===// |
| 386 | // TemplateTemplateParmDecl Method Implementations |
| 387 | //===----------------------------------------------------------------------===// |
| 388 | |
| 389 | TemplateTemplateParmDecl * |
| 390 | TemplateTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, |
| 391 | SourceLocation L, unsigned D, unsigned P, |
| 392 | IdentifierInfo *Id, |
| 393 | TemplateParameterList *Params) { |
| 394 | return new (C) TemplateTemplateParmDecl(DC, L, D, P, Id, Params); |
| 395 | } |
| 396 | |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 397 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 398 | // TemplateArgumentList Implementation |
| 399 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 400 | TemplateArgumentList * |
| 401 | TemplateArgumentList::CreateCopy(ASTContext &Context, |
| 402 | const TemplateArgument *Args, |
| 403 | unsigned NumArgs) { |
| 404 | std::size_t Size = sizeof(TemplateArgumentList) |
| 405 | + NumArgs * sizeof(TemplateArgument); |
| 406 | void *Mem = Context.Allocate(Size); |
| 407 | TemplateArgument *StoredArgs |
| 408 | = reinterpret_cast<TemplateArgument *>( |
| 409 | static_cast<TemplateArgumentList *>(Mem) + 1); |
| 410 | std::uninitialized_copy(Args, Args + NumArgs, StoredArgs); |
| 411 | return new (Mem) TemplateArgumentList(StoredArgs, NumArgs, true); |
Argyrios Kyrtzidis | 94d228d | 2010-06-23 13:48:23 +0000 | [diff] [blame] | 412 | } |
| 413 | |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 414 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 415 | // ClassTemplateSpecializationDecl Implementation |
| 416 | //===----------------------------------------------------------------------===// |
| 417 | ClassTemplateSpecializationDecl:: |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 418 | ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 419 | DeclContext *DC, SourceLocation L, |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 420 | ClassTemplateDecl *SpecializedTemplate, |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 421 | const TemplateArgument *Args, |
| 422 | unsigned NumArgs, |
Douglas Gregor | 8e9e9ef | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 423 | ClassTemplateSpecializationDecl *PrevDecl) |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 424 | : CXXRecordDecl(DK, TK, DC, L, |
Douglas Gregor | 8e9e9ef | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 425 | SpecializedTemplate->getIdentifier(), |
| 426 | PrevDecl), |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 427 | SpecializedTemplate(SpecializedTemplate), |
Abramo Bagnara | c98971d | 2010-06-12 07:44:57 +0000 | [diff] [blame] | 428 | ExplicitInfo(0), |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 429 | TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args, NumArgs)), |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 430 | SpecializationKind(TSK_Undeclared) { |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 431 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 432 | |
Argyrios Kyrtzidis | 94d228d | 2010-06-23 13:48:23 +0000 | [diff] [blame] | 433 | ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(Kind DK) |
| 434 | : CXXRecordDecl(DK, TTK_Struct, 0, SourceLocation(), 0, 0), |
| 435 | ExplicitInfo(0), |
| 436 | SpecializationKind(TSK_Undeclared) { |
| 437 | } |
| 438 | |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 439 | ClassTemplateSpecializationDecl * |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 440 | ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK, |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 441 | DeclContext *DC, SourceLocation L, |
| 442 | ClassTemplateDecl *SpecializedTemplate, |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 443 | const TemplateArgument *Args, |
| 444 | unsigned NumArgs, |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 445 | ClassTemplateSpecializationDecl *PrevDecl) { |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 446 | ClassTemplateSpecializationDecl *Result |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 447 | = new (Context)ClassTemplateSpecializationDecl(Context, |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 448 | ClassTemplateSpecialization, |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 449 | TK, DC, L, |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 450 | SpecializedTemplate, |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 451 | Args, NumArgs, |
Douglas Gregor | 8e9e9ef | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 452 | PrevDecl); |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 453 | Context.getTypeDeclType(Result, PrevDecl); |
| 454 | return Result; |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 455 | } |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 456 | |
Argyrios Kyrtzidis | 94d228d | 2010-06-23 13:48:23 +0000 | [diff] [blame] | 457 | ClassTemplateSpecializationDecl * |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 458 | ClassTemplateSpecializationDecl::Create(ASTContext &Context, EmptyShell Empty) { |
Argyrios Kyrtzidis | 94d228d | 2010-06-23 13:48:23 +0000 | [diff] [blame] | 459 | return |
| 460 | new (Context)ClassTemplateSpecializationDecl(ClassTemplateSpecialization); |
| 461 | } |
| 462 | |
John McCall | 136a698 | 2009-09-11 06:45:03 +0000 | [diff] [blame] | 463 | void |
| 464 | ClassTemplateSpecializationDecl::getNameForDiagnostic(std::string &S, |
| 465 | const PrintingPolicy &Policy, |
| 466 | bool Qualified) const { |
| 467 | NamedDecl::getNameForDiagnostic(S, Policy, Qualified); |
| 468 | |
| 469 | const TemplateArgumentList &TemplateArgs = getTemplateArgs(); |
| 470 | S += TemplateSpecializationType::PrintTemplateArgumentList( |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 471 | TemplateArgs.data(), |
| 472 | TemplateArgs.size(), |
John McCall | 136a698 | 2009-09-11 06:45:03 +0000 | [diff] [blame] | 473 | Policy); |
| 474 | } |
| 475 | |
Douglas Gregor | 37d93e9 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 476 | ClassTemplateDecl * |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 477 | ClassTemplateSpecializationDecl::getSpecializedTemplate() const { |
| 478 | if (SpecializedPartialSpecialization *PartialSpec |
Douglas Gregor | 37d93e9 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 479 | = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>()) |
| 480 | return PartialSpec->PartialSpecialization->getSpecializedTemplate(); |
| 481 | return SpecializedTemplate.get<ClassTemplateDecl*>(); |
| 482 | } |
| 483 | |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 484 | //===----------------------------------------------------------------------===// |
| 485 | // ClassTemplatePartialSpecializationDecl Implementation |
| 486 | //===----------------------------------------------------------------------===// |
| 487 | ClassTemplatePartialSpecializationDecl * |
| 488 | ClassTemplatePartialSpecializationDecl:: |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 489 | Create(ASTContext &Context, TagKind TK,DeclContext *DC, SourceLocation L, |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 490 | TemplateParameterList *Params, |
| 491 | ClassTemplateDecl *SpecializedTemplate, |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 492 | const TemplateArgument *Args, |
| 493 | unsigned NumArgs, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 494 | const TemplateArgumentListInfo &ArgInfos, |
John McCall | 3cb0ebd | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 495 | QualType CanonInjectedType, |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 496 | ClassTemplatePartialSpecializationDecl *PrevDecl, |
| 497 | unsigned SequenceNumber) { |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 498 | unsigned N = ArgInfos.size(); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 499 | TemplateArgumentLoc *ClonedArgs = new (Context) TemplateArgumentLoc[N]; |
| 500 | for (unsigned I = 0; I != N; ++I) |
| 501 | ClonedArgs[I] = ArgInfos[I]; |
| 502 | |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 503 | ClassTemplatePartialSpecializationDecl *Result |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 504 | = new (Context)ClassTemplatePartialSpecializationDecl(Context, TK, |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 505 | DC, L, Params, |
| 506 | SpecializedTemplate, |
Douglas Gregor | 910f800 | 2010-11-07 23:05:16 +0000 | [diff] [blame] | 507 | Args, NumArgs, |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 508 | ClonedArgs, N, |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 509 | PrevDecl, |
| 510 | SequenceNumber); |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 511 | Result->setSpecializationKind(TSK_ExplicitSpecialization); |
John McCall | 3cb0ebd | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 512 | |
| 513 | Context.getInjectedClassNameType(Result, CanonInjectedType); |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 514 | return Result; |
| 515 | } |
John McCall | dd4a3b0 | 2009-09-16 22:47:08 +0000 | [diff] [blame] | 516 | |
Argyrios Kyrtzidis | 94d228d | 2010-06-23 13:48:23 +0000 | [diff] [blame] | 517 | ClassTemplatePartialSpecializationDecl * |
Argyrios Kyrtzidis | b8b03e6 | 2010-07-02 11:54:55 +0000 | [diff] [blame] | 518 | ClassTemplatePartialSpecializationDecl::Create(ASTContext &Context, |
| 519 | EmptyShell Empty) { |
Argyrios Kyrtzidis | 94d228d | 2010-06-23 13:48:23 +0000 | [diff] [blame] | 520 | return new (Context)ClassTemplatePartialSpecializationDecl(); |
| 521 | } |
| 522 | |
John McCall | dd4a3b0 | 2009-09-16 22:47:08 +0000 | [diff] [blame] | 523 | //===----------------------------------------------------------------------===// |
| 524 | // FriendTemplateDecl Implementation |
| 525 | //===----------------------------------------------------------------------===// |
| 526 | |
| 527 | FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context, |
| 528 | DeclContext *DC, |
| 529 | SourceLocation L, |
| 530 | unsigned NParams, |
| 531 | TemplateParameterList **Params, |
| 532 | FriendUnion Friend, |
| 533 | SourceLocation FLoc) { |
| 534 | FriendTemplateDecl *Result |
| 535 | = new (Context) FriendTemplateDecl(DC, L, NParams, Params, Friend, FLoc); |
| 536 | return Result; |
| 537 | } |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 538 | |
| 539 | FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context, |
| 540 | EmptyShell Empty) { |
| 541 | return new (Context) FriendTemplateDecl(Empty); |
| 542 | } |