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