Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 1 | //===--- SemaTemplateInstantiateDecl.cpp - C++ Template Decl 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 for declarations. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===/ |
| 12 | #include "Sema.h" |
Douglas Gregor | aba43bb | 2009-05-26 20:50:29 +0000 | [diff] [blame] | 13 | #include "clang/AST/ASTConsumer.h" |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 14 | #include "clang/AST/ASTContext.h" |
| 15 | #include "clang/AST/DeclTemplate.h" |
| 16 | #include "clang/AST/DeclVisitor.h" |
| 17 | #include "clang/AST/Expr.h" |
| 18 | #include "llvm/Support/Compiler.h" |
| 19 | |
| 20 | using namespace clang; |
| 21 | |
| 22 | namespace { |
| 23 | class VISIBILITY_HIDDEN TemplateDeclInstantiator |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 24 | : public DeclVisitor<TemplateDeclInstantiator, Decl *> { |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 25 | Sema &SemaRef; |
| 26 | DeclContext *Owner; |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 27 | const TemplateArgumentList &TemplateArgs; |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 28 | |
| 29 | public: |
| 30 | typedef Sema::OwningExprResult OwningExprResult; |
| 31 | |
| 32 | TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner, |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 33 | const TemplateArgumentList &TemplateArgs) |
| 34 | : SemaRef(SemaRef), Owner(Owner), TemplateArgs(TemplateArgs) { } |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 35 | |
Mike Stump | 390b4cc | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 36 | // FIXME: Once we get closer to completion, replace these manually-written |
| 37 | // declarations with automatically-generated ones from |
| 38 | // clang/AST/DeclNodes.def. |
Douglas Gregor | 4f722be | 2009-03-25 15:45:12 +0000 | [diff] [blame] | 39 | Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D); |
| 40 | Decl *VisitNamespaceDecl(NamespaceDecl *D); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 41 | Decl *VisitTypedefDecl(TypedefDecl *D); |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 42 | Decl *VisitVarDecl(VarDecl *D); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 43 | Decl *VisitFieldDecl(FieldDecl *D); |
| 44 | Decl *VisitStaticAssertDecl(StaticAssertDecl *D); |
| 45 | Decl *VisitEnumDecl(EnumDecl *D); |
Douglas Gregor | 6477b69 | 2009-03-25 15:04:13 +0000 | [diff] [blame] | 46 | Decl *VisitEnumConstantDecl(EnumConstantDecl *D); |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 47 | Decl *VisitFunctionDecl(FunctionDecl *D); |
Douglas Gregor | d475b8d | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 48 | Decl *VisitCXXRecordDecl(CXXRecordDecl *D); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 49 | Decl *VisitCXXMethodDecl(CXXMethodDecl *D); |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 50 | Decl *VisitCXXConstructorDecl(CXXConstructorDecl *D); |
Douglas Gregor | 03b2b07 | 2009-03-24 00:15:49 +0000 | [diff] [blame] | 51 | Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D); |
Douglas Gregor | bb969ed | 2009-03-25 00:34:44 +0000 | [diff] [blame] | 52 | Decl *VisitCXXConversionDecl(CXXConversionDecl *D); |
Douglas Gregor | 6477b69 | 2009-03-25 15:04:13 +0000 | [diff] [blame] | 53 | ParmVarDecl *VisitParmVarDecl(ParmVarDecl *D); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 54 | Decl *VisitOriginalParmVarDecl(OriginalParmVarDecl *D); |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 55 | |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 56 | // Base case. FIXME: Remove once we can instantiate everything. |
| 57 | Decl *VisitDecl(Decl *) { |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 58 | assert(false && "Template instantiation of unknown declaration kind!"); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 59 | return 0; |
| 60 | } |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 61 | |
| 62 | // Helper functions for instantiating methods. |
| 63 | QualType InstantiateFunctionType(FunctionDecl *D, |
| 64 | llvm::SmallVectorImpl<ParmVarDecl *> &Params); |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 65 | bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl); |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 66 | bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 67 | }; |
| 68 | } |
| 69 | |
Douglas Gregor | 4f722be | 2009-03-25 15:45:12 +0000 | [diff] [blame] | 70 | Decl * |
| 71 | TemplateDeclInstantiator::VisitTranslationUnitDecl(TranslationUnitDecl *D) { |
| 72 | assert(false && "Translation units cannot be instantiated"); |
| 73 | return D; |
| 74 | } |
| 75 | |
| 76 | Decl * |
| 77 | TemplateDeclInstantiator::VisitNamespaceDecl(NamespaceDecl *D) { |
| 78 | assert(false && "Namespaces cannot be instantiated"); |
| 79 | return D; |
| 80 | } |
| 81 | |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 82 | Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) { |
| 83 | bool Invalid = false; |
| 84 | QualType T = D->getUnderlyingType(); |
| 85 | if (T->isDependentType()) { |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 86 | T = SemaRef.InstantiateType(T, TemplateArgs, |
| 87 | D->getLocation(), D->getDeclName()); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 88 | if (T.isNull()) { |
| 89 | Invalid = true; |
| 90 | T = SemaRef.Context.IntTy; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // Create the new typedef |
| 95 | TypedefDecl *Typedef |
| 96 | = TypedefDecl::Create(SemaRef.Context, Owner, D->getLocation(), |
| 97 | D->getIdentifier(), T); |
| 98 | if (Invalid) |
| 99 | Typedef->setInvalidDecl(); |
| 100 | |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 101 | Owner->addDecl(Typedef); |
Douglas Gregor | bc22163 | 2009-05-28 16:34:51 +0000 | [diff] [blame] | 102 | |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 103 | return Typedef; |
| 104 | } |
| 105 | |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 106 | Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { |
| 107 | // Instantiate the type of the declaration |
| 108 | QualType T = SemaRef.InstantiateType(D->getType(), TemplateArgs, |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 109 | D->getTypeSpecStartLoc(), |
| 110 | D->getDeclName()); |
| 111 | if (T.isNull()) |
| 112 | return 0; |
| 113 | |
Douglas Gregor | b9f1b8d | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 114 | // Build the instantiated declaration |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 115 | VarDecl *Var = VarDecl::Create(SemaRef.Context, Owner, |
| 116 | D->getLocation(), D->getIdentifier(), |
| 117 | T, D->getStorageClass(), |
| 118 | D->getTypeSpecStartLoc()); |
| 119 | Var->setThreadSpecified(D->isThreadSpecified()); |
| 120 | Var->setCXXDirectInitializer(D->hasCXXDirectInitializer()); |
| 121 | Var->setDeclaredInCondition(D->isDeclaredInCondition()); |
| 122 | |
Mike Stump | 390b4cc | 2009-05-16 07:39:55 +0000 | [diff] [blame] | 123 | // FIXME: In theory, we could have a previous declaration for variables that |
| 124 | // are not static data members. |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 125 | bool Redeclaration = false; |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 126 | SemaRef.CheckVariableDeclaration(Var, 0, Redeclaration); |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 127 | Owner->addDecl(Var); |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 128 | |
| 129 | if (D->getInit()) { |
| 130 | OwningExprResult Init |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 131 | = SemaRef.InstantiateExpr(D->getInit(), TemplateArgs); |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 132 | if (Init.isInvalid()) |
| 133 | Var->setInvalidDecl(); |
| 134 | else |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 135 | SemaRef.AddInitializerToDecl(Sema::DeclPtrTy::make(Var), move(Init), |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 136 | D->hasCXXDirectInitializer()); |
Douglas Gregor | d308e62 | 2009-05-18 20:51:54 +0000 | [diff] [blame] | 137 | } else { |
| 138 | // FIXME: Call ActOnUninitializedDecl? (Not always) |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | return Var; |
| 142 | } |
| 143 | |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 144 | Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { |
| 145 | bool Invalid = false; |
| 146 | QualType T = D->getType(); |
| 147 | if (T->isDependentType()) { |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 148 | T = SemaRef.InstantiateType(T, TemplateArgs, |
| 149 | D->getLocation(), D->getDeclName()); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 150 | if (!T.isNull() && T->isFunctionType()) { |
| 151 | // C++ [temp.arg.type]p3: |
| 152 | // If a declaration acquires a function type through a type |
| 153 | // dependent on a template-parameter and this causes a |
| 154 | // declaration that does not use the syntactic form of a |
| 155 | // function declarator to have function type, the program is |
| 156 | // ill-formed. |
| 157 | SemaRef.Diag(D->getLocation(), diag::err_field_instantiates_to_function) |
| 158 | << T; |
| 159 | T = QualType(); |
| 160 | Invalid = true; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | Expr *BitWidth = D->getBitWidth(); |
| 165 | if (Invalid) |
| 166 | BitWidth = 0; |
| 167 | else if (BitWidth) { |
Douglas Gregor | ac7610d | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 168 | // The bit-width expression is not potentially evaluated. |
| 169 | EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); |
| 170 | |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 171 | OwningExprResult InstantiatedBitWidth |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 172 | = SemaRef.InstantiateExpr(BitWidth, TemplateArgs); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 173 | if (InstantiatedBitWidth.isInvalid()) { |
| 174 | Invalid = true; |
| 175 | BitWidth = 0; |
| 176 | } else |
Anders Carlsson | e9146f2 | 2009-05-01 19:49:17 +0000 | [diff] [blame] | 177 | BitWidth = InstantiatedBitWidth.takeAs<Expr>(); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | FieldDecl *Field = SemaRef.CheckFieldDecl(D->getDeclName(), T, |
| 181 | cast<RecordDecl>(Owner), |
| 182 | D->getLocation(), |
| 183 | D->isMutable(), |
| 184 | BitWidth, |
Steve Naroff | ea218b8 | 2009-07-14 14:58:18 +0000 | [diff] [blame] | 185 | D->getTypeSpecStartLoc(), |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 186 | D->getAccess(), |
| 187 | 0); |
| 188 | if (Field) { |
| 189 | if (Invalid) |
| 190 | Field->setInvalidDecl(); |
| 191 | |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 192 | Owner->addDecl(Field); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | return Field; |
| 196 | } |
| 197 | |
| 198 | Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) { |
| 199 | Expr *AssertExpr = D->getAssertExpr(); |
| 200 | |
Douglas Gregor | ac7610d | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 201 | // The expression in a static assertion is not potentially evaluated. |
| 202 | EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); |
| 203 | |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 204 | OwningExprResult InstantiatedAssertExpr |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 205 | = SemaRef.InstantiateExpr(AssertExpr, TemplateArgs); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 206 | if (InstantiatedAssertExpr.isInvalid()) |
| 207 | return 0; |
| 208 | |
| 209 | OwningExprResult Message = SemaRef.Clone(D->getMessage()); |
| 210 | Decl *StaticAssert |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 211 | = SemaRef.ActOnStaticAssertDeclaration(D->getLocation(), |
| 212 | move(InstantiatedAssertExpr), |
| 213 | move(Message)).getAs<Decl>(); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 214 | return StaticAssert; |
| 215 | } |
| 216 | |
| 217 | Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { |
| 218 | EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner, |
| 219 | D->getLocation(), D->getIdentifier(), |
Douglas Gregor | 741dd9a | 2009-07-21 14:46:17 +0000 | [diff] [blame] | 220 | D->getTagKeywordLoc(), |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 221 | /*PrevDecl=*/0); |
Douglas Gregor | 8dbc3c6 | 2009-05-27 17:20:35 +0000 | [diff] [blame] | 222 | Enum->setInstantiationOfMemberEnum(D); |
Douglas Gregor | 06c0fec | 2009-03-25 22:00:53 +0000 | [diff] [blame] | 223 | Enum->setAccess(D->getAccess()); |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 224 | Owner->addDecl(Enum); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 225 | Enum->startDefinition(); |
| 226 | |
Douglas Gregor | 0ca20ac | 2009-05-29 18:27:38 +0000 | [diff] [blame] | 227 | llvm::SmallVector<Sema::DeclPtrTy, 4> Enumerators; |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 228 | |
| 229 | EnumConstantDecl *LastEnumConst = 0; |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 230 | for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(), |
| 231 | ECEnd = D->enumerator_end(); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 232 | EC != ECEnd; ++EC) { |
| 233 | // The specified value for the enumerator. |
| 234 | OwningExprResult Value = SemaRef.Owned((Expr *)0); |
Douglas Gregor | ac7610d | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 235 | if (Expr *UninstValue = EC->getInitExpr()) { |
| 236 | // The enumerator's value expression is not potentially evaluated. |
| 237 | EnterExpressionEvaluationContext Unevaluated(SemaRef, |
| 238 | Action::Unevaluated); |
| 239 | |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 240 | Value = SemaRef.InstantiateExpr(UninstValue, TemplateArgs); |
Douglas Gregor | ac7610d | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 241 | } |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 242 | |
| 243 | // Drop the initial value and continue. |
| 244 | bool isInvalid = false; |
| 245 | if (Value.isInvalid()) { |
| 246 | Value = SemaRef.Owned((Expr *)0); |
| 247 | isInvalid = true; |
| 248 | } |
| 249 | |
| 250 | EnumConstantDecl *EnumConst |
| 251 | = SemaRef.CheckEnumConstant(Enum, LastEnumConst, |
| 252 | EC->getLocation(), EC->getIdentifier(), |
| 253 | move(Value)); |
| 254 | |
| 255 | if (isInvalid) { |
| 256 | if (EnumConst) |
| 257 | EnumConst->setInvalidDecl(); |
| 258 | Enum->setInvalidDecl(); |
| 259 | } |
| 260 | |
| 261 | if (EnumConst) { |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 262 | Enum->addDecl(EnumConst); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 263 | Enumerators.push_back(Sema::DeclPtrTy::make(EnumConst)); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 264 | LastEnumConst = EnumConst; |
| 265 | } |
| 266 | } |
| 267 | |
Mike Stump | c6e35aa | 2009-05-16 07:06:02 +0000 | [diff] [blame] | 268 | // FIXME: Fixup LBraceLoc and RBraceLoc |
| 269 | SemaRef.ActOnEnumBody(Enum->getLocation(), SourceLocation(), SourceLocation(), |
| 270 | Sema::DeclPtrTy::make(Enum), |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 271 | &Enumerators[0], Enumerators.size()); |
| 272 | |
| 273 | return Enum; |
| 274 | } |
| 275 | |
Douglas Gregor | 6477b69 | 2009-03-25 15:04:13 +0000 | [diff] [blame] | 276 | Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) { |
| 277 | assert(false && "EnumConstantDecls can only occur within EnumDecls."); |
| 278 | return 0; |
| 279 | } |
| 280 | |
Douglas Gregor | d475b8d | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 281 | Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { |
| 282 | CXXRecordDecl *PrevDecl = 0; |
| 283 | if (D->isInjectedClassName()) |
| 284 | PrevDecl = cast<CXXRecordDecl>(Owner); |
| 285 | |
| 286 | CXXRecordDecl *Record |
| 287 | = CXXRecordDecl::Create(SemaRef.Context, D->getTagKind(), Owner, |
Douglas Gregor | 741dd9a | 2009-07-21 14:46:17 +0000 | [diff] [blame] | 288 | D->getLocation(), D->getIdentifier(), |
| 289 | D->getTagKeywordLoc(), PrevDecl); |
Douglas Gregor | d475b8d | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 290 | Record->setImplicit(D->isImplicit()); |
| 291 | Record->setAccess(D->getAccess()); |
Douglas Gregor | d475b8d | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 292 | if (!D->isInjectedClassName()) |
| 293 | Record->setInstantiationOfMemberClass(D); |
| 294 | |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 295 | Owner->addDecl(Record); |
Douglas Gregor | d475b8d | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 296 | return Record; |
| 297 | } |
| 298 | |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 299 | Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) { |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 300 | // Check whether there is already a function template specialization for |
| 301 | // this declaration. |
| 302 | FunctionTemplateDecl *FunctionTemplate = D->getDescribedFunctionTemplate(); |
| 303 | void *InsertPos = 0; |
| 304 | if (FunctionTemplate) { |
| 305 | llvm::FoldingSetNodeID ID; |
| 306 | FunctionTemplateSpecializationInfo::Profile(ID, |
| 307 | TemplateArgs.getFlatArgumentList(), |
| 308 | TemplateArgs.flat_size()); |
| 309 | |
| 310 | FunctionTemplateSpecializationInfo *Info |
| 311 | = FunctionTemplate->getSpecializations().FindNodeOrInsertPos(ID, |
| 312 | InsertPos); |
| 313 | |
| 314 | // If we already have a function template specialization, return it. |
| 315 | if (Info) |
| 316 | return Info->Function; |
| 317 | } |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 318 | |
| 319 | Sema::LocalInstantiationScope Scope(SemaRef); |
| 320 | |
| 321 | llvm::SmallVector<ParmVarDecl *, 4> Params; |
| 322 | QualType T = InstantiateFunctionType(D, Params); |
| 323 | if (T.isNull()) |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 324 | return 0; |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 325 | |
| 326 | // Build the instantiated method declaration. |
| 327 | FunctionDecl *Function |
| 328 | = FunctionDecl::Create(SemaRef.Context, Owner, D->getLocation(), |
| 329 | D->getDeclName(), T, D->getStorageClass(), |
| 330 | D->isInline(), D->hasWrittenPrototype(), |
| 331 | D->getTypeSpecStartLoc()); |
| 332 | |
| 333 | // FIXME: friend functions |
| 334 | |
| 335 | // Attach the parameters |
| 336 | for (unsigned P = 0; P < Params.size(); ++P) |
| 337 | Params[P]->setOwningFunction(Function); |
| 338 | Function->setParams(SemaRef.Context, Params.data(), Params.size()); |
| 339 | |
| 340 | if (InitFunctionInstantiation(Function, D)) |
| 341 | Function->setInvalidDecl(); |
| 342 | |
| 343 | bool Redeclaration = false; |
| 344 | bool OverloadableAttrRequired = false; |
| 345 | NamedDecl *PrevDecl = 0; |
| 346 | SemaRef.CheckFunctionDeclaration(Function, PrevDecl, Redeclaration, |
| 347 | /*FIXME:*/OverloadableAttrRequired); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 348 | |
Douglas Gregor | 127102b | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 349 | if (FunctionTemplate) { |
| 350 | // Record this function template specialization. |
| 351 | Function->setFunctionTemplateSpecialization(SemaRef.Context, |
| 352 | FunctionTemplate, |
| 353 | &TemplateArgs, |
| 354 | InsertPos); |
| 355 | } |
| 356 | |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 357 | return Function; |
| 358 | } |
| 359 | |
| 360 | Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) { |
| 361 | // FIXME: Look for existing, explicit specializations. |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 362 | Sema::LocalInstantiationScope Scope(SemaRef); |
| 363 | |
Douglas Gregor | 0ca20ac | 2009-05-29 18:27:38 +0000 | [diff] [blame] | 364 | llvm::SmallVector<ParmVarDecl *, 4> Params; |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 365 | QualType T = InstantiateFunctionType(D, Params); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 366 | if (T.isNull()) |
| 367 | return 0; |
| 368 | |
| 369 | // Build the instantiated method declaration. |
| 370 | CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner); |
| 371 | CXXMethodDecl *Method |
| 372 | = CXXMethodDecl::Create(SemaRef.Context, Record, D->getLocation(), |
| 373 | D->getDeclName(), T, D->isStatic(), |
| 374 | D->isInline()); |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 375 | Method->setInstantiationOfMemberFunction(D); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 376 | |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 377 | // Attach the parameters |
| 378 | for (unsigned P = 0; P < Params.size(); ++P) |
| 379 | Params[P]->setOwningFunction(Method); |
Jay Foad | beaaccd | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 380 | Method->setParams(SemaRef.Context, Params.data(), Params.size()); |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 381 | |
| 382 | if (InitMethodInstantiation(Method, D)) |
| 383 | Method->setInvalidDecl(); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 384 | |
| 385 | NamedDecl *PrevDecl |
| 386 | = SemaRef.LookupQualifiedName(Owner, Method->getDeclName(), |
| 387 | Sema::LookupOrdinaryName, true); |
| 388 | // In C++, the previous declaration we find might be a tag type |
| 389 | // (class or enum). In this case, the new declaration will hide the |
| 390 | // tag type. Note that this does does not apply if we're declaring a |
| 391 | // typedef (C++ [dcl.typedef]p4). |
| 392 | if (PrevDecl && PrevDecl->getIdentifierNamespace() == Decl::IDNS_Tag) |
| 393 | PrevDecl = 0; |
| 394 | bool Redeclaration = false; |
| 395 | bool OverloadableAttrRequired = false; |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 396 | SemaRef.CheckFunctionDeclaration(Method, PrevDecl, Redeclaration, |
| 397 | /*FIXME:*/OverloadableAttrRequired); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 398 | |
| 399 | if (!Method->isInvalidDecl() || !PrevDecl) |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 400 | Owner->addDecl(Method); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 401 | return Method; |
| 402 | } |
| 403 | |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 404 | Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 405 | // FIXME: Look for existing, explicit specializations. |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 406 | Sema::LocalInstantiationScope Scope(SemaRef); |
| 407 | |
Douglas Gregor | 0ca20ac | 2009-05-29 18:27:38 +0000 | [diff] [blame] | 408 | llvm::SmallVector<ParmVarDecl *, 4> Params; |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 409 | QualType T = InstantiateFunctionType(D, Params); |
| 410 | if (T.isNull()) |
| 411 | return 0; |
| 412 | |
| 413 | // Build the instantiated method declaration. |
| 414 | CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner); |
| 415 | QualType ClassTy = SemaRef.Context.getTypeDeclType(Record); |
| 416 | DeclarationName Name |
Douglas Gregor | 49f25ec | 2009-05-15 21:18:27 +0000 | [diff] [blame] | 417 | = SemaRef.Context.DeclarationNames.getCXXConstructorName( |
| 418 | SemaRef.Context.getCanonicalType(ClassTy)); |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 419 | CXXConstructorDecl *Constructor |
| 420 | = CXXConstructorDecl::Create(SemaRef.Context, Record, D->getLocation(), |
| 421 | Name, T, D->isExplicit(), D->isInline(), |
| 422 | false); |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 423 | Constructor->setInstantiationOfMemberFunction(D); |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 424 | |
| 425 | // Attach the parameters |
| 426 | for (unsigned P = 0; P < Params.size(); ++P) |
| 427 | Params[P]->setOwningFunction(Constructor); |
Jay Foad | beaaccd | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 428 | Constructor->setParams(SemaRef.Context, Params.data(), Params.size()); |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 429 | |
| 430 | if (InitMethodInstantiation(Constructor, D)) |
| 431 | Constructor->setInvalidDecl(); |
| 432 | |
| 433 | NamedDecl *PrevDecl |
| 434 | = SemaRef.LookupQualifiedName(Owner, Name, Sema::LookupOrdinaryName, true); |
| 435 | |
| 436 | // In C++, the previous declaration we find might be a tag type |
| 437 | // (class or enum). In this case, the new declaration will hide the |
| 438 | // tag type. Note that this does does not apply if we're declaring a |
| 439 | // typedef (C++ [dcl.typedef]p4). |
| 440 | if (PrevDecl && PrevDecl->getIdentifierNamespace() == Decl::IDNS_Tag) |
| 441 | PrevDecl = 0; |
| 442 | bool Redeclaration = false; |
| 443 | bool OverloadableAttrRequired = false; |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 444 | SemaRef.CheckFunctionDeclaration(Constructor, PrevDecl, Redeclaration, |
| 445 | /*FIXME:*/OverloadableAttrRequired); |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 446 | |
Douglas Gregor | 49f25ec | 2009-05-15 21:18:27 +0000 | [diff] [blame] | 447 | Record->addedConstructor(SemaRef.Context, Constructor); |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 448 | Owner->addDecl(Constructor); |
Douglas Gregor | 615c5d4 | 2009-03-24 16:43:20 +0000 | [diff] [blame] | 449 | return Constructor; |
| 450 | } |
| 451 | |
Douglas Gregor | 03b2b07 | 2009-03-24 00:15:49 +0000 | [diff] [blame] | 452 | Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 453 | // FIXME: Look for existing, explicit specializations. |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 454 | Sema::LocalInstantiationScope Scope(SemaRef); |
| 455 | |
Douglas Gregor | 0ca20ac | 2009-05-29 18:27:38 +0000 | [diff] [blame] | 456 | llvm::SmallVector<ParmVarDecl *, 4> Params; |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 457 | QualType T = InstantiateFunctionType(D, Params); |
Douglas Gregor | 03b2b07 | 2009-03-24 00:15:49 +0000 | [diff] [blame] | 458 | if (T.isNull()) |
| 459 | return 0; |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 460 | assert(Params.size() == 0 && "Destructor with parameters?"); |
| 461 | |
Douglas Gregor | 03b2b07 | 2009-03-24 00:15:49 +0000 | [diff] [blame] | 462 | // Build the instantiated destructor declaration. |
| 463 | CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner); |
Douglas Gregor | 49f25ec | 2009-05-15 21:18:27 +0000 | [diff] [blame] | 464 | QualType ClassTy = |
| 465 | SemaRef.Context.getCanonicalType(SemaRef.Context.getTypeDeclType(Record)); |
Douglas Gregor | 03b2b07 | 2009-03-24 00:15:49 +0000 | [diff] [blame] | 466 | CXXDestructorDecl *Destructor |
| 467 | = CXXDestructorDecl::Create(SemaRef.Context, Record, |
| 468 | D->getLocation(), |
| 469 | SemaRef.Context.DeclarationNames.getCXXDestructorName(ClassTy), |
| 470 | T, D->isInline(), false); |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 471 | Destructor->setInstantiationOfMemberFunction(D); |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 472 | if (InitMethodInstantiation(Destructor, D)) |
| 473 | Destructor->setInvalidDecl(); |
Douglas Gregor | 03b2b07 | 2009-03-24 00:15:49 +0000 | [diff] [blame] | 474 | |
| 475 | bool Redeclaration = false; |
| 476 | bool OverloadableAttrRequired = false; |
| 477 | NamedDecl *PrevDecl = 0; |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 478 | SemaRef.CheckFunctionDeclaration(Destructor, PrevDecl, Redeclaration, |
| 479 | /*FIXME:*/OverloadableAttrRequired); |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 480 | Owner->addDecl(Destructor); |
Douglas Gregor | 03b2b07 | 2009-03-24 00:15:49 +0000 | [diff] [blame] | 481 | return Destructor; |
| 482 | } |
| 483 | |
Douglas Gregor | bb969ed | 2009-03-25 00:34:44 +0000 | [diff] [blame] | 484 | Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) { |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 485 | // FIXME: Look for existing, explicit specializations. |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 486 | Sema::LocalInstantiationScope Scope(SemaRef); |
| 487 | |
Douglas Gregor | 0ca20ac | 2009-05-29 18:27:38 +0000 | [diff] [blame] | 488 | llvm::SmallVector<ParmVarDecl *, 4> Params; |
Douglas Gregor | bb969ed | 2009-03-25 00:34:44 +0000 | [diff] [blame] | 489 | QualType T = InstantiateFunctionType(D, Params); |
| 490 | if (T.isNull()) |
| 491 | return 0; |
| 492 | assert(Params.size() == 0 && "Destructor with parameters?"); |
| 493 | |
| 494 | // Build the instantiated conversion declaration. |
| 495 | CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner); |
| 496 | QualType ClassTy = SemaRef.Context.getTypeDeclType(Record); |
| 497 | QualType ConvTy |
| 498 | = SemaRef.Context.getCanonicalType(T->getAsFunctionType()->getResultType()); |
| 499 | CXXConversionDecl *Conversion |
| 500 | = CXXConversionDecl::Create(SemaRef.Context, Record, |
| 501 | D->getLocation(), |
| 502 | SemaRef.Context.DeclarationNames.getCXXConversionFunctionName(ConvTy), |
| 503 | T, D->isInline(), D->isExplicit()); |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 504 | Conversion->setInstantiationOfMemberFunction(D); |
Douglas Gregor | bb969ed | 2009-03-25 00:34:44 +0000 | [diff] [blame] | 505 | if (InitMethodInstantiation(Conversion, D)) |
| 506 | Conversion->setInvalidDecl(); |
| 507 | |
| 508 | bool Redeclaration = false; |
| 509 | bool OverloadableAttrRequired = false; |
| 510 | NamedDecl *PrevDecl = 0; |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 511 | SemaRef.CheckFunctionDeclaration(Conversion, PrevDecl, Redeclaration, |
| 512 | /*FIXME:*/OverloadableAttrRequired); |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 513 | Owner->addDecl(Conversion); |
Douglas Gregor | bb969ed | 2009-03-25 00:34:44 +0000 | [diff] [blame] | 514 | return Conversion; |
| 515 | } |
| 516 | |
Douglas Gregor | 6477b69 | 2009-03-25 15:04:13 +0000 | [diff] [blame] | 517 | ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) { |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 518 | QualType OrigT = SemaRef.InstantiateType(D->getOriginalType(), TemplateArgs, |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 519 | D->getLocation(), D->getDeclName()); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 520 | if (OrigT.isNull()) |
| 521 | return 0; |
| 522 | |
| 523 | QualType T = SemaRef.adjustParameterType(OrigT); |
| 524 | |
| 525 | if (D->getDefaultArg()) { |
| 526 | // FIXME: Leave a marker for "uninstantiated" default |
| 527 | // arguments. They only get instantiated on demand at the call |
| 528 | // site. |
| 529 | unsigned DiagID = SemaRef.Diags.getCustomDiagID(Diagnostic::Warning, |
| 530 | "sorry, dropping default argument during template instantiation"); |
| 531 | SemaRef.Diag(D->getDefaultArg()->getSourceRange().getBegin(), DiagID) |
| 532 | << D->getDefaultArg()->getSourceRange(); |
| 533 | } |
| 534 | |
| 535 | // Allocate the parameter |
| 536 | ParmVarDecl *Param = 0; |
| 537 | if (T == OrigT) |
| 538 | Param = ParmVarDecl::Create(SemaRef.Context, Owner, D->getLocation(), |
| 539 | D->getIdentifier(), T, D->getStorageClass(), |
| 540 | 0); |
| 541 | else |
| 542 | Param = OriginalParmVarDecl::Create(SemaRef.Context, Owner, |
| 543 | D->getLocation(), D->getIdentifier(), |
| 544 | T, OrigT, D->getStorageClass(), 0); |
| 545 | |
| 546 | // Note: we don't try to instantiate function parameters until after |
| 547 | // we've instantiated the function's type. Therefore, we don't have |
| 548 | // to check for 'void' parameter types here. |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 549 | SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param); |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 550 | return Param; |
| 551 | } |
| 552 | |
| 553 | Decl * |
| 554 | TemplateDeclInstantiator::VisitOriginalParmVarDecl(OriginalParmVarDecl *D) { |
| 555 | // Since parameter types can decay either before or after |
| 556 | // instantiation, we simply treat OriginalParmVarDecls as |
| 557 | // ParmVarDecls the same way, and create one or the other depending |
| 558 | // on what happens after template instantiation. |
| 559 | return VisitParmVarDecl(D); |
| 560 | } |
| 561 | |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 562 | Decl *Sema::InstantiateDecl(Decl *D, DeclContext *Owner, |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 563 | const TemplateArgumentList &TemplateArgs) { |
| 564 | TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 565 | return Instantiator.Visit(D); |
| 566 | } |
| 567 | |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 568 | /// \brief Instantiates the type of the given function, including |
| 569 | /// instantiating all of the function parameters. |
| 570 | /// |
| 571 | /// \param D The function that we will be instantiated |
| 572 | /// |
| 573 | /// \param Params the instantiated parameter declarations |
| 574 | |
| 575 | /// \returns the instantiated function's type if successfull, a NULL |
| 576 | /// type if there was an error. |
| 577 | QualType |
| 578 | TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D, |
| 579 | llvm::SmallVectorImpl<ParmVarDecl *> &Params) { |
| 580 | bool InvalidDecl = false; |
| 581 | |
| 582 | // Instantiate the function parameters |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 583 | TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs); |
Douglas Gregor | 0ca20ac | 2009-05-29 18:27:38 +0000 | [diff] [blame] | 584 | llvm::SmallVector<QualType, 4> ParamTys; |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 585 | for (FunctionDecl::param_iterator P = D->param_begin(), |
| 586 | PEnd = D->param_end(); |
| 587 | P != PEnd; ++P) { |
Douglas Gregor | 6477b69 | 2009-03-25 15:04:13 +0000 | [diff] [blame] | 588 | if (ParmVarDecl *PInst = ParamInstantiator.VisitParmVarDecl(*P)) { |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 589 | if (PInst->getType()->isVoidType()) { |
| 590 | SemaRef.Diag(PInst->getLocation(), diag::err_param_with_void_type); |
| 591 | PInst->setInvalidDecl(); |
| 592 | } |
| 593 | else if (SemaRef.RequireNonAbstractType(PInst->getLocation(), |
| 594 | PInst->getType(), |
| 595 | diag::err_abstract_type_in_decl, |
Anders Carlsson | 8211eff | 2009-03-24 01:19:16 +0000 | [diff] [blame] | 596 | Sema::AbstractParamType)) |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 597 | PInst->setInvalidDecl(); |
| 598 | |
| 599 | Params.push_back(PInst); |
| 600 | ParamTys.push_back(PInst->getType()); |
| 601 | |
| 602 | if (PInst->isInvalidDecl()) |
| 603 | InvalidDecl = true; |
| 604 | } else |
| 605 | InvalidDecl = true; |
| 606 | } |
| 607 | |
| 608 | // FIXME: Deallocate dead declarations. |
| 609 | if (InvalidDecl) |
| 610 | return QualType(); |
| 611 | |
| 612 | const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType(); |
| 613 | assert(Proto && "Missing prototype?"); |
| 614 | QualType ResultType |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 615 | = SemaRef.InstantiateType(Proto->getResultType(), TemplateArgs, |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 616 | D->getLocation(), D->getDeclName()); |
| 617 | if (ResultType.isNull()) |
| 618 | return QualType(); |
| 619 | |
Jay Foad | beaaccd | 2009-05-21 09:52:38 +0000 | [diff] [blame] | 620 | return SemaRef.BuildFunctionType(ResultType, ParamTys.data(), ParamTys.size(), |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 621 | Proto->isVariadic(), Proto->getTypeQuals(), |
| 622 | D->getLocation(), D->getDeclName()); |
| 623 | } |
| 624 | |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 625 | /// \brief Initializes the common fields of an instantiation function |
| 626 | /// declaration (New) from the corresponding fields of its template (Tmpl). |
| 627 | /// |
| 628 | /// \returns true if there was an error |
| 629 | bool |
| 630 | TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, |
| 631 | FunctionDecl *Tmpl) { |
| 632 | if (Tmpl->isDeleted()) |
| 633 | New->setDeleted(); |
Douglas Gregor | cca9e96 | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 634 | |
| 635 | // If we are performing substituting explicitly-specified template arguments |
| 636 | // or deduced template arguments into a function template and we reach this |
| 637 | // point, we are now past the point where SFINAE applies and have committed |
| 638 | // to keeping the new function template specialization. We therefore |
| 639 | // convert the active template instantiation for the function template |
| 640 | // into a template instantiation for this specific function template |
| 641 | // specialization, which is not a SFINAE context, so that we diagnose any |
| 642 | // further errors in the declaration itself. |
| 643 | typedef Sema::ActiveTemplateInstantiation ActiveInstType; |
| 644 | ActiveInstType &ActiveInst = SemaRef.ActiveTemplateInstantiations.back(); |
| 645 | if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution || |
| 646 | ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) { |
| 647 | if (FunctionTemplateDecl *FunTmpl |
| 648 | = dyn_cast<FunctionTemplateDecl>((Decl *)ActiveInst.Entity)) { |
| 649 | assert(FunTmpl->getTemplatedDecl() == Tmpl && |
| 650 | "Deduction from the wrong function template?"); |
Daniel Dunbar | bcbb8bd | 2009-07-16 22:10:11 +0000 | [diff] [blame] | 651 | (void) FunTmpl; |
Douglas Gregor | cca9e96 | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 652 | ActiveInst.Kind = ActiveInstType::TemplateInstantiation; |
| 653 | ActiveInst.Entity = reinterpret_cast<uintptr_t>(New); |
| 654 | } |
| 655 | } |
| 656 | |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 657 | return false; |
| 658 | } |
| 659 | |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 660 | /// \brief Initializes common fields of an instantiated method |
| 661 | /// declaration (New) from the corresponding fields of its template |
| 662 | /// (Tmpl). |
| 663 | /// |
| 664 | /// \returns true if there was an error |
| 665 | bool |
| 666 | TemplateDeclInstantiator::InitMethodInstantiation(CXXMethodDecl *New, |
| 667 | CXXMethodDecl *Tmpl) { |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 668 | if (InitFunctionInstantiation(New, Tmpl)) |
| 669 | return true; |
| 670 | |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 671 | CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner); |
| 672 | New->setAccess(Tmpl->getAccess()); |
Anders Carlsson | 77b7f1d | 2009-05-14 22:15:41 +0000 | [diff] [blame] | 673 | if (Tmpl->isVirtualAsWritten()) { |
| 674 | New->setVirtualAsWritten(true); |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 675 | Record->setAggregate(false); |
| 676 | Record->setPOD(false); |
| 677 | Record->setPolymorphic(true); |
| 678 | } |
Douglas Gregor | 5545e16 | 2009-03-24 00:38:23 +0000 | [diff] [blame] | 679 | if (Tmpl->isPure()) { |
| 680 | New->setPure(); |
| 681 | Record->setAbstract(true); |
| 682 | } |
| 683 | |
| 684 | // FIXME: attributes |
| 685 | // FIXME: New needs a pointer to Tmpl |
| 686 | return false; |
| 687 | } |
Douglas Gregor | a58861f | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 688 | |
| 689 | /// \brief Instantiate the definition of the given function from its |
| 690 | /// template. |
| 691 | /// |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 692 | /// \param PointOfInstantiation the point at which the instantiation was |
| 693 | /// required. Note that this is not precisely a "point of instantiation" |
| 694 | /// for the function, but it's close. |
| 695 | /// |
Douglas Gregor | a58861f | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 696 | /// \param Function the already-instantiated declaration of a |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 697 | /// function template specialization or member function of a class template |
| 698 | /// specialization. |
| 699 | /// |
| 700 | /// \param Recursive if true, recursively instantiates any functions that |
| 701 | /// are required by this instantiation. |
Douglas Gregor | f3e7ce4 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 702 | void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 703 | FunctionDecl *Function, |
| 704 | bool Recursive) { |
Douglas Gregor | 54dabfc | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 705 | if (Function->isInvalidDecl()) |
| 706 | return; |
| 707 | |
Argyrios Kyrtzidis | 6fb0aee | 2009-06-30 02:35:26 +0000 | [diff] [blame] | 708 | assert(!Function->getBody() && "Already instantiated!"); |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 709 | |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 710 | // Find the function body that we'll be substituting. |
Douglas Gregor | 1637be7 | 2009-06-26 00:10:03 +0000 | [diff] [blame] | 711 | const FunctionDecl *PatternDecl = 0; |
| 712 | if (FunctionTemplateDecl *Primary = Function->getPrimaryTemplate()) |
| 713 | PatternDecl = Primary->getTemplatedDecl(); |
| 714 | else |
| 715 | PatternDecl = Function->getInstantiatedFromMemberFunction(); |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 716 | Stmt *Pattern = 0; |
| 717 | if (PatternDecl) |
Argyrios Kyrtzidis | 6fb0aee | 2009-06-30 02:35:26 +0000 | [diff] [blame] | 718 | Pattern = PatternDecl->getBody(PatternDecl); |
Douglas Gregor | 1eee0e7 | 2009-05-14 21:06:31 +0000 | [diff] [blame] | 719 | |
| 720 | if (!Pattern) |
| 721 | return; |
| 722 | |
Douglas Gregor | f3e7ce4 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 723 | InstantiatingTemplate Inst(*this, PointOfInstantiation, Function); |
| 724 | if (Inst) |
| 725 | return; |
Douglas Gregor | b9f1b8d | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 726 | |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 727 | // If we're performing recursive template instantiation, create our own |
| 728 | // queue of pending implicit instantiations that we will instantiate later, |
| 729 | // while we're still within our own instantiation context. |
| 730 | std::deque<PendingImplicitInstantiation> SavedPendingImplicitInstantiations; |
| 731 | if (Recursive) |
| 732 | PendingImplicitInstantiations.swap(SavedPendingImplicitInstantiations); |
| 733 | |
Douglas Gregor | e2c31ff | 2009-05-15 17:59:04 +0000 | [diff] [blame] | 734 | ActOnStartOfFunctionDef(0, DeclPtrTy::make(Function)); |
| 735 | |
Douglas Gregor | 54dabfc | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 736 | // Introduce a new scope where local variable instantiations will be |
| 737 | // recorded. |
| 738 | LocalInstantiationScope Scope(*this); |
| 739 | |
| 740 | // Introduce the instantiated function parameters into the local |
| 741 | // instantiation scope. |
| 742 | for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I) |
| 743 | Scope.InstantiatedLocal(PatternDecl->getParamDecl(I), |
| 744 | Function->getParamDecl(I)); |
| 745 | |
Douglas Gregor | b9f1b8d | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 746 | // Enter the scope of this instantiation. We don't use |
| 747 | // PushDeclContext because we don't have a scope. |
| 748 | DeclContext *PreviousContext = CurContext; |
| 749 | CurContext = Function; |
| 750 | |
Douglas Gregor | 54dabfc | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 751 | // Instantiate the function body. |
| 752 | OwningStmtResult Body |
| 753 | = InstantiateStmt(Pattern, getTemplateInstantiationArgs(Function)); |
Douglas Gregor | e2c31ff | 2009-05-15 17:59:04 +0000 | [diff] [blame] | 754 | |
| 755 | ActOnFinishFunctionBody(DeclPtrTy::make(Function), move(Body), |
| 756 | /*IsInstantiation=*/true); |
Douglas Gregor | b9f1b8d | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 757 | |
| 758 | CurContext = PreviousContext; |
Douglas Gregor | aba43bb | 2009-05-26 20:50:29 +0000 | [diff] [blame] | 759 | |
| 760 | DeclGroupRef DG(Function); |
| 761 | Consumer.HandleTopLevelDecl(DG); |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 762 | |
| 763 | if (Recursive) { |
| 764 | // Instantiate any pending implicit instantiations found during the |
| 765 | // instantiation of this template. |
| 766 | PerformPendingImplicitInstantiations(); |
| 767 | |
| 768 | // Restore the set of pending implicit instantiations. |
| 769 | PendingImplicitInstantiations.swap(SavedPendingImplicitInstantiations); |
| 770 | } |
Douglas Gregor | a58861f | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | /// \brief Instantiate the definition of the given variable from its |
| 774 | /// template. |
| 775 | /// |
| 776 | /// \param Var the already-instantiated declaration of a variable. |
| 777 | void Sema::InstantiateVariableDefinition(VarDecl *Var) { |
| 778 | // FIXME: Implement this! |
| 779 | } |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 780 | |
| 781 | static bool isInstantiationOf(ASTContext &Ctx, NamedDecl *D, Decl *Other) { |
| 782 | if (D->getKind() != Other->getKind()) |
| 783 | return false; |
| 784 | |
| 785 | if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Other)) |
Argyrios Kyrtzidis | 97fbaa2 | 2009-07-18 00:34:25 +0000 | [diff] [blame] | 786 | return Record->getInstantiatedFromMemberClass()->getCanonicalDecl() |
| 787 | == D->getCanonicalDecl(); |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 788 | |
| 789 | if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Other)) |
Argyrios Kyrtzidis | 97fbaa2 | 2009-07-18 00:34:25 +0000 | [diff] [blame] | 790 | return Function->getInstantiatedFromMemberFunction()->getCanonicalDecl() |
| 791 | == D->getCanonicalDecl(); |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 792 | |
Douglas Gregor | 8dbc3c6 | 2009-05-27 17:20:35 +0000 | [diff] [blame] | 793 | if (EnumDecl *Enum = dyn_cast<EnumDecl>(Other)) |
Argyrios Kyrtzidis | 97fbaa2 | 2009-07-18 00:34:25 +0000 | [diff] [blame] | 794 | return Enum->getInstantiatedFromMemberEnum()->getCanonicalDecl() |
| 795 | == D->getCanonicalDecl(); |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 796 | |
| 797 | // FIXME: How can we find instantiations of anonymous unions? |
| 798 | |
| 799 | return D->getDeclName() && isa<NamedDecl>(Other) && |
| 800 | D->getDeclName() == cast<NamedDecl>(Other)->getDeclName(); |
| 801 | } |
| 802 | |
| 803 | template<typename ForwardIterator> |
| 804 | static NamedDecl *findInstantiationOf(ASTContext &Ctx, |
| 805 | NamedDecl *D, |
| 806 | ForwardIterator first, |
| 807 | ForwardIterator last) { |
| 808 | for (; first != last; ++first) |
| 809 | if (isInstantiationOf(Ctx, D, *first)) |
| 810 | return cast<NamedDecl>(*first); |
| 811 | |
| 812 | return 0; |
| 813 | } |
| 814 | |
Douglas Gregor | ed961e7 | 2009-05-27 17:54:46 +0000 | [diff] [blame] | 815 | /// \brief Find the instantiation of the given declaration within the |
| 816 | /// current instantiation. |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 817 | /// |
| 818 | /// This routine is intended to be used when \p D is a declaration |
| 819 | /// referenced from within a template, that needs to mapped into the |
| 820 | /// corresponding declaration within an instantiation. For example, |
| 821 | /// given: |
| 822 | /// |
| 823 | /// \code |
| 824 | /// template<typename T> |
| 825 | /// struct X { |
| 826 | /// enum Kind { |
| 827 | /// KnownValue = sizeof(T) |
| 828 | /// }; |
| 829 | /// |
| 830 | /// bool getKind() const { return KnownValue; } |
| 831 | /// }; |
| 832 | /// |
| 833 | /// template struct X<int>; |
| 834 | /// \endcode |
| 835 | /// |
| 836 | /// In the instantiation of X<int>::getKind(), we need to map the |
| 837 | /// EnumConstantDecl for KnownValue (which refers to |
| 838 | /// X<T>::<Kind>::KnownValue) to its instantiation |
Douglas Gregor | ed961e7 | 2009-05-27 17:54:46 +0000 | [diff] [blame] | 839 | /// (X<int>::<Kind>::KnownValue). InstantiateCurrentDeclRef() performs |
| 840 | /// this mapping from within the instantiation of X<int>. |
| 841 | NamedDecl * Sema::InstantiateCurrentDeclRef(NamedDecl *D) { |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 842 | DeclContext *ParentDC = D->getDeclContext(); |
Douglas Gregor | 2bba76b | 2009-05-27 17:07:49 +0000 | [diff] [blame] | 843 | if (isa<ParmVarDecl>(D) || ParentDC->isFunctionOrMethod()) { |
| 844 | // D is a local of some kind. Look into the map of local |
| 845 | // declarations to their instantiations. |
| 846 | return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D)); |
| 847 | } |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 848 | |
Douglas Gregor | 2bba76b | 2009-05-27 17:07:49 +0000 | [diff] [blame] | 849 | if (NamedDecl *ParentDecl = dyn_cast<NamedDecl>(ParentDC)) { |
Douglas Gregor | ed961e7 | 2009-05-27 17:54:46 +0000 | [diff] [blame] | 850 | ParentDecl = InstantiateCurrentDeclRef(ParentDecl); |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 851 | if (!ParentDecl) |
| 852 | return 0; |
| 853 | |
| 854 | ParentDC = cast<DeclContext>(ParentDecl); |
| 855 | } |
| 856 | |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 857 | if (ParentDC != D->getDeclContext()) { |
| 858 | // We performed some kind of instantiation in the parent context, |
| 859 | // so now we need to look into the instantiated parent context to |
| 860 | // find the instantiation of the declaration D. |
| 861 | NamedDecl *Result = 0; |
| 862 | if (D->getDeclName()) { |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 863 | DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName()); |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 864 | Result = findInstantiationOf(Context, D, Found.first, Found.second); |
| 865 | } else { |
| 866 | // Since we don't have a name for the entity we're looking for, |
| 867 | // our only option is to walk through all of the declarations to |
| 868 | // find that name. This will occur in a few cases: |
| 869 | // |
| 870 | // - anonymous struct/union within a template |
| 871 | // - unnamed class/struct/union/enum within a template |
| 872 | // |
| 873 | // FIXME: Find a better way to find these instantiations! |
| 874 | Result = findInstantiationOf(Context, D, |
Argyrios Kyrtzidis | 17945a0 | 2009-06-30 02:36:12 +0000 | [diff] [blame] | 875 | ParentDC->decls_begin(), |
| 876 | ParentDC->decls_end()); |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 877 | } |
| 878 | assert(Result && "Unable to find instantiation of declaration!"); |
| 879 | D = Result; |
| 880 | } |
| 881 | |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 882 | if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) |
Douglas Gregor | ed961e7 | 2009-05-27 17:54:46 +0000 | [diff] [blame] | 883 | if (ClassTemplateDecl *ClassTemplate |
| 884 | = Record->getDescribedClassTemplate()) { |
| 885 | // When the declaration D was parsed, it referred to the current |
| 886 | // instantiation. Therefore, look through the current context, |
| 887 | // which contains actual instantiations, to find the |
| 888 | // instantiation of the "current instantiation" that D refers |
| 889 | // to. Alternatively, we could just instantiate the |
| 890 | // injected-class-name with the current template arguments, but |
| 891 | // such an instantiation is far more expensive. |
| 892 | for (DeclContext *DC = CurContext; !DC->isFileContext(); |
| 893 | DC = DC->getParent()) { |
| 894 | if (ClassTemplateSpecializationDecl *Spec |
| 895 | = dyn_cast<ClassTemplateSpecializationDecl>(DC)) |
Argyrios Kyrtzidis | 97fbaa2 | 2009-07-18 00:34:25 +0000 | [diff] [blame] | 896 | if (Spec->getSpecializedTemplate()->getCanonicalDecl() |
| 897 | == ClassTemplate->getCanonicalDecl()) |
Douglas Gregor | ed961e7 | 2009-05-27 17:54:46 +0000 | [diff] [blame] | 898 | return Spec; |
| 899 | } |
| 900 | |
| 901 | assert(false && |
| 902 | "Unable to find declaration for the current instantiation"); |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | return D; |
| 906 | } |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 907 | |
| 908 | /// \brief Performs template instantiation for all implicit template |
| 909 | /// instantiations we have seen until this point. |
| 910 | void Sema::PerformPendingImplicitInstantiations() { |
| 911 | while (!PendingImplicitInstantiations.empty()) { |
| 912 | PendingImplicitInstantiation Inst = PendingImplicitInstantiations.front(); |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 913 | PendingImplicitInstantiations.pop_front(); |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 914 | |
| 915 | if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Inst.first)) |
Argyrios Kyrtzidis | 6fb0aee | 2009-06-30 02:35:26 +0000 | [diff] [blame] | 916 | if (!Function->getBody()) |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 917 | InstantiateFunctionDefinition(/*FIXME:*/Inst.second, Function, true); |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 918 | |
Douglas Gregor | 751f9a4 | 2009-06-30 15:47:41 +0000 | [diff] [blame] | 919 | // FIXME: instantiate static member variables |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 920 | } |
| 921 | } |