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" |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 19 | #include "clang/Basic/IdentifierTable.h" |
| 20 | #include "llvm/ADT/STLExtras.h" |
| 21 | using namespace clang; |
| 22 | |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | // TemplateParameterList Implementation |
| 25 | //===----------------------------------------------------------------------===// |
| 26 | |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 27 | TemplateParameterList::TemplateParameterList(SourceLocation TemplateLoc, |
| 28 | SourceLocation LAngleLoc, |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 29 | NamedDecl **Params, unsigned NumParams, |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 30 | SourceLocation RAngleLoc) |
| 31 | : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc), |
| 32 | NumParams(NumParams) { |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 33 | for (unsigned Idx = 0; Idx < NumParams; ++Idx) |
| 34 | begin()[Idx] = Params[Idx]; |
| 35 | } |
| 36 | |
| 37 | TemplateParameterList * |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 38 | TemplateParameterList::Create(ASTContext &C, SourceLocation TemplateLoc, |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 39 | SourceLocation LAngleLoc, NamedDecl **Params, |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 40 | unsigned NumParams, SourceLocation RAngleLoc) { |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 41 | unsigned Size = sizeof(TemplateParameterList) |
| 42 | + sizeof(NamedDecl *) * NumParams; |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 43 | unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment; |
| 44 | void *Mem = C.Allocate(Size, Align); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 45 | return new (Mem) TemplateParameterList(TemplateLoc, LAngleLoc, Params, |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 46 | NumParams, RAngleLoc); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 49 | unsigned TemplateParameterList::getMinRequiredArguments() const { |
| 50 | unsigned NumRequiredArgs = size(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 51 | iterator Param = const_cast<TemplateParameterList *>(this)->end(), |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 52 | ParamBegin = const_cast<TemplateParameterList *>(this)->begin(); |
| 53 | while (Param != ParamBegin) { |
| 54 | --Param; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 55 | |
Anders Carlsson | 0ceffb5 | 2009-06-13 02:08:00 +0000 | [diff] [blame] | 56 | if (!(*Param)->isTemplateParameterPack() && |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 57 | !(isa<TemplateTypeParmDecl>(*Param) && |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 58 | cast<TemplateTypeParmDecl>(*Param)->hasDefaultArgument()) && |
| 59 | !(isa<NonTypeTemplateParmDecl>(*Param) && |
| 60 | cast<NonTypeTemplateParmDecl>(*Param)->hasDefaultArgument()) && |
| 61 | !(isa<TemplateTemplateParmDecl>(*Param) && |
| 62 | cast<TemplateTemplateParmDecl>(*Param)->hasDefaultArgument())) |
| 63 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 64 | |
Douglas Gregor | 62cb18d | 2009-02-11 18:16:40 +0000 | [diff] [blame] | 65 | --NumRequiredArgs; |
| 66 | } |
| 67 | |
| 68 | return NumRequiredArgs; |
| 69 | } |
| 70 | |
Douglas Gregor | ed9c0f9 | 2009-10-29 00:04:11 +0000 | [diff] [blame] | 71 | unsigned TemplateParameterList::getDepth() const { |
| 72 | if (size() == 0) |
| 73 | return 0; |
| 74 | |
| 75 | const NamedDecl *FirstParm = getParam(0); |
| 76 | if (const TemplateTypeParmDecl *TTP |
| 77 | = dyn_cast<TemplateTypeParmDecl>(FirstParm)) |
| 78 | return TTP->getDepth(); |
| 79 | else if (const NonTypeTemplateParmDecl *NTTP |
| 80 | = dyn_cast<NonTypeTemplateParmDecl>(FirstParm)) |
| 81 | return NTTP->getDepth(); |
| 82 | else |
| 83 | return cast<TemplateTemplateParmDecl>(FirstParm)->getDepth(); |
| 84 | } |
| 85 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 86 | //===----------------------------------------------------------------------===// |
| 87 | // TemplateDecl Implementation |
| 88 | //===----------------------------------------------------------------------===// |
| 89 | |
| 90 | TemplateDecl::~TemplateDecl() { |
| 91 | } |
| 92 | |
| 93 | //===----------------------------------------------------------------------===// |
| 94 | // FunctionTemplateDecl Implementation |
| 95 | //===----------------------------------------------------------------------===// |
| 96 | |
Douglas Gregor | 0054531 | 2010-05-23 18:26:36 +0000 | [diff] [blame] | 97 | void FunctionTemplateDecl::DeallocateCommon(void *Ptr) { |
| 98 | static_cast<Common *>(Ptr)->~Common(); |
| 99 | } |
| 100 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 101 | FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C, |
| 102 | DeclContext *DC, |
| 103 | SourceLocation L, |
| 104 | DeclarationName Name, |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 105 | TemplateParameterList *Params, |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 106 | NamedDecl *Decl) { |
| 107 | return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl); |
| 108 | } |
| 109 | |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 110 | void FunctionTemplateDecl::Destroy(ASTContext &C) { |
| 111 | if (Common *CommonPtr = CommonOrPrev.dyn_cast<Common*>()) { |
| 112 | for (llvm::FoldingSet<FunctionTemplateSpecializationInfo>::iterator |
| 113 | Spec = CommonPtr->Specializations.begin(), |
| 114 | SpecEnd = CommonPtr->Specializations.end(); |
| 115 | Spec != SpecEnd; ++Spec) |
| 116 | C.Deallocate(&*Spec); |
| 117 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 118 | |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 119 | Decl::Destroy(C); |
| 120 | } |
| 121 | |
Argyrios Kyrtzidis | b57a4fe | 2009-07-18 00:34:07 +0000 | [diff] [blame] | 122 | FunctionTemplateDecl *FunctionTemplateDecl::getCanonicalDecl() { |
| 123 | FunctionTemplateDecl *FunTmpl = this; |
| 124 | while (FunTmpl->getPreviousDeclaration()) |
| 125 | FunTmpl = FunTmpl->getPreviousDeclaration(); |
| 126 | return FunTmpl; |
| 127 | } |
| 128 | |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 129 | FunctionTemplateDecl::Common *FunctionTemplateDecl::getCommonPtr() { |
| 130 | // Find the first declaration of this function template. |
| 131 | FunctionTemplateDecl *First = this; |
| 132 | while (First->getPreviousDeclaration()) |
| 133 | First = First->getPreviousDeclaration(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 134 | |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 135 | if (First->CommonOrPrev.isNull()) { |
Douglas Gregor | 0054531 | 2010-05-23 18:26:36 +0000 | [diff] [blame] | 136 | Common *CommonPtr = new (getASTContext()) Common; |
| 137 | getASTContext().AddDeallocation(DeallocateCommon, CommonPtr); |
| 138 | First->CommonOrPrev = CommonPtr; |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 139 | } |
| 140 | return First->CommonOrPrev.get<Common*>(); |
| 141 | } |
| 142 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 143 | //===----------------------------------------------------------------------===// |
| 144 | // ClassTemplateDecl Implementation |
| 145 | //===----------------------------------------------------------------------===// |
| 146 | |
Douglas Gregor | 0054531 | 2010-05-23 18:26:36 +0000 | [diff] [blame] | 147 | void ClassTemplateDecl::DeallocateCommon(void *Ptr) { |
| 148 | static_cast<Common *>(Ptr)->~Common(); |
| 149 | } |
| 150 | |
Argyrios Kyrtzidis | b57a4fe | 2009-07-18 00:34:07 +0000 | [diff] [blame] | 151 | ClassTemplateDecl *ClassTemplateDecl::getCanonicalDecl() { |
| 152 | ClassTemplateDecl *Template = this; |
| 153 | while (Template->getPreviousDeclaration()) |
| 154 | Template = Template->getPreviousDeclaration(); |
| 155 | return Template; |
| 156 | } |
| 157 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 158 | ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, |
| 159 | DeclContext *DC, |
| 160 | SourceLocation L, |
| 161 | DeclarationName Name, |
| 162 | TemplateParameterList *Params, |
Douglas Gregor | 5953d8b | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 163 | NamedDecl *Decl, |
| 164 | ClassTemplateDecl *PrevDecl) { |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 165 | ClassTemplateDecl *New = new (C) ClassTemplateDecl(DC, L, Name, Params, Decl); |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame^] | 166 | New->setPreviousDeclaration(PrevDecl); |
Argyrios Kyrtzidis | 8731ca7 | 2010-06-19 19:29:09 +0000 | [diff] [blame] | 167 | return New; |
Douglas Gregor | 5953d8b | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Douglas Gregor | 5953d8b | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 170 | void ClassTemplateDecl::Destroy(ASTContext& C) { |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame^] | 171 | Decl::Destroy(C); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 174 | void ClassTemplateDecl::getPartialSpecializations( |
| 175 | llvm::SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS) { |
| 176 | llvm::FoldingSet<ClassTemplatePartialSpecializationDecl> &PartialSpecs |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame^] | 177 | = getPartialSpecializations(); |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 178 | PS.clear(); |
| 179 | PS.resize(PartialSpecs.size()); |
| 180 | for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator |
| 181 | P = PartialSpecs.begin(), PEnd = PartialSpecs.end(); |
| 182 | P != PEnd; ++P) { |
| 183 | assert(!PS[P->getSequenceNumber()]); |
| 184 | PS[P->getSequenceNumber()] = &*P; |
| 185 | } |
| 186 | } |
| 187 | |
Douglas Gregor | b88e888 | 2009-07-30 17:40:51 +0000 | [diff] [blame] | 188 | ClassTemplatePartialSpecializationDecl * |
| 189 | ClassTemplateDecl::findPartialSpecialization(QualType T) { |
| 190 | ASTContext &Context = getASTContext(); |
| 191 | typedef llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator |
| 192 | partial_spec_iterator; |
| 193 | for (partial_spec_iterator P = getPartialSpecializations().begin(), |
| 194 | PEnd = getPartialSpecializations().end(); |
| 195 | P != PEnd; ++P) { |
John McCall | 31f17ec | 2010-04-27 00:57:59 +0000 | [diff] [blame] | 196 | if (Context.hasSameType(P->getInjectedSpecializationType(), T)) |
Douglas Gregor | b88e888 | 2009-07-30 17:40:51 +0000 | [diff] [blame] | 197 | return &*P; |
| 198 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 199 | |
Douglas Gregor | b88e888 | 2009-07-30 17:40:51 +0000 | [diff] [blame] | 200 | return 0; |
| 201 | } |
| 202 | |
John McCall | 3cb0ebd | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 203 | QualType |
| 204 | ClassTemplateDecl::getInjectedClassNameSpecialization(ASTContext &Context) { |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame^] | 205 | Common *CommonPtr = getCommonPtr(); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 206 | if (!CommonPtr->InjectedClassNameType.isNull()) |
| 207 | return CommonPtr->InjectedClassNameType; |
| 208 | |
| 209 | // FIXME: n2800 14.6.1p1 should say how the template arguments |
| 210 | // corresponding to template parameter packs should be pack |
| 211 | // expansions. We already say that in 14.6.2.1p2, so it would be |
| 212 | // better to fix that redundancy. |
| 213 | |
| 214 | TemplateParameterList *Params = getTemplateParameters(); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 215 | llvm::SmallVector<TemplateArgument, 16> TemplateArgs; |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 216 | TemplateArgs.reserve(Params->size()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 217 | for (TemplateParameterList::iterator Param = Params->begin(), |
| 218 | ParamEnd = Params->end(); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 219 | Param != ParamEnd; ++Param) { |
| 220 | if (isa<TemplateTypeParmDecl>(*Param)) { |
| 221 | QualType ParamType = Context.getTypeDeclType(cast<TypeDecl>(*Param)); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 222 | TemplateArgs.push_back(TemplateArgument(ParamType)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 223 | } else if (NonTypeTemplateParmDecl *NTTP = |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 224 | dyn_cast<NonTypeTemplateParmDecl>(*Param)) { |
Chandler Carruth | b7de181 | 2010-01-31 07:24:03 +0000 | [diff] [blame] | 225 | Expr *E = new (Context) DeclRefExpr(NTTP, |
| 226 | NTTP->getType().getNonReferenceType(), |
Douglas Gregor | 0da76df | 2009-11-23 11:41:28 +0000 | [diff] [blame] | 227 | NTTP->getLocation()); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 228 | TemplateArgs.push_back(TemplateArgument(E)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 229 | } else { |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 230 | TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(*Param); |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 231 | TemplateArgs.push_back(TemplateArgument(TemplateName(TTP))); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 235 | CommonPtr->InjectedClassNameType |
Douglas Gregor | 1275ae0 | 2009-07-28 23:00:59 +0000 | [diff] [blame] | 236 | = Context.getTemplateSpecializationType(TemplateName(this), |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 237 | &TemplateArgs[0], |
Douglas Gregor | 1275ae0 | 2009-07-28 23:00:59 +0000 | [diff] [blame] | 238 | TemplateArgs.size()); |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 239 | return CommonPtr->InjectedClassNameType; |
| 240 | } |
| 241 | |
Argyrios Kyrtzidis | 5bf1bdc | 2010-06-21 10:57:41 +0000 | [diff] [blame^] | 242 | ClassTemplateDecl::Common *ClassTemplateDecl::getCommonPtr() { |
| 243 | // Find the first declaration of this function template. |
| 244 | ClassTemplateDecl *First = this; |
| 245 | while (First->getPreviousDeclaration()) |
| 246 | First = First->getPreviousDeclaration(); |
| 247 | |
| 248 | if (First->CommonOrPrev.isNull()) { |
| 249 | Common *CommonPtr = new (getASTContext()) Common; |
| 250 | getASTContext().AddDeallocation(DeallocateCommon, CommonPtr); |
| 251 | First->CommonOrPrev = CommonPtr; |
| 252 | } |
| 253 | return First->CommonOrPrev.get<Common*>(); |
| 254 | } |
| 255 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 256 | //===----------------------------------------------------------------------===// |
| 257 | // TemplateTypeParm Allocation/Deallocation Method Implementations |
| 258 | //===----------------------------------------------------------------------===// |
| 259 | |
| 260 | TemplateTypeParmDecl * |
| 261 | TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC, |
| 262 | SourceLocation L, unsigned D, unsigned P, |
Anders Carlsson | 6d845ae | 2009-06-12 22:23:22 +0000 | [diff] [blame] | 263 | IdentifierInfo *Id, bool Typename, |
| 264 | bool ParameterPack) { |
Douglas Gregor | efed5c8 | 2010-06-16 15:23:05 +0000 | [diff] [blame] | 265 | QualType Type = C.getTemplateTypeParmType(D, P, ParameterPack, Id); |
| 266 | return new (C) TemplateTypeParmDecl(DC, L, Id, Typename, Type, ParameterPack); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 267 | } |
| 268 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 269 | SourceLocation TemplateTypeParmDecl::getDefaultArgumentLoc() const { |
Abramo Bagnara | bd054db | 2010-05-20 10:00:11 +0000 | [diff] [blame] | 270 | return DefaultArgument->getTypeLoc().getSourceRange().getBegin(); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 271 | } |
| 272 | |
Douglas Gregor | ed9c0f9 | 2009-10-29 00:04:11 +0000 | [diff] [blame] | 273 | unsigned TemplateTypeParmDecl::getDepth() const { |
| 274 | return TypeForDecl->getAs<TemplateTypeParmType>()->getDepth(); |
| 275 | } |
| 276 | |
| 277 | unsigned TemplateTypeParmDecl::getIndex() const { |
| 278 | return TypeForDecl->getAs<TemplateTypeParmType>()->getIndex(); |
| 279 | } |
| 280 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 281 | //===----------------------------------------------------------------------===// |
| 282 | // NonTypeTemplateParmDecl Method Implementations |
| 283 | //===----------------------------------------------------------------------===// |
| 284 | |
| 285 | NonTypeTemplateParmDecl * |
| 286 | NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, |
| 287 | SourceLocation L, unsigned D, unsigned P, |
| 288 | IdentifierInfo *Id, QualType T, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 289 | TypeSourceInfo *TInfo) { |
| 290 | return new (C) NonTypeTemplateParmDecl(DC, L, D, P, Id, T, TInfo); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 291 | } |
| 292 | |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 293 | SourceLocation NonTypeTemplateParmDecl::getDefaultArgumentLoc() const { |
Abramo Bagnara | d92f7a2 | 2010-06-09 09:26:05 +0000 | [diff] [blame] | 294 | return hasDefaultArgument() |
| 295 | ? getDefaultArgument()->getSourceRange().getBegin() |
| 296 | : SourceLocation(); |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 299 | //===----------------------------------------------------------------------===// |
| 300 | // TemplateTemplateParmDecl Method Implementations |
| 301 | //===----------------------------------------------------------------------===// |
| 302 | |
| 303 | TemplateTemplateParmDecl * |
| 304 | TemplateTemplateParmDecl::Create(ASTContext &C, DeclContext *DC, |
| 305 | SourceLocation L, unsigned D, unsigned P, |
| 306 | IdentifierInfo *Id, |
| 307 | TemplateParameterList *Params) { |
| 308 | return new (C) TemplateTemplateParmDecl(DC, L, D, P, Id, Params); |
| 309 | } |
| 310 | |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 311 | //===----------------------------------------------------------------------===// |
Anders Carlsson | 9ba4164 | 2009-06-05 05:31:27 +0000 | [diff] [blame] | 312 | // TemplateArgumentListBuilder Implementation |
| 313 | //===----------------------------------------------------------------------===// |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 314 | |
Chris Lattner | 98d279b | 2010-05-20 00:25:36 +0000 | [diff] [blame] | 315 | void TemplateArgumentListBuilder::Append(const TemplateArgument &Arg) { |
| 316 | assert((Arg.getKind() != TemplateArgument::Type || |
| 317 | Arg.getAsType().isCanonical()) && "Type must be canonical!"); |
| 318 | assert(FlatArgs.size() < MaxFlatArgs && "Argument list builder is full!"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 319 | assert(!StructuredArgs && |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 320 | "Can't append arguments when an argument pack has been added!"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 321 | |
Chris Lattner | 98d279b | 2010-05-20 00:25:36 +0000 | [diff] [blame] | 322 | FlatArgs.push_back(Arg); |
Anders Carlsson | 9ba4164 | 2009-06-05 05:31:27 +0000 | [diff] [blame] | 323 | } |
| 324 | |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 325 | void TemplateArgumentListBuilder::BeginPack() { |
| 326 | assert(!AddingToPack && "Already adding to pack!"); |
| 327 | assert(!StructuredArgs && "Argument list already contains a pack!"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 328 | |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 329 | AddingToPack = true; |
Chris Lattner | 98d279b | 2010-05-20 00:25:36 +0000 | [diff] [blame] | 330 | PackBeginIndex = FlatArgs.size(); |
Anders Carlsson | 67e3320 | 2009-06-13 00:08:58 +0000 | [diff] [blame] | 331 | } |
| 332 | |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 333 | void TemplateArgumentListBuilder::EndPack() { |
| 334 | assert(AddingToPack && "Not adding to pack!"); |
| 335 | assert(!StructuredArgs && "Argument list already contains a pack!"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 336 | |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 337 | AddingToPack = false; |
Anders Carlsson | 3b36b66 | 2009-06-15 17:56:45 +0000 | [diff] [blame] | 338 | |
Chris Lattner | 304d0fa | 2010-05-20 00:26:28 +0000 | [diff] [blame] | 339 | // FIXME: This is a memory leak! |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 340 | StructuredArgs = new TemplateArgument[MaxStructuredArgs]; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 341 | |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 342 | // First copy the flat entries over to the list (if any) |
| 343 | for (unsigned I = 0; I != PackBeginIndex; ++I) { |
| 344 | NumStructuredArgs++; |
| 345 | StructuredArgs[I] = FlatArgs[I]; |
| 346 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 347 | |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 348 | // Next, set the pack. |
| 349 | TemplateArgument *PackArgs = 0; |
| 350 | unsigned NumPackArgs = NumFlatArgs - PackBeginIndex; |
Chris Lattner | 98d279b | 2010-05-20 00:25:36 +0000 | [diff] [blame] | 351 | // FIXME: NumPackArgs shouldn't be negative here??? |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 352 | if (NumPackArgs) |
Chris Lattner | 98d279b | 2010-05-20 00:25:36 +0000 | [diff] [blame] | 353 | PackArgs = FlatArgs.data()+PackBeginIndex; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 354 | |
| 355 | StructuredArgs[NumStructuredArgs++].setArgumentPack(PackArgs, NumPackArgs, |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 356 | /*CopyArgs=*/false); |
| 357 | } |
| 358 | |
Anders Carlsson | 9ba4164 | 2009-06-05 05:31:27 +0000 | [diff] [blame] | 359 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 360 | // TemplateArgumentList Implementation |
| 361 | //===----------------------------------------------------------------------===// |
| 362 | TemplateArgumentList::TemplateArgumentList(ASTContext &Context, |
Anders Carlsson | e9c904b | 2009-06-05 04:47:51 +0000 | [diff] [blame] | 363 | TemplateArgumentListBuilder &Builder, |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 364 | bool TakeArgs) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 365 | : FlatArguments(Builder.getFlatArguments(), TakeArgs), |
| 366 | NumFlatArguments(Builder.flatSize()), |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 367 | StructuredArguments(Builder.getStructuredArguments(), TakeArgs), |
| 368 | NumStructuredArguments(Builder.structuredSize()) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 369 | |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 370 | if (!TakeArgs) |
| 371 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 372 | |
Chris Lattner | 56ef550 | 2010-05-20 00:11:47 +0000 | [diff] [blame] | 373 | // If this does take ownership of the arguments, then we have to new them |
| 374 | // and copy over. |
Ted Kremenek | 3458d43 | 2010-05-25 20:43:29 +0000 | [diff] [blame] | 375 | TemplateArgument *NewArgs = |
| 376 | new (Context) TemplateArgument[Builder.flatSize()]; |
Chris Lattner | 56ef550 | 2010-05-20 00:11:47 +0000 | [diff] [blame] | 377 | std::copy(Builder.getFlatArguments(), |
| 378 | Builder.getFlatArguments()+Builder.flatSize(), NewArgs); |
| 379 | FlatArguments.setPointer(NewArgs); |
| 380 | |
| 381 | // Just reuse the structured and flat arguments array if possible. |
| 382 | if (Builder.getStructuredArguments() == Builder.getFlatArguments()) { |
| 383 | StructuredArguments.setPointer(NewArgs); |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 384 | StructuredArguments.setInt(0); |
Chris Lattner | 56ef550 | 2010-05-20 00:11:47 +0000 | [diff] [blame] | 385 | } else { |
Ted Kremenek | 3458d43 | 2010-05-25 20:43:29 +0000 | [diff] [blame] | 386 | TemplateArgument *NewSArgs = |
| 387 | new (Context) TemplateArgument[Builder.flatSize()]; |
Chris Lattner | 56ef550 | 2010-05-20 00:11:47 +0000 | [diff] [blame] | 388 | std::copy(Builder.getFlatArguments(), |
| 389 | Builder.getFlatArguments()+Builder.flatSize(), NewSArgs); |
| 390 | StructuredArguments.setPointer(NewSArgs); |
| 391 | } |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Chris Lattner | 8859891 | 2010-05-20 00:19:09 +0000 | [diff] [blame] | 394 | /// Produces a shallow copy of the given template argument list. This |
| 395 | /// assumes that the input argument list outlives it. This takes the list as |
| 396 | /// a pointer to avoid looking like a copy constructor, since this really |
| 397 | /// really isn't safe to use that way. |
| 398 | TemplateArgumentList::TemplateArgumentList(const TemplateArgumentList *Other) |
| 399 | : FlatArguments(Other->FlatArguments.getPointer(), false), |
| 400 | NumFlatArguments(Other->flat_size()), |
| 401 | StructuredArguments(Other->StructuredArguments.getPointer(), false), |
| 402 | NumStructuredArguments(Other->NumStructuredArguments) { } |
Douglas Gregor | b9aa6b2 | 2009-09-24 23:14:47 +0000 | [diff] [blame] | 403 | |
Ted Kremenek | 3458d43 | 2010-05-25 20:43:29 +0000 | [diff] [blame] | 404 | void TemplateArgumentList::Destroy(ASTContext &C) { |
Chris Lattner | 56ef550 | 2010-05-20 00:11:47 +0000 | [diff] [blame] | 405 | if (FlatArguments.getInt()) |
Ted Kremenek | 3458d43 | 2010-05-25 20:43:29 +0000 | [diff] [blame] | 406 | C.Deallocate((void*)FlatArguments.getPointer()); |
Chris Lattner | 56ef550 | 2010-05-20 00:11:47 +0000 | [diff] [blame] | 407 | if (StructuredArguments.getInt()) |
Ted Kremenek | 3458d43 | 2010-05-25 20:43:29 +0000 | [diff] [blame] | 408 | C.Deallocate((void*)StructuredArguments.getPointer()); |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 409 | } |
| 410 | |
Ted Kremenek | 3458d43 | 2010-05-25 20:43:29 +0000 | [diff] [blame] | 411 | TemplateArgumentList::~TemplateArgumentList() {} |
| 412 | |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 413 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 414 | // ClassTemplateSpecializationDecl Implementation |
| 415 | //===----------------------------------------------------------------------===// |
| 416 | ClassTemplateSpecializationDecl:: |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 417 | ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 418 | DeclContext *DC, SourceLocation L, |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 419 | ClassTemplateDecl *SpecializedTemplate, |
Douglas Gregor | 8e9e9ef | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 420 | TemplateArgumentListBuilder &Builder, |
| 421 | ClassTemplateSpecializationDecl *PrevDecl) |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 422 | : CXXRecordDecl(DK, TK, DC, L, |
Douglas Gregor | 8e9e9ef | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 423 | SpecializedTemplate->getIdentifier(), |
| 424 | PrevDecl), |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 425 | SpecializedTemplate(SpecializedTemplate), |
Abramo Bagnara | c98971d | 2010-06-12 07:44:57 +0000 | [diff] [blame] | 426 | ExplicitInfo(0), |
Anders Carlsson | fb25052 | 2009-06-23 01:26:57 +0000 | [diff] [blame] | 427 | TemplateArgs(Context, Builder, /*TakeArgs=*/true), |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 428 | SpecializationKind(TSK_Undeclared) { |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 429 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 430 | |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 431 | ClassTemplateSpecializationDecl * |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 432 | ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK, |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 433 | DeclContext *DC, SourceLocation L, |
| 434 | ClassTemplateDecl *SpecializedTemplate, |
Anders Carlsson | 91fdf6f | 2009-06-05 04:06:48 +0000 | [diff] [blame] | 435 | TemplateArgumentListBuilder &Builder, |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 436 | ClassTemplateSpecializationDecl *PrevDecl) { |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 437 | ClassTemplateSpecializationDecl *Result |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 438 | = new (Context)ClassTemplateSpecializationDecl(Context, |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 439 | ClassTemplateSpecialization, |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 440 | TK, DC, L, |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 441 | SpecializedTemplate, |
Douglas Gregor | 8e9e9ef | 2009-07-29 23:36:44 +0000 | [diff] [blame] | 442 | Builder, |
| 443 | PrevDecl); |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 444 | Context.getTypeDeclType(Result, PrevDecl); |
| 445 | return Result; |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 446 | } |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 447 | |
Douglas Gregor | 37d93e9 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 448 | void ClassTemplateSpecializationDecl::Destroy(ASTContext &C) { |
Abramo Bagnara | c98971d | 2010-06-12 07:44:57 +0000 | [diff] [blame] | 449 | delete ExplicitInfo; |
| 450 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 451 | if (SpecializedPartialSpecialization *PartialSpec |
Douglas Gregor | 37d93e9 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 452 | = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>()) |
| 453 | C.Deallocate(PartialSpec); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 454 | |
Douglas Gregor | 37d93e9 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 455 | CXXRecordDecl::Destroy(C); |
| 456 | } |
| 457 | |
John McCall | 136a698 | 2009-09-11 06:45:03 +0000 | [diff] [blame] | 458 | void |
| 459 | ClassTemplateSpecializationDecl::getNameForDiagnostic(std::string &S, |
| 460 | const PrintingPolicy &Policy, |
| 461 | bool Qualified) const { |
| 462 | NamedDecl::getNameForDiagnostic(S, Policy, Qualified); |
| 463 | |
| 464 | const TemplateArgumentList &TemplateArgs = getTemplateArgs(); |
| 465 | S += TemplateSpecializationType::PrintTemplateArgumentList( |
| 466 | TemplateArgs.getFlatArgumentList(), |
| 467 | TemplateArgs.flat_size(), |
| 468 | Policy); |
| 469 | } |
| 470 | |
Douglas Gregor | 37d93e9 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 471 | ClassTemplateDecl * |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 472 | ClassTemplateSpecializationDecl::getSpecializedTemplate() const { |
| 473 | if (SpecializedPartialSpecialization *PartialSpec |
Douglas Gregor | 37d93e9 | 2009-08-02 23:24:31 +0000 | [diff] [blame] | 474 | = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>()) |
| 475 | return PartialSpec->PartialSpecialization->getSpecializedTemplate(); |
| 476 | return SpecializedTemplate.get<ClassTemplateDecl*>(); |
| 477 | } |
| 478 | |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 479 | //===----------------------------------------------------------------------===// |
| 480 | // ClassTemplatePartialSpecializationDecl Implementation |
| 481 | //===----------------------------------------------------------------------===// |
| 482 | ClassTemplatePartialSpecializationDecl * |
| 483 | ClassTemplatePartialSpecializationDecl:: |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 484 | Create(ASTContext &Context, TagKind TK,DeclContext *DC, SourceLocation L, |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 485 | TemplateParameterList *Params, |
| 486 | ClassTemplateDecl *SpecializedTemplate, |
Anders Carlsson | 91fdf6f | 2009-06-05 04:06:48 +0000 | [diff] [blame] | 487 | TemplateArgumentListBuilder &Builder, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 488 | const TemplateArgumentListInfo &ArgInfos, |
John McCall | 3cb0ebd | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 489 | QualType CanonInjectedType, |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 490 | ClassTemplatePartialSpecializationDecl *PrevDecl, |
| 491 | unsigned SequenceNumber) { |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 492 | unsigned N = ArgInfos.size(); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 493 | TemplateArgumentLoc *ClonedArgs = new (Context) TemplateArgumentLoc[N]; |
| 494 | for (unsigned I = 0; I != N; ++I) |
| 495 | ClonedArgs[I] = ArgInfos[I]; |
| 496 | |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 497 | ClassTemplatePartialSpecializationDecl *Result |
Douglas Gregor | 13c8577 | 2010-05-06 00:28:52 +0000 | [diff] [blame] | 498 | = new (Context)ClassTemplatePartialSpecializationDecl(Context, TK, |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 499 | DC, L, Params, |
| 500 | SpecializedTemplate, |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 501 | Builder, |
| 502 | ClonedArgs, N, |
Douglas Gregor | dc60c1e | 2010-04-30 05:56:50 +0000 | [diff] [blame] | 503 | PrevDecl, |
| 504 | SequenceNumber); |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 505 | Result->setSpecializationKind(TSK_ExplicitSpecialization); |
John McCall | 3cb0ebd | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 506 | |
| 507 | Context.getInjectedClassNameType(Result, CanonInjectedType); |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 508 | return Result; |
| 509 | } |
John McCall | dd4a3b0 | 2009-09-16 22:47:08 +0000 | [diff] [blame] | 510 | |
| 511 | //===----------------------------------------------------------------------===// |
| 512 | // FriendTemplateDecl Implementation |
| 513 | //===----------------------------------------------------------------------===// |
| 514 | |
| 515 | FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context, |
| 516 | DeclContext *DC, |
| 517 | SourceLocation L, |
| 518 | unsigned NParams, |
| 519 | TemplateParameterList **Params, |
| 520 | FriendUnion Friend, |
| 521 | SourceLocation FLoc) { |
| 522 | FriendTemplateDecl *Result |
| 523 | = new (Context) FriendTemplateDecl(DC, L, NParams, Params, Friend, FLoc); |
| 524 | return Result; |
| 525 | } |