Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 1 | //===------- SemaTemplateInstantiate.cpp - C++ Template Instantiation ------===/ |
| 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 | // This file implements C++ template instantiation. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===/ |
| 12 | |
| 13 | #include "Sema.h" |
Douglas Gregor | dc18e89 | 2009-05-26 20:50:29 +0000 | [diff] [blame^] | 14 | #include "clang/AST/ASTConsumer.h" |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 15 | #include "clang/AST/ASTContext.h" |
| 16 | #include "clang/AST/Expr.h" |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclTemplate.h" |
| 18 | #include "clang/Parse/DeclSpec.h" |
| 19 | #include "clang/Basic/LangOptions.h" |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Compiler.h" |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace clang; |
| 23 | |
Douglas Gregor | fee85d6 | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 24 | //===----------------------------------------------------------------------===/ |
| 25 | // Template Instantiation Support |
| 26 | //===----------------------------------------------------------------------===/ |
| 27 | |
Douglas Gregor | 5f62c5e | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 28 | /// \brief Retrieve the template argument list that should be used to |
| 29 | /// instantiate the given declaration. |
| 30 | const TemplateArgumentList & |
| 31 | Sema::getTemplateInstantiationArgs(NamedDecl *D) { |
| 32 | if (ClassTemplateSpecializationDecl *Spec |
| 33 | = dyn_cast<ClassTemplateSpecializationDecl>(D)) |
| 34 | return Spec->getTemplateArgs(); |
| 35 | |
| 36 | DeclContext *EnclosingTemplateCtx = D->getDeclContext(); |
| 37 | while (!isa<ClassTemplateSpecializationDecl>(EnclosingTemplateCtx)) { |
| 38 | assert(!EnclosingTemplateCtx->isFileContext() && |
| 39 | "Tried to get the instantiation arguments of a non-template"); |
| 40 | EnclosingTemplateCtx = EnclosingTemplateCtx->getParent(); |
| 41 | } |
| 42 | |
| 43 | ClassTemplateSpecializationDecl *EnclosingTemplate |
| 44 | = cast<ClassTemplateSpecializationDecl>(EnclosingTemplateCtx); |
| 45 | return EnclosingTemplate->getTemplateArgs(); |
| 46 | } |
| 47 | |
Douglas Gregor | 375733c | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 48 | Sema::InstantiatingTemplate:: |
| 49 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 50 | Decl *Entity, |
Douglas Gregor | 375733c | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 51 | SourceRange InstantiationRange) |
| 52 | : SemaRef(SemaRef) { |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 53 | |
| 54 | Invalid = CheckInstantiationDepth(PointOfInstantiation, |
| 55 | InstantiationRange); |
| 56 | if (!Invalid) { |
Douglas Gregor | 375733c | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 57 | ActiveTemplateInstantiation Inst; |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 58 | Inst.Kind = ActiveTemplateInstantiation::TemplateInstantiation; |
Douglas Gregor | 375733c | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 59 | Inst.PointOfInstantiation = PointOfInstantiation; |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 60 | Inst.Entity = reinterpret_cast<uintptr_t>(Entity); |
Douglas Gregor | 95ba128 | 2009-03-12 18:36:18 +0000 | [diff] [blame] | 61 | Inst.TemplateArgs = 0; |
| 62 | Inst.NumTemplateArgs = 0; |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 63 | Inst.InstantiationRange = InstantiationRange; |
| 64 | SemaRef.ActiveTemplateInstantiations.push_back(Inst); |
| 65 | Invalid = false; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef, |
| 70 | SourceLocation PointOfInstantiation, |
| 71 | TemplateDecl *Template, |
| 72 | const TemplateArgument *TemplateArgs, |
| 73 | unsigned NumTemplateArgs, |
| 74 | SourceRange InstantiationRange) |
| 75 | : SemaRef(SemaRef) { |
| 76 | |
| 77 | Invalid = CheckInstantiationDepth(PointOfInstantiation, |
| 78 | InstantiationRange); |
| 79 | if (!Invalid) { |
| 80 | ActiveTemplateInstantiation Inst; |
| 81 | Inst.Kind |
| 82 | = ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation; |
| 83 | Inst.PointOfInstantiation = PointOfInstantiation; |
| 84 | Inst.Entity = reinterpret_cast<uintptr_t>(Template); |
| 85 | Inst.TemplateArgs = TemplateArgs; |
| 86 | Inst.NumTemplateArgs = NumTemplateArgs; |
Douglas Gregor | 375733c | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 87 | Inst.InstantiationRange = InstantiationRange; |
| 88 | SemaRef.ActiveTemplateInstantiations.push_back(Inst); |
| 89 | Invalid = false; |
| 90 | } |
| 91 | } |
| 92 | |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 93 | void Sema::InstantiatingTemplate::Clear() { |
| 94 | if (!Invalid) { |
Douglas Gregor | 375733c | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 95 | SemaRef.ActiveTemplateInstantiations.pop_back(); |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 96 | Invalid = true; |
| 97 | } |
Douglas Gregor | 375733c | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 98 | } |
| 99 | |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 100 | bool Sema::InstantiatingTemplate::CheckInstantiationDepth( |
| 101 | SourceLocation PointOfInstantiation, |
| 102 | SourceRange InstantiationRange) { |
| 103 | if (SemaRef.ActiveTemplateInstantiations.size() |
| 104 | <= SemaRef.getLangOptions().InstantiationDepth) |
| 105 | return false; |
| 106 | |
| 107 | SemaRef.Diag(PointOfInstantiation, |
| 108 | diag::err_template_recursion_depth_exceeded) |
| 109 | << SemaRef.getLangOptions().InstantiationDepth |
| 110 | << InstantiationRange; |
| 111 | SemaRef.Diag(PointOfInstantiation, diag::note_template_recursion_depth) |
| 112 | << SemaRef.getLangOptions().InstantiationDepth; |
| 113 | return true; |
| 114 | } |
| 115 | |
Douglas Gregor | fee85d6 | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 116 | /// \brief Prints the current instantiation stack through a series of |
| 117 | /// notes. |
| 118 | void Sema::PrintInstantiationStack() { |
| 119 | for (llvm::SmallVector<ActiveTemplateInstantiation, 16>::reverse_iterator |
| 120 | Active = ActiveTemplateInstantiations.rbegin(), |
| 121 | ActiveEnd = ActiveTemplateInstantiations.rend(); |
| 122 | Active != ActiveEnd; |
| 123 | ++Active) { |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 124 | switch (Active->Kind) { |
| 125 | case ActiveTemplateInstantiation::TemplateInstantiation: { |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 126 | Decl *D = reinterpret_cast<Decl *>(Active->Entity); |
| 127 | if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) { |
| 128 | unsigned DiagID = diag::note_template_member_class_here; |
| 129 | if (isa<ClassTemplateSpecializationDecl>(Record)) |
| 130 | DiagID = diag::note_template_class_instantiation_here; |
| 131 | Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr), |
| 132 | DiagID) |
| 133 | << Context.getTypeDeclType(Record) |
| 134 | << Active->InstantiationRange; |
| 135 | } else { |
| 136 | FunctionDecl *Function = cast<FunctionDecl>(D); |
| 137 | unsigned DiagID = diag::note_template_member_function_here; |
| 138 | // FIXME: check for a function template |
| 139 | Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr), |
| 140 | DiagID) |
| 141 | << Function |
| 142 | << Active->InstantiationRange; |
| 143 | } |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 144 | break; |
| 145 | } |
| 146 | |
| 147 | case ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation: { |
| 148 | TemplateDecl *Template = cast<TemplateDecl>((Decl *)Active->Entity); |
| 149 | std::string TemplateArgsStr |
Douglas Gregor | dd13e84 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 150 | = TemplateSpecializationType::PrintTemplateArgumentList( |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 151 | Active->TemplateArgs, |
| 152 | Active->NumTemplateArgs); |
| 153 | Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr), |
| 154 | diag::note_default_arg_instantiation_here) |
| 155 | << (Template->getNameAsString() + TemplateArgsStr) |
| 156 | << Active->InstantiationRange; |
| 157 | break; |
| 158 | } |
| 159 | } |
Douglas Gregor | fee85d6 | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 163 | //===----------------------------------------------------------------------===/ |
| 164 | // Template Instantiation for Types |
| 165 | //===----------------------------------------------------------------------===/ |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 166 | namespace { |
| 167 | class VISIBILITY_HIDDEN TemplateTypeInstantiator { |
| 168 | Sema &SemaRef; |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 169 | const TemplateArgumentList &TemplateArgs; |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 170 | SourceLocation Loc; |
| 171 | DeclarationName Entity; |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 172 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 173 | public: |
| 174 | TemplateTypeInstantiator(Sema &SemaRef, |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 175 | const TemplateArgumentList &TemplateArgs, |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 176 | SourceLocation Loc, |
| 177 | DeclarationName Entity) |
| 178 | : SemaRef(SemaRef), TemplateArgs(TemplateArgs), |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 179 | Loc(Loc), Entity(Entity) { } |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 180 | |
| 181 | QualType operator()(QualType T) const { return Instantiate(T); } |
| 182 | |
| 183 | QualType Instantiate(QualType T) const; |
| 184 | |
| 185 | // Declare instantiate functions for each type. |
| 186 | #define TYPE(Class, Base) \ |
| 187 | QualType Instantiate##Class##Type(const Class##Type *T, \ |
| 188 | unsigned Quals) const; |
| 189 | #define ABSTRACT_TYPE(Class, Base) |
| 190 | #include "clang/AST/TypeNodes.def" |
| 191 | }; |
| 192 | } |
| 193 | |
| 194 | QualType |
| 195 | TemplateTypeInstantiator::InstantiateExtQualType(const ExtQualType *T, |
| 196 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 197 | // FIXME: Implement this |
| 198 | assert(false && "Cannot instantiate ExtQualType yet"); |
| 199 | return QualType(); |
| 200 | } |
| 201 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 202 | QualType |
| 203 | TemplateTypeInstantiator::InstantiateBuiltinType(const BuiltinType *T, |
| 204 | unsigned Quals) const { |
Douglas Gregor | c0139ca | 2009-02-28 01:04:19 +0000 | [diff] [blame] | 205 | assert(false && "Builtin types are not dependent and cannot be instantiated"); |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 206 | return QualType(T, Quals); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 209 | QualType |
| 210 | TemplateTypeInstantiator:: |
| 211 | InstantiateFixedWidthIntType(const FixedWidthIntType *T, unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 212 | // FIXME: Implement this |
| 213 | assert(false && "Cannot instantiate FixedWidthIntType yet"); |
| 214 | return QualType(); |
| 215 | } |
| 216 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 217 | QualType |
| 218 | TemplateTypeInstantiator::InstantiateComplexType(const ComplexType *T, |
| 219 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 220 | // FIXME: Implement this |
| 221 | assert(false && "Cannot instantiate ComplexType yet"); |
| 222 | return QualType(); |
| 223 | } |
| 224 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 225 | QualType |
| 226 | TemplateTypeInstantiator::InstantiatePointerType(const PointerType *T, |
| 227 | unsigned Quals) const { |
| 228 | QualType PointeeType = Instantiate(T->getPointeeType()); |
| 229 | if (PointeeType.isNull()) |
| 230 | return QualType(); |
| 231 | |
| 232 | return SemaRef.BuildPointerType(PointeeType, Quals, Loc, Entity); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 235 | QualType |
| 236 | TemplateTypeInstantiator::InstantiateBlockPointerType(const BlockPointerType *T, |
| 237 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 238 | // FIXME: Implement this |
| 239 | assert(false && "Cannot instantiate BlockPointerType yet"); |
| 240 | return QualType(); |
| 241 | } |
| 242 | |
Sebastian Redl | ce6fff0 | 2009-03-16 23:22:08 +0000 | [diff] [blame] | 243 | QualType |
| 244 | TemplateTypeInstantiator::InstantiateLValueReferenceType( |
| 245 | const LValueReferenceType *T, unsigned Quals) const { |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 246 | QualType ReferentType = Instantiate(T->getPointeeType()); |
| 247 | if (ReferentType.isNull()) |
| 248 | return QualType(); |
| 249 | |
Sebastian Redl | ce6fff0 | 2009-03-16 23:22:08 +0000 | [diff] [blame] | 250 | return SemaRef.BuildReferenceType(ReferentType, true, Quals, Loc, Entity); |
| 251 | } |
| 252 | |
| 253 | QualType |
| 254 | TemplateTypeInstantiator::InstantiateRValueReferenceType( |
| 255 | const RValueReferenceType *T, unsigned Quals) const { |
| 256 | QualType ReferentType = Instantiate(T->getPointeeType()); |
| 257 | if (ReferentType.isNull()) |
| 258 | return QualType(); |
| 259 | |
| 260 | return SemaRef.BuildReferenceType(ReferentType, false, Quals, Loc, Entity); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 263 | QualType |
| 264 | TemplateTypeInstantiator:: |
| 265 | InstantiateMemberPointerType(const MemberPointerType *T, |
| 266 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 267 | // FIXME: Implement this |
| 268 | assert(false && "Cannot instantiate MemberPointerType yet"); |
| 269 | return QualType(); |
| 270 | } |
| 271 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 272 | QualType |
| 273 | TemplateTypeInstantiator:: |
| 274 | InstantiateConstantArrayType(const ConstantArrayType *T, |
| 275 | unsigned Quals) const { |
| 276 | QualType ElementType = Instantiate(T->getElementType()); |
| 277 | if (ElementType.isNull()) |
| 278 | return ElementType; |
| 279 | |
| 280 | // Build a temporary integer literal to specify the size for |
| 281 | // BuildArrayType. Since we have already checked the size as part of |
| 282 | // creating the dependent array type in the first place, we know |
Douglas Gregor | 9017791 | 2009-05-13 18:28:20 +0000 | [diff] [blame] | 283 | // there aren't any errors. However, we do need to determine what |
| 284 | // C++ type to give the size expression. |
| 285 | llvm::APInt Size = T->getSize(); |
| 286 | QualType Types[] = { |
| 287 | SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy, |
| 288 | SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy, |
| 289 | SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty |
| 290 | }; |
| 291 | const unsigned NumTypes = sizeof(Types) / sizeof(QualType); |
| 292 | QualType SizeType; |
| 293 | for (unsigned I = 0; I != NumTypes; ++I) |
| 294 | if (Size.getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) { |
| 295 | SizeType = Types[I]; |
| 296 | break; |
| 297 | } |
| 298 | |
| 299 | if (SizeType.isNull()) |
| 300 | SizeType = SemaRef.Context.getFixedWidthIntType(Size.getBitWidth(), false); |
| 301 | |
| 302 | IntegerLiteral ArraySize(Size, SizeType, Loc); |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 303 | return SemaRef.BuildArrayType(ElementType, T->getSizeModifier(), |
| 304 | &ArraySize, T->getIndexTypeQualifier(), |
| 305 | Loc, Entity); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 306 | } |
| 307 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 308 | QualType |
| 309 | TemplateTypeInstantiator:: |
| 310 | InstantiateIncompleteArrayType(const IncompleteArrayType *T, |
| 311 | unsigned Quals) const { |
| 312 | QualType ElementType = Instantiate(T->getElementType()); |
| 313 | if (ElementType.isNull()) |
| 314 | return ElementType; |
| 315 | |
| 316 | return SemaRef.BuildArrayType(ElementType, T->getSizeModifier(), |
| 317 | 0, T->getIndexTypeQualifier(), |
| 318 | Loc, Entity); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 319 | } |
| 320 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 321 | QualType |
| 322 | TemplateTypeInstantiator:: |
| 323 | InstantiateVariableArrayType(const VariableArrayType *T, |
| 324 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 325 | // FIXME: Implement this |
| 326 | assert(false && "Cannot instantiate VariableArrayType yet"); |
| 327 | return QualType(); |
| 328 | } |
| 329 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 330 | QualType |
| 331 | TemplateTypeInstantiator:: |
| 332 | InstantiateDependentSizedArrayType(const DependentSizedArrayType *T, |
| 333 | unsigned Quals) const { |
Anders Carlsson | 149f278 | 2009-03-15 20:12:13 +0000 | [diff] [blame] | 334 | Expr *ArraySize = T->getSizeExpr(); |
| 335 | assert(ArraySize->isValueDependent() && |
| 336 | "dependent sized array types must have value dependent size expr"); |
| 337 | |
| 338 | // Instantiate the element type if needed |
| 339 | QualType ElementType = T->getElementType(); |
| 340 | if (ElementType->isDependentType()) { |
| 341 | ElementType = Instantiate(ElementType); |
| 342 | if (ElementType.isNull()) |
| 343 | return QualType(); |
| 344 | } |
| 345 | |
| 346 | // Instantiate the size expression |
| 347 | Sema::OwningExprResult InstantiatedArraySize = |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 348 | SemaRef.InstantiateExpr(ArraySize, TemplateArgs); |
Anders Carlsson | 149f278 | 2009-03-15 20:12:13 +0000 | [diff] [blame] | 349 | if (InstantiatedArraySize.isInvalid()) |
| 350 | return QualType(); |
| 351 | |
| 352 | return SemaRef.BuildArrayType(ElementType, T->getSizeModifier(), |
Anders Carlsson | 39ecdcf | 2009-05-01 19:49:17 +0000 | [diff] [blame] | 353 | InstantiatedArraySize.takeAs<Expr>(), |
Anders Carlsson | 149f278 | 2009-03-15 20:12:13 +0000 | [diff] [blame] | 354 | T->getIndexTypeQualifier(), Loc, Entity); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 355 | } |
| 356 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 357 | QualType |
| 358 | TemplateTypeInstantiator::InstantiateVectorType(const VectorType *T, |
| 359 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 360 | // FIXME: Implement this |
| 361 | assert(false && "Cannot instantiate VectorType yet"); |
| 362 | return QualType(); |
| 363 | } |
| 364 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 365 | QualType |
| 366 | TemplateTypeInstantiator::InstantiateExtVectorType(const ExtVectorType *T, |
| 367 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 368 | // FIXME: Implement this |
| 369 | assert(false && "Cannot instantiate ExtVectorType yet"); |
| 370 | return QualType(); |
| 371 | } |
| 372 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 373 | QualType |
| 374 | TemplateTypeInstantiator:: |
| 375 | InstantiateFunctionProtoType(const FunctionProtoType *T, |
| 376 | unsigned Quals) const { |
Douglas Gregor | c0139ca | 2009-02-28 01:04:19 +0000 | [diff] [blame] | 377 | QualType ResultType = Instantiate(T->getResultType()); |
| 378 | if (ResultType.isNull()) |
| 379 | return ResultType; |
| 380 | |
| 381 | llvm::SmallVector<QualType, 16> ParamTypes; |
| 382 | for (FunctionProtoType::arg_type_iterator Param = T->arg_type_begin(), |
| 383 | ParamEnd = T->arg_type_end(); |
| 384 | Param != ParamEnd; ++Param) { |
| 385 | QualType P = Instantiate(*Param); |
| 386 | if (P.isNull()) |
| 387 | return P; |
| 388 | |
| 389 | ParamTypes.push_back(P); |
| 390 | } |
| 391 | |
| 392 | return SemaRef.BuildFunctionType(ResultType, &ParamTypes[0], |
| 393 | ParamTypes.size(), |
| 394 | T->isVariadic(), T->getTypeQuals(), |
| 395 | Loc, Entity); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 398 | QualType |
| 399 | TemplateTypeInstantiator:: |
| 400 | InstantiateFunctionNoProtoType(const FunctionNoProtoType *T, |
| 401 | unsigned Quals) const { |
Douglas Gregor | c0139ca | 2009-02-28 01:04:19 +0000 | [diff] [blame] | 402 | assert(false && "Functions without prototypes cannot be dependent."); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 403 | return QualType(); |
| 404 | } |
| 405 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 406 | QualType |
| 407 | TemplateTypeInstantiator::InstantiateTypedefType(const TypedefType *T, |
| 408 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 409 | // FIXME: Implement this |
| 410 | assert(false && "Cannot instantiate TypedefType yet"); |
| 411 | return QualType(); |
| 412 | } |
| 413 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 414 | QualType |
| 415 | TemplateTypeInstantiator::InstantiateTypeOfExprType(const TypeOfExprType *T, |
| 416 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 417 | // FIXME: Implement this |
| 418 | assert(false && "Cannot instantiate TypeOfExprType yet"); |
| 419 | return QualType(); |
| 420 | } |
| 421 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 422 | QualType |
| 423 | TemplateTypeInstantiator::InstantiateTypeOfType(const TypeOfType *T, |
| 424 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 425 | // FIXME: Implement this |
| 426 | assert(false && "Cannot instantiate TypeOfType yet"); |
| 427 | return QualType(); |
| 428 | } |
| 429 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 430 | QualType |
| 431 | TemplateTypeInstantiator::InstantiateRecordType(const RecordType *T, |
| 432 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 433 | // FIXME: Implement this |
| 434 | assert(false && "Cannot instantiate RecordType yet"); |
| 435 | return QualType(); |
| 436 | } |
| 437 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 438 | QualType |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 439 | TemplateTypeInstantiator::InstantiateEnumType(const EnumType *T, |
| 440 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 441 | // FIXME: Implement this |
| 442 | assert(false && "Cannot instantiate EnumType yet"); |
| 443 | return QualType(); |
| 444 | } |
| 445 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 446 | QualType |
| 447 | TemplateTypeInstantiator:: |
| 448 | InstantiateTemplateTypeParmType(const TemplateTypeParmType *T, |
| 449 | unsigned Quals) const { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 450 | if (T->getDepth() == 0) { |
| 451 | // Replace the template type parameter with its corresponding |
| 452 | // template argument. |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 453 | assert(TemplateArgs[T->getIndex()].getKind() == TemplateArgument::Type && |
| 454 | "Template argument kind mismatch"); |
| 455 | QualType Result = TemplateArgs[T->getIndex()].getAsType(); |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 456 | if (Result.isNull() || !Quals) |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 457 | return Result; |
| 458 | |
| 459 | // C++ [dcl.ref]p1: |
| 460 | // [...] Cv-qualified references are ill-formed except when |
| 461 | // the cv-qualifiers are introduced through the use of a |
| 462 | // typedef (7.1.3) or of a template type argument (14.3), in |
| 463 | // which case the cv-qualifiers are ignored. |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 464 | if (Quals && Result->isReferenceType()) |
| 465 | Quals = 0; |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 466 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 467 | return QualType(Result.getTypePtr(), Quals | Result.getCVRQualifiers()); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | // The template type parameter comes from an inner template (e.g., |
| 471 | // the template parameter list of a member template inside the |
| 472 | // template we are instantiating). Create a new template type |
| 473 | // parameter with the template "level" reduced by one. |
| 474 | return SemaRef.Context.getTemplateTypeParmType(T->getDepth() - 1, |
| 475 | T->getIndex(), |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 476 | T->getName()) |
| 477 | .getQualifiedType(Quals); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 478 | } |
| 479 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 480 | QualType |
| 481 | TemplateTypeInstantiator:: |
Douglas Gregor | dd13e84 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 482 | InstantiateTemplateSpecializationType( |
| 483 | const TemplateSpecializationType *T, |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 484 | unsigned Quals) const { |
Douglas Gregor | f9ff4b1 | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 485 | llvm::SmallVector<TemplateArgument, 16> InstantiatedTemplateArgs; |
| 486 | InstantiatedTemplateArgs.reserve(T->getNumArgs()); |
Douglas Gregor | dd13e84 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 487 | for (TemplateSpecializationType::iterator Arg = T->begin(), ArgEnd = T->end(); |
Douglas Gregor | f9ff4b1 | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 488 | Arg != ArgEnd; ++Arg) { |
| 489 | switch (Arg->getKind()) { |
| 490 | case TemplateArgument::Type: { |
| 491 | QualType T = SemaRef.InstantiateType(Arg->getAsType(), |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 492 | TemplateArgs, |
Douglas Gregor | f9ff4b1 | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 493 | Arg->getLocation(), |
| 494 | DeclarationName()); |
| 495 | if (T.isNull()) |
| 496 | return QualType(); |
| 497 | |
| 498 | InstantiatedTemplateArgs.push_back( |
| 499 | TemplateArgument(Arg->getLocation(), T)); |
| 500 | break; |
| 501 | } |
| 502 | |
| 503 | case TemplateArgument::Declaration: |
| 504 | case TemplateArgument::Integral: |
| 505 | InstantiatedTemplateArgs.push_back(*Arg); |
| 506 | break; |
| 507 | |
| 508 | case TemplateArgument::Expression: |
Douglas Gregor | 396f114 | 2009-03-13 21:01:28 +0000 | [diff] [blame] | 509 | Sema::OwningExprResult E |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 510 | = SemaRef.InstantiateExpr(Arg->getAsExpr(), TemplateArgs); |
Douglas Gregor | 396f114 | 2009-03-13 21:01:28 +0000 | [diff] [blame] | 511 | if (E.isInvalid()) |
| 512 | return QualType(); |
Anders Carlsson | c154a72 | 2009-05-01 19:30:39 +0000 | [diff] [blame] | 513 | InstantiatedTemplateArgs.push_back(E.takeAs<Expr>()); |
Douglas Gregor | f9ff4b1 | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 514 | break; |
| 515 | } |
| 516 | } |
| 517 | |
Mike Stump | e127ae3 | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 518 | // FIXME: We're missing the locations of the template name, '<', and '>'. |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 519 | |
| 520 | TemplateName Name = SemaRef.InstantiateTemplateName(T->getTemplateName(), |
| 521 | Loc, |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 522 | TemplateArgs); |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 523 | |
| 524 | return SemaRef.CheckTemplateIdType(Name, Loc, SourceLocation(), |
Douglas Gregor | dd13e84 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 525 | &InstantiatedTemplateArgs[0], |
| 526 | InstantiatedTemplateArgs.size(), |
| 527 | SourceLocation()); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 528 | } |
| 529 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 530 | QualType |
| 531 | TemplateTypeInstantiator:: |
Douglas Gregor | 734b4ba | 2009-03-19 00:18:19 +0000 | [diff] [blame] | 532 | InstantiateQualifiedNameType(const QualifiedNameType *T, |
| 533 | unsigned Quals) const { |
Douglas Gregor | d302260 | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 534 | // When we instantiated a qualified name type, there's no point in |
| 535 | // keeping the qualification around in the instantiated result. So, |
| 536 | // just instantiate the named type. |
| 537 | return (*this)(T->getNamedType()); |
| 538 | } |
| 539 | |
| 540 | QualType |
| 541 | TemplateTypeInstantiator:: |
| 542 | InstantiateTypenameType(const TypenameType *T, unsigned Quals) const { |
Douglas Gregor | 77da580 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 543 | if (const TemplateSpecializationType *TemplateId = T->getTemplateId()) { |
| 544 | // When the typename type refers to a template-id, the template-id |
| 545 | // is dependent and has enough information to instantiate the |
| 546 | // result of the typename type. Since we don't care about keeping |
| 547 | // the spelling of the typename type in template instantiations, |
| 548 | // we just instantiate the template-id. |
| 549 | return InstantiateTemplateSpecializationType(TemplateId, Quals); |
| 550 | } |
| 551 | |
Douglas Gregor | d302260 | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 552 | NestedNameSpecifier *NNS |
| 553 | = SemaRef.InstantiateNestedNameSpecifier(T->getQualifier(), |
| 554 | SourceRange(Loc), |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 555 | TemplateArgs); |
Douglas Gregor | d302260 | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 556 | if (!NNS) |
| 557 | return QualType(); |
| 558 | |
Douglas Gregor | 77da580 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 559 | return SemaRef.CheckTypenameType(NNS, *T->getIdentifier(), SourceRange(Loc)); |
Douglas Gregor | 734b4ba | 2009-03-19 00:18:19 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | QualType |
| 563 | TemplateTypeInstantiator:: |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 564 | InstantiateObjCInterfaceType(const ObjCInterfaceType *T, |
| 565 | unsigned Quals) const { |
| 566 | assert(false && "Objective-C types cannot be dependent"); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 567 | return QualType(); |
| 568 | } |
| 569 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 570 | QualType |
| 571 | TemplateTypeInstantiator:: |
| 572 | InstantiateObjCQualifiedInterfaceType(const ObjCQualifiedInterfaceType *T, |
| 573 | unsigned Quals) const { |
| 574 | assert(false && "Objective-C types cannot be dependent"); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 575 | return QualType(); |
| 576 | } |
| 577 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 578 | QualType |
| 579 | TemplateTypeInstantiator:: |
| 580 | InstantiateObjCQualifiedIdType(const ObjCQualifiedIdType *T, |
| 581 | unsigned Quals) const { |
| 582 | assert(false && "Objective-C types cannot be dependent"); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 583 | return QualType(); |
| 584 | } |
| 585 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 586 | /// \brief The actual implementation of Sema::InstantiateType(). |
| 587 | QualType TemplateTypeInstantiator::Instantiate(QualType T) const { |
| 588 | // If T is not a dependent type, there is nothing to do. |
| 589 | if (!T->isDependentType()) |
| 590 | return T; |
| 591 | |
| 592 | switch (T->getTypeClass()) { |
| 593 | #define TYPE(Class, Base) \ |
| 594 | case Type::Class: \ |
| 595 | return Instantiate##Class##Type(cast<Class##Type>(T.getTypePtr()), \ |
| 596 | T.getCVRQualifiers()); |
| 597 | #define ABSTRACT_TYPE(Class, Base) |
| 598 | #include "clang/AST/TypeNodes.def" |
| 599 | } |
| 600 | |
| 601 | assert(false && "Not all types have been decoded for instantiation"); |
| 602 | return QualType(); |
| 603 | } |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 604 | |
| 605 | /// \brief Instantiate the type T with a given set of template arguments. |
| 606 | /// |
| 607 | /// This routine substitutes the given template arguments into the |
| 608 | /// type T and produces the instantiated type. |
| 609 | /// |
| 610 | /// \param T the type into which the template arguments will be |
| 611 | /// substituted. If this type is not dependent, it will be returned |
| 612 | /// immediately. |
| 613 | /// |
| 614 | /// \param TemplateArgs the template arguments that will be |
| 615 | /// substituted for the top-level template parameters within T. |
| 616 | /// |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 617 | /// \param Loc the location in the source code where this substitution |
| 618 | /// is being performed. It will typically be the location of the |
| 619 | /// declarator (if we're instantiating the type of some declaration) |
| 620 | /// or the location of the type in the source code (if, e.g., we're |
| 621 | /// instantiating the type of a cast expression). |
| 622 | /// |
| 623 | /// \param Entity the name of the entity associated with a declaration |
| 624 | /// being instantiated (if any). May be empty to indicate that there |
| 625 | /// is no such entity (if, e.g., this is a type that occurs as part of |
| 626 | /// a cast expression) or that the entity has no name (e.g., an |
| 627 | /// unnamed function parameter). |
| 628 | /// |
| 629 | /// \returns If the instantiation succeeds, the instantiated |
| 630 | /// type. Otherwise, produces diagnostics and returns a NULL type. |
| 631 | QualType Sema::InstantiateType(QualType T, |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 632 | const TemplateArgumentList &TemplateArgs, |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 633 | SourceLocation Loc, DeclarationName Entity) { |
Douglas Gregor | 56d25a7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 634 | assert(!ActiveTemplateInstantiations.empty() && |
| 635 | "Cannot perform an instantiation without some context on the " |
| 636 | "instantiation stack"); |
| 637 | |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 638 | // If T is not a dependent type, there is nothing to do. |
| 639 | if (!T->isDependentType()) |
| 640 | return T; |
| 641 | |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 642 | TemplateTypeInstantiator Instantiator(*this, TemplateArgs, Loc, Entity); |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 643 | return Instantiator(T); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 644 | } |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 645 | |
| 646 | /// \brief Instantiate the base class specifiers of the given class |
| 647 | /// template specialization. |
| 648 | /// |
| 649 | /// Produces a diagnostic and returns true on error, returns false and |
| 650 | /// attaches the instantiated base classes to the class template |
| 651 | /// specialization if successful. |
| 652 | bool |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 653 | Sema::InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation, |
| 654 | CXXRecordDecl *Pattern, |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 655 | const TemplateArgumentList &TemplateArgs) { |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 656 | bool Invalid = false; |
| 657 | llvm::SmallVector<CXXBaseSpecifier*, 8> InstantiatedBases; |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 658 | for (ClassTemplateSpecializationDecl::base_class_iterator |
| 659 | Base = Pattern->bases_begin(), BaseEnd = Pattern->bases_end(); |
Douglas Gregor | d9572a1 | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 660 | Base != BaseEnd; ++Base) { |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 661 | if (!Base->getType()->isDependentType()) { |
| 662 | // FIXME: Allocate via ASTContext |
| 663 | InstantiatedBases.push_back(new CXXBaseSpecifier(*Base)); |
| 664 | continue; |
| 665 | } |
| 666 | |
| 667 | QualType BaseType = InstantiateType(Base->getType(), |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 668 | TemplateArgs, |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 669 | Base->getSourceRange().getBegin(), |
| 670 | DeclarationName()); |
| 671 | if (BaseType.isNull()) { |
| 672 | Invalid = true; |
| 673 | continue; |
| 674 | } |
| 675 | |
| 676 | if (CXXBaseSpecifier *InstantiatedBase |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 677 | = CheckBaseSpecifier(Instantiation, |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 678 | Base->getSourceRange(), |
| 679 | Base->isVirtual(), |
| 680 | Base->getAccessSpecifierAsWritten(), |
| 681 | BaseType, |
| 682 | /*FIXME: Not totally accurate */ |
| 683 | Base->getSourceRange().getBegin())) |
| 684 | InstantiatedBases.push_back(InstantiatedBase); |
| 685 | else |
| 686 | Invalid = true; |
| 687 | } |
| 688 | |
Douglas Gregor | d9572a1 | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 689 | if (!Invalid && |
Jay Foad | 9e6bef4 | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 690 | AttachBaseSpecifiers(Instantiation, InstantiatedBases.data(), |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 691 | InstantiatedBases.size())) |
| 692 | Invalid = true; |
| 693 | |
| 694 | return Invalid; |
| 695 | } |
| 696 | |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 697 | /// \brief Instantiate the definition of a class from a given pattern. |
| 698 | /// |
| 699 | /// \param PointOfInstantiation The point of instantiation within the |
| 700 | /// source code. |
| 701 | /// |
| 702 | /// \param Instantiation is the declaration whose definition is being |
| 703 | /// instantiated. This will be either a class template specialization |
| 704 | /// or a member class of a class template specialization. |
| 705 | /// |
| 706 | /// \param Pattern is the pattern from which the instantiation |
| 707 | /// occurs. This will be either the declaration of a class template or |
| 708 | /// the declaration of a member class of a class template. |
| 709 | /// |
| 710 | /// \param TemplateArgs The template arguments to be substituted into |
| 711 | /// the pattern. |
| 712 | /// |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 713 | /// \returns true if an error occurred, false otherwise. |
| 714 | bool |
| 715 | Sema::InstantiateClass(SourceLocation PointOfInstantiation, |
| 716 | CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, |
Douglas Gregor | fd79ac6 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 717 | const TemplateArgumentList &TemplateArgs, |
| 718 | bool ExplicitInstantiation) { |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 719 | bool Invalid = false; |
| 720 | |
| 721 | CXXRecordDecl *PatternDef |
| 722 | = cast_or_null<CXXRecordDecl>(Pattern->getDefinition(Context)); |
| 723 | if (!PatternDef) { |
| 724 | if (Pattern == Instantiation->getInstantiatedFromMemberClass()) { |
| 725 | Diag(PointOfInstantiation, |
| 726 | diag::err_implicit_instantiate_member_undefined) |
| 727 | << Context.getTypeDeclType(Instantiation); |
| 728 | Diag(Pattern->getLocation(), diag::note_member_of_template_here); |
| 729 | } else { |
Douglas Gregor | fd79ac6 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 730 | Diag(PointOfInstantiation, diag::err_template_instantiate_undefined) |
| 731 | << ExplicitInstantiation |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 732 | << Context.getTypeDeclType(Instantiation); |
| 733 | Diag(Pattern->getLocation(), diag::note_template_decl_here); |
| 734 | } |
| 735 | return true; |
| 736 | } |
| 737 | Pattern = PatternDef; |
| 738 | |
Douglas Gregor | 42c4852 | 2009-03-25 21:23:52 +0000 | [diff] [blame] | 739 | InstantiatingTemplate Inst(*this, PointOfInstantiation, Instantiation); |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 740 | if (Inst) |
| 741 | return true; |
| 742 | |
| 743 | // Enter the scope of this instantiation. We don't use |
| 744 | // PushDeclContext because we don't have a scope. |
| 745 | DeclContext *PreviousContext = CurContext; |
| 746 | CurContext = Instantiation; |
| 747 | |
| 748 | // Start the definition of this instantiation. |
| 749 | Instantiation->startDefinition(); |
| 750 | |
| 751 | // Instantiate the base class specifiers. |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 752 | if (InstantiateBaseSpecifiers(Instantiation, Pattern, TemplateArgs)) |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 753 | Invalid = true; |
| 754 | |
Chris Lattner | 5261d0c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 755 | llvm::SmallVector<DeclPtrTy, 32> Fields; |
Douglas Gregor | c55b0b0 | 2009-04-09 21:40:53 +0000 | [diff] [blame] | 756 | for (RecordDecl::decl_iterator Member = Pattern->decls_begin(Context), |
| 757 | MemberEnd = Pattern->decls_end(Context); |
| 758 | Member != MemberEnd; ++Member) { |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 759 | Decl *NewMember = InstantiateDecl(*Member, Instantiation, TemplateArgs); |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 760 | if (NewMember) { |
| 761 | if (NewMember->isInvalidDecl()) |
| 762 | Invalid = true; |
| 763 | else if (FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) |
Chris Lattner | 5261d0c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 764 | Fields.push_back(DeclPtrTy::make(Field)); |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 765 | } else { |
| 766 | // FIXME: Eventually, a NULL return will mean that one of the |
Mike Stump | e127ae3 | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 767 | // instantiations was a semantic disaster, and we'll want to set Invalid = |
| 768 | // true. For now, we expect to skip some members that we can't yet handle. |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | |
| 772 | // Finish checking fields. |
Chris Lattner | 5261d0c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 773 | ActOnFields(0, Instantiation->getLocation(), DeclPtrTy::make(Instantiation), |
Jay Foad | 9e6bef4 | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 774 | Fields.data(), Fields.size(), SourceLocation(), SourceLocation(), |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 775 | 0); |
| 776 | |
| 777 | // Add any implicitly-declared members that we might need. |
| 778 | AddImplicitlyDeclaredMembersToClass(Instantiation); |
| 779 | |
| 780 | // Exit the scope of this instantiation. |
| 781 | CurContext = PreviousContext; |
| 782 | |
Douglas Gregor | dc18e89 | 2009-05-26 20:50:29 +0000 | [diff] [blame^] | 783 | if (!Invalid) |
| 784 | Consumer.HandleTagDeclDefinition(Instantiation); |
| 785 | |
Douglas Gregor | df9f5d1 | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 786 | // If this is an explicit instantiation, instantiate our members, too. |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 787 | if (!Invalid && ExplicitInstantiation) { |
| 788 | Inst.Clear(); |
Douglas Gregor | df9f5d1 | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 789 | InstantiateClassMembers(PointOfInstantiation, Instantiation, TemplateArgs); |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 790 | } |
Douglas Gregor | df9f5d1 | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 791 | |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 792 | return Invalid; |
| 793 | } |
| 794 | |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 795 | bool |
| 796 | Sema::InstantiateClassTemplateSpecialization( |
| 797 | ClassTemplateSpecializationDecl *ClassTemplateSpec, |
| 798 | bool ExplicitInstantiation) { |
| 799 | // Perform the actual instantiation on the canonical declaration. |
| 800 | ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>( |
| 801 | Context.getCanonicalDecl(ClassTemplateSpec)); |
| 802 | |
| 803 | // We can only instantiate something that hasn't already been |
| 804 | // instantiated or specialized. Fail without any diagnostics: our |
| 805 | // caller will provide an error message. |
| 806 | if (ClassTemplateSpec->getSpecializationKind() != TSK_Undeclared) |
| 807 | return true; |
| 808 | |
Mike Stump | e127ae3 | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 809 | // FIXME: Push this class template instantiation onto the instantiation stack, |
| 810 | // checking for recursion that exceeds a certain depth. |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 811 | |
Mike Stump | e127ae3 | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 812 | // FIXME: Perform class template partial specialization to select the best |
| 813 | // template. |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 814 | ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate(); |
| 815 | |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 816 | CXXRecordDecl *Pattern = Template->getTemplatedDecl(); |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 817 | |
| 818 | // Note that this is an instantiation. |
| 819 | ClassTemplateSpec->setSpecializationKind( |
| 820 | ExplicitInstantiation? TSK_ExplicitInstantiation |
| 821 | : TSK_ImplicitInstantiation); |
| 822 | |
Douglas Gregor | cc88797 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 823 | return InstantiateClass(ClassTemplateSpec->getLocation(), |
| 824 | ClassTemplateSpec, Pattern, |
Douglas Gregor | fd79ac6 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 825 | ClassTemplateSpec->getTemplateArgs(), |
| 826 | ExplicitInstantiation); |
Douglas Gregor | ed3a398 | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 827 | } |
Douglas Gregor | 47bde7c | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 828 | |
Douglas Gregor | df9f5d1 | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 829 | /// \brief Instantiate the definitions of all of the member of the |
| 830 | /// given class, which is an instantiation of a class template or a |
| 831 | /// member class of a template. |
| 832 | void |
| 833 | Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, |
| 834 | CXXRecordDecl *Instantiation, |
| 835 | const TemplateArgumentList &TemplateArgs) { |
| 836 | for (DeclContext::decl_iterator D = Instantiation->decls_begin(Context), |
| 837 | DEnd = Instantiation->decls_end(Context); |
| 838 | D != DEnd; ++D) { |
| 839 | if (FunctionDecl *Function = dyn_cast<FunctionDecl>(*D)) { |
| 840 | if (!Function->getBody(Context)) |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 841 | InstantiateFunctionDefinition(PointOfInstantiation, Function); |
Douglas Gregor | df9f5d1 | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 842 | } else if (VarDecl *Var = dyn_cast<VarDecl>(*D)) { |
| 843 | const VarDecl *Def = 0; |
| 844 | if (!Var->getDefinition(Def)) |
| 845 | InstantiateVariableDefinition(Var); |
| 846 | } else if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(*D)) { |
| 847 | if (!Record->isInjectedClassName() && !Record->getDefinition(Context)) { |
| 848 | assert(Record->getInstantiatedFromMemberClass() && |
| 849 | "Missing instantiated-from-template information"); |
Douglas Gregor | b12249d | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 850 | InstantiateClass(PointOfInstantiation, Record, |
Douglas Gregor | df9f5d1 | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 851 | Record->getInstantiatedFromMemberClass(), |
| 852 | TemplateArgs, true); |
| 853 | } |
| 854 | } |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | /// \brief Instantiate the definitions of all of the members of the |
| 859 | /// given class template specialization, which was named as part of an |
| 860 | /// explicit instantiation. |
| 861 | void Sema::InstantiateClassTemplateSpecializationMembers( |
| 862 | SourceLocation PointOfInstantiation, |
| 863 | ClassTemplateSpecializationDecl *ClassTemplateSpec) { |
| 864 | // C++0x [temp.explicit]p7: |
| 865 | // An explicit instantiation that names a class template |
| 866 | // specialization is an explicit instantion of the same kind |
| 867 | // (declaration or definition) of each of its members (not |
| 868 | // including members inherited from base classes) that has not |
| 869 | // been previously explicitly specialized in the translation unit |
| 870 | // containing the explicit instantiation, except as described |
| 871 | // below. |
| 872 | InstantiateClassMembers(PointOfInstantiation, ClassTemplateSpec, |
| 873 | ClassTemplateSpec->getTemplateArgs()); |
| 874 | } |
| 875 | |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 876 | /// \brief Instantiate a nested-name-specifier. |
| 877 | NestedNameSpecifier * |
| 878 | Sema::InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS, |
| 879 | SourceRange Range, |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 880 | const TemplateArgumentList &TemplateArgs) { |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 881 | // Instantiate the prefix of this nested name specifier. |
| 882 | NestedNameSpecifier *Prefix = NNS->getPrefix(); |
| 883 | if (Prefix) { |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 884 | Prefix = InstantiateNestedNameSpecifier(Prefix, Range, TemplateArgs); |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 885 | if (!Prefix) |
| 886 | return 0; |
Douglas Gregor | 47bde7c | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 887 | } |
| 888 | |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 889 | switch (NNS->getKind()) { |
Douglas Gregor | 77da580 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 890 | case NestedNameSpecifier::Identifier: { |
| 891 | assert(Prefix && |
| 892 | "Can't have an identifier nested-name-specifier with no prefix"); |
| 893 | CXXScopeSpec SS; |
| 894 | // FIXME: The source location information is all wrong. |
| 895 | SS.setRange(Range); |
| 896 | SS.setScopeRep(Prefix); |
| 897 | return static_cast<NestedNameSpecifier *>( |
| 898 | ActOnCXXNestedNameSpecifier(0, SS, |
| 899 | Range.getEnd(), |
| 900 | Range.getEnd(), |
Douglas Gregor | 96b6df9 | 2009-05-14 00:28:11 +0000 | [diff] [blame] | 901 | *NNS->getAsIdentifier())); |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 902 | break; |
Douglas Gregor | 77da580 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 903 | } |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 904 | |
| 905 | case NestedNameSpecifier::Namespace: |
| 906 | case NestedNameSpecifier::Global: |
| 907 | return NNS; |
| 908 | |
| 909 | case NestedNameSpecifier::TypeSpecWithTemplate: |
| 910 | case NestedNameSpecifier::TypeSpec: { |
| 911 | QualType T = QualType(NNS->getAsType(), 0); |
| 912 | if (!T->isDependentType()) |
| 913 | return NNS; |
| 914 | |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 915 | T = InstantiateType(T, TemplateArgs, Range.getBegin(), DeclarationName()); |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 916 | if (T.isNull()) |
| 917 | return 0; |
| 918 | |
Douglas Gregor | d302260 | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 919 | if (T->isRecordType() || |
| 920 | (getLangOptions().CPlusPlus0x && T->isEnumeralType())) { |
Douglas Gregor | 77da580 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 921 | assert(T.getCVRQualifiers() == 0 && "Can't get cv-qualifiers here"); |
Douglas Gregor | d302260 | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 922 | return NestedNameSpecifier::Create(Context, Prefix, |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 923 | NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate, |
Douglas Gregor | d302260 | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 924 | T.getTypePtr()); |
| 925 | } |
| 926 | |
| 927 | Diag(Range.getBegin(), diag::err_nested_name_spec_non_tag) << T; |
| 928 | return 0; |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 929 | } |
| 930 | } |
| 931 | |
Douglas Gregor | d302260 | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 932 | // Required to silence a GCC warning |
Douglas Gregor | 1e589cc | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 933 | return 0; |
Douglas Gregor | 47bde7c | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 934 | } |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 935 | |
| 936 | TemplateName |
| 937 | Sema::InstantiateTemplateName(TemplateName Name, SourceLocation Loc, |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 938 | const TemplateArgumentList &TemplateArgs) { |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 939 | if (TemplateTemplateParmDecl *TTP |
| 940 | = dyn_cast_or_null<TemplateTemplateParmDecl>( |
| 941 | Name.getAsTemplateDecl())) { |
| 942 | assert(TTP->getDepth() == 0 && |
| 943 | "Cannot reduce depth of a template template parameter"); |
Douglas Gregor | aed9804 | 2009-03-31 20:22:05 +0000 | [diff] [blame] | 944 | assert(TemplateArgs[TTP->getPosition()].getAsDecl() && |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 945 | "Wrong kind of template template argument"); |
| 946 | ClassTemplateDecl *ClassTemplate |
| 947 | = dyn_cast<ClassTemplateDecl>( |
| 948 | TemplateArgs[TTP->getPosition()].getAsDecl()); |
Douglas Gregor | aed9804 | 2009-03-31 20:22:05 +0000 | [diff] [blame] | 949 | assert(ClassTemplate && "Expected a class template"); |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 950 | if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) { |
| 951 | NestedNameSpecifier *NNS |
| 952 | = InstantiateNestedNameSpecifier(QTN->getQualifier(), |
| 953 | /*FIXME=*/SourceRange(Loc), |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 954 | TemplateArgs); |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 955 | if (NNS) |
| 956 | return Context.getQualifiedTemplateName(NNS, |
| 957 | QTN->hasTemplateKeyword(), |
| 958 | ClassTemplate); |
| 959 | } |
| 960 | |
| 961 | return TemplateName(ClassTemplate); |
| 962 | } else if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) { |
| 963 | NestedNameSpecifier *NNS |
| 964 | = InstantiateNestedNameSpecifier(DTN->getQualifier(), |
| 965 | /*FIXME=*/SourceRange(Loc), |
Douglas Gregor | f9e7d3d | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 966 | TemplateArgs); |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 967 | |
| 968 | if (!NNS) // FIXME: Not the best recovery strategy. |
| 969 | return Name; |
| 970 | |
| 971 | if (NNS->isDependent()) |
| 972 | return Context.getDependentTemplateName(NNS, DTN->getName()); |
| 973 | |
| 974 | // Somewhat redundant with ActOnDependentTemplateName. |
| 975 | CXXScopeSpec SS; |
| 976 | SS.setRange(SourceRange(Loc)); |
| 977 | SS.setScopeRep(NNS); |
| 978 | TemplateTy Template; |
| 979 | TemplateNameKind TNK = isTemplateName(*DTN->getName(), 0, Template, &SS); |
| 980 | if (TNK == TNK_Non_template) { |
| 981 | Diag(Loc, diag::err_template_kw_refers_to_non_template) |
| 982 | << DTN->getName(); |
| 983 | return Name; |
| 984 | } else if (TNK == TNK_Function_template) { |
| 985 | Diag(Loc, diag::err_template_kw_refers_to_non_template) |
| 986 | << DTN->getName(); |
| 987 | return Name; |
| 988 | } |
| 989 | |
| 990 | return Template.getAsVal<TemplateName>(); |
| 991 | } |
| 992 | |
| 993 | |
| 994 | |
Mike Stump | e127ae3 | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 995 | // FIXME: Even if we're referring to a Decl that isn't a template template |
| 996 | // parameter, we may need to instantiate the outer contexts of that |
| 997 | // Decl. However, this won't be needed until we implement member templates. |
Douglas Gregor | 15a9285 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 998 | return Name; |
| 999 | } |