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