SemaTemplateInstantiate.cpp revision 56d25a726f0bdb4db08021b9e98782ada5241eaf
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" 14#include "clang/AST/ASTContext.h" 15#include "clang/AST/Expr.h" 16#include "clang/AST/ExprCXX.h" 17#include "clang/AST/DeclTemplate.h" 18#include "clang/Parse/DeclSpec.h" 19#include "clang/Basic/LangOptions.h" 20#include "llvm/Support/Compiler.h" 21 22using namespace clang; 23 24//===----------------------------------------------------------------------===/ 25// Template Instantiation Support 26//===----------------------------------------------------------------------===/ 27 28Sema::InstantiatingTemplate:: 29InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 30 ClassTemplateSpecializationDecl *Entity, 31 SourceRange InstantiationRange) 32 : SemaRef(SemaRef) { 33 34 Invalid = CheckInstantiationDepth(PointOfInstantiation, 35 InstantiationRange); 36 if (!Invalid) { 37 ActiveTemplateInstantiation Inst; 38 Inst.Kind = ActiveTemplateInstantiation::TemplateInstantiation; 39 Inst.PointOfInstantiation = PointOfInstantiation; 40 Inst.Entity = reinterpret_cast<uintptr_t>(Entity); 41 Inst.InstantiationRange = InstantiationRange; 42 SemaRef.ActiveTemplateInstantiations.push_back(Inst); 43 Invalid = false; 44 } 45} 46 47Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef, 48 SourceLocation PointOfInstantiation, 49 TemplateDecl *Template, 50 const TemplateArgument *TemplateArgs, 51 unsigned NumTemplateArgs, 52 SourceRange InstantiationRange) 53 : SemaRef(SemaRef) { 54 55 Invalid = CheckInstantiationDepth(PointOfInstantiation, 56 InstantiationRange); 57 if (!Invalid) { 58 ActiveTemplateInstantiation Inst; 59 Inst.Kind 60 = ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation; 61 Inst.PointOfInstantiation = PointOfInstantiation; 62 Inst.Entity = reinterpret_cast<uintptr_t>(Template); 63 Inst.TemplateArgs = TemplateArgs; 64 Inst.NumTemplateArgs = NumTemplateArgs; 65 Inst.InstantiationRange = InstantiationRange; 66 SemaRef.ActiveTemplateInstantiations.push_back(Inst); 67 Invalid = false; 68 } 69} 70 71Sema::InstantiatingTemplate::~InstantiatingTemplate() { 72 if (!Invalid) 73 SemaRef.ActiveTemplateInstantiations.pop_back(); 74} 75 76bool Sema::InstantiatingTemplate::CheckInstantiationDepth( 77 SourceLocation PointOfInstantiation, 78 SourceRange InstantiationRange) { 79 if (SemaRef.ActiveTemplateInstantiations.size() 80 <= SemaRef.getLangOptions().InstantiationDepth) 81 return false; 82 83 SemaRef.Diag(PointOfInstantiation, 84 diag::err_template_recursion_depth_exceeded) 85 << SemaRef.getLangOptions().InstantiationDepth 86 << InstantiationRange; 87 SemaRef.Diag(PointOfInstantiation, diag::note_template_recursion_depth) 88 << SemaRef.getLangOptions().InstantiationDepth; 89 return true; 90} 91 92/// \brief Post-diagnostic hook for printing the instantiation stack. 93void Sema::PrintInstantiationStackHook(unsigned, void *Cookie) { 94 Sema &SemaRef = *static_cast<Sema*>(Cookie); 95 SemaRef.PrintInstantiationStack(); 96 SemaRef.LastTemplateInstantiationErrorContext 97 = SemaRef.ActiveTemplateInstantiations.back(); 98} 99 100/// \brief Prints the current instantiation stack through a series of 101/// notes. 102void Sema::PrintInstantiationStack() { 103 for (llvm::SmallVector<ActiveTemplateInstantiation, 16>::reverse_iterator 104 Active = ActiveTemplateInstantiations.rbegin(), 105 ActiveEnd = ActiveTemplateInstantiations.rend(); 106 Active != ActiveEnd; 107 ++Active) { 108 switch (Active->Kind) { 109 case ActiveTemplateInstantiation::TemplateInstantiation: { 110 ClassTemplateSpecializationDecl *Spec 111 = cast<ClassTemplateSpecializationDecl>((Decl*)Active->Entity); 112 Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr), 113 diag::note_template_class_instantiation_here) 114 << Context.getTypeDeclType(Spec) 115 << Active->InstantiationRange; 116 break; 117 } 118 119 case ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation: { 120 TemplateDecl *Template = cast<TemplateDecl>((Decl *)Active->Entity); 121 std::string TemplateArgsStr 122 = ClassTemplateSpecializationType::PrintTemplateArgumentList( 123 Active->TemplateArgs, 124 Active->NumTemplateArgs); 125 Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr), 126 diag::note_default_arg_instantiation_here) 127 << (Template->getNameAsString() + TemplateArgsStr) 128 << Active->InstantiationRange; 129 break; 130 } 131 } 132 } 133} 134 135//===----------------------------------------------------------------------===/ 136// Template Instantiation for Types 137//===----------------------------------------------------------------------===/ 138namespace { 139 class VISIBILITY_HIDDEN TemplateTypeInstantiator { 140 Sema &SemaRef; 141 const TemplateArgument *TemplateArgs; 142 unsigned NumTemplateArgs; 143 SourceLocation Loc; 144 DeclarationName Entity; 145 146 public: 147 TemplateTypeInstantiator(Sema &SemaRef, 148 const TemplateArgument *TemplateArgs, 149 unsigned NumTemplateArgs, 150 SourceLocation Loc, 151 DeclarationName Entity) 152 : SemaRef(SemaRef), TemplateArgs(TemplateArgs), 153 NumTemplateArgs(NumTemplateArgs), Loc(Loc), Entity(Entity) { } 154 155 QualType operator()(QualType T) const { return Instantiate(T); } 156 157 QualType Instantiate(QualType T) const; 158 159 // Declare instantiate functions for each type. 160#define TYPE(Class, Base) \ 161 QualType Instantiate##Class##Type(const Class##Type *T, \ 162 unsigned Quals) const; 163#define ABSTRACT_TYPE(Class, Base) 164#include "clang/AST/TypeNodes.def" 165 }; 166} 167 168QualType 169TemplateTypeInstantiator::InstantiateExtQualType(const ExtQualType *T, 170 unsigned Quals) const { 171 // FIXME: Implement this 172 assert(false && "Cannot instantiate ExtQualType yet"); 173 return QualType(); 174} 175 176QualType 177TemplateTypeInstantiator::InstantiateBuiltinType(const BuiltinType *T, 178 unsigned Quals) const { 179 assert(false && "Builtin types are not dependent and cannot be instantiated"); 180 return QualType(T, Quals); 181} 182 183QualType 184TemplateTypeInstantiator:: 185InstantiateFixedWidthIntType(const FixedWidthIntType *T, unsigned Quals) const { 186 // FIXME: Implement this 187 assert(false && "Cannot instantiate FixedWidthIntType yet"); 188 return QualType(); 189} 190 191QualType 192TemplateTypeInstantiator::InstantiateComplexType(const ComplexType *T, 193 unsigned Quals) const { 194 // FIXME: Implement this 195 assert(false && "Cannot instantiate ComplexType yet"); 196 return QualType(); 197} 198 199QualType 200TemplateTypeInstantiator::InstantiatePointerType(const PointerType *T, 201 unsigned Quals) const { 202 QualType PointeeType = Instantiate(T->getPointeeType()); 203 if (PointeeType.isNull()) 204 return QualType(); 205 206 return SemaRef.BuildPointerType(PointeeType, Quals, Loc, Entity); 207} 208 209QualType 210TemplateTypeInstantiator::InstantiateBlockPointerType(const BlockPointerType *T, 211 unsigned Quals) const { 212 // FIXME: Implement this 213 assert(false && "Cannot instantiate BlockPointerType yet"); 214 return QualType(); 215} 216 217QualType 218TemplateTypeInstantiator::InstantiateReferenceType(const ReferenceType *T, 219 unsigned Quals) const { 220 QualType ReferentType = Instantiate(T->getPointeeType()); 221 if (ReferentType.isNull()) 222 return QualType(); 223 224 return SemaRef.BuildReferenceType(ReferentType, Quals, Loc, Entity); 225} 226 227QualType 228TemplateTypeInstantiator:: 229InstantiateMemberPointerType(const MemberPointerType *T, 230 unsigned Quals) const { 231 // FIXME: Implement this 232 assert(false && "Cannot instantiate MemberPointerType yet"); 233 return QualType(); 234} 235 236QualType 237TemplateTypeInstantiator:: 238InstantiateConstantArrayType(const ConstantArrayType *T, 239 unsigned Quals) const { 240 QualType ElementType = Instantiate(T->getElementType()); 241 if (ElementType.isNull()) 242 return ElementType; 243 244 // Build a temporary integer literal to specify the size for 245 // BuildArrayType. Since we have already checked the size as part of 246 // creating the dependent array type in the first place, we know 247 // there aren't any errors. 248 // FIXME: Is IntTy big enough? Maybe not, but LongLongTy causes 249 // problems that I have yet to investigate. 250 IntegerLiteral ArraySize(T->getSize(), SemaRef.Context.IntTy, Loc); 251 return SemaRef.BuildArrayType(ElementType, T->getSizeModifier(), 252 &ArraySize, T->getIndexTypeQualifier(), 253 Loc, Entity); 254} 255 256QualType 257TemplateTypeInstantiator:: 258InstantiateIncompleteArrayType(const IncompleteArrayType *T, 259 unsigned Quals) const { 260 QualType ElementType = Instantiate(T->getElementType()); 261 if (ElementType.isNull()) 262 return ElementType; 263 264 return SemaRef.BuildArrayType(ElementType, T->getSizeModifier(), 265 0, T->getIndexTypeQualifier(), 266 Loc, Entity); 267} 268 269QualType 270TemplateTypeInstantiator:: 271InstantiateVariableArrayType(const VariableArrayType *T, 272 unsigned Quals) const { 273 // FIXME: Implement this 274 assert(false && "Cannot instantiate VariableArrayType yet"); 275 return QualType(); 276} 277 278QualType 279TemplateTypeInstantiator:: 280InstantiateDependentSizedArrayType(const DependentSizedArrayType *T, 281 unsigned Quals) const { 282 // FIXME: Implement this 283 assert(false && "Cannot instantiate DependentSizedArrayType yet"); 284 return QualType(); 285} 286 287QualType 288TemplateTypeInstantiator::InstantiateVectorType(const VectorType *T, 289 unsigned Quals) const { 290 // FIXME: Implement this 291 assert(false && "Cannot instantiate VectorType yet"); 292 return QualType(); 293} 294 295QualType 296TemplateTypeInstantiator::InstantiateExtVectorType(const ExtVectorType *T, 297 unsigned Quals) const { 298 // FIXME: Implement this 299 assert(false && "Cannot instantiate ExtVectorType yet"); 300 return QualType(); 301} 302 303QualType 304TemplateTypeInstantiator:: 305InstantiateFunctionProtoType(const FunctionProtoType *T, 306 unsigned Quals) const { 307 QualType ResultType = Instantiate(T->getResultType()); 308 if (ResultType.isNull()) 309 return ResultType; 310 311 llvm::SmallVector<QualType, 16> ParamTypes; 312 for (FunctionProtoType::arg_type_iterator Param = T->arg_type_begin(), 313 ParamEnd = T->arg_type_end(); 314 Param != ParamEnd; ++Param) { 315 QualType P = Instantiate(*Param); 316 if (P.isNull()) 317 return P; 318 319 ParamTypes.push_back(P); 320 } 321 322 return SemaRef.BuildFunctionType(ResultType, &ParamTypes[0], 323 ParamTypes.size(), 324 T->isVariadic(), T->getTypeQuals(), 325 Loc, Entity); 326} 327 328QualType 329TemplateTypeInstantiator:: 330InstantiateFunctionNoProtoType(const FunctionNoProtoType *T, 331 unsigned Quals) const { 332 assert(false && "Functions without prototypes cannot be dependent."); 333 return QualType(); 334} 335 336QualType 337TemplateTypeInstantiator::InstantiateTypedefType(const TypedefType *T, 338 unsigned Quals) const { 339 // FIXME: Implement this 340 assert(false && "Cannot instantiate TypedefType yet"); 341 return QualType(); 342} 343 344QualType 345TemplateTypeInstantiator::InstantiateTypeOfExprType(const TypeOfExprType *T, 346 unsigned Quals) const { 347 // FIXME: Implement this 348 assert(false && "Cannot instantiate TypeOfExprType yet"); 349 return QualType(); 350} 351 352QualType 353TemplateTypeInstantiator::InstantiateTypeOfType(const TypeOfType *T, 354 unsigned Quals) const { 355 // FIXME: Implement this 356 assert(false && "Cannot instantiate TypeOfType yet"); 357 return QualType(); 358} 359 360QualType 361TemplateTypeInstantiator::InstantiateRecordType(const RecordType *T, 362 unsigned Quals) const { 363 // FIXME: Implement this 364 assert(false && "Cannot instantiate RecordType yet"); 365 return QualType(); 366} 367 368QualType 369TemplateTypeInstantiator::InstantiateEnumType(const EnumType *T, 370 unsigned Quals) const { 371 // FIXME: Implement this 372 assert(false && "Cannot instantiate EnumType yet"); 373 return QualType(); 374} 375 376QualType 377TemplateTypeInstantiator:: 378InstantiateTemplateTypeParmType(const TemplateTypeParmType *T, 379 unsigned Quals) const { 380 if (T->getDepth() == 0) { 381 // Replace the template type parameter with its corresponding 382 // template argument. 383 assert(T->getIndex() < NumTemplateArgs && "Wrong # of template args"); 384 assert(TemplateArgs[T->getIndex()].getKind() == TemplateArgument::Type && 385 "Template argument kind mismatch"); 386 QualType Result = TemplateArgs[T->getIndex()].getAsType(); 387 if (Result.isNull() || !Quals) 388 return Result; 389 390 // C++ [dcl.ref]p1: 391 // [...] Cv-qualified references are ill-formed except when 392 // the cv-qualifiers are introduced through the use of a 393 // typedef (7.1.3) or of a template type argument (14.3), in 394 // which case the cv-qualifiers are ignored. 395 if (Quals && Result->isReferenceType()) 396 Quals = 0; 397 398 return QualType(Result.getTypePtr(), Quals | Result.getCVRQualifiers()); 399 } 400 401 // The template type parameter comes from an inner template (e.g., 402 // the template parameter list of a member template inside the 403 // template we are instantiating). Create a new template type 404 // parameter with the template "level" reduced by one. 405 return SemaRef.Context.getTemplateTypeParmType(T->getDepth() - 1, 406 T->getIndex(), 407 T->getName()) 408 .getQualifiedType(Quals); 409} 410 411QualType 412TemplateTypeInstantiator:: 413InstantiateClassTemplateSpecializationType( 414 const ClassTemplateSpecializationType *T, 415 unsigned Quals) const { 416 llvm::SmallVector<TemplateArgument, 16> InstantiatedTemplateArgs; 417 InstantiatedTemplateArgs.reserve(T->getNumArgs()); 418 for (ClassTemplateSpecializationType::iterator Arg = T->begin(), 419 ArgEnd = T->end(); 420 Arg != ArgEnd; ++Arg) { 421 switch (Arg->getKind()) { 422 case TemplateArgument::Type: { 423 QualType T = SemaRef.InstantiateType(Arg->getAsType(), 424 TemplateArgs, NumTemplateArgs, 425 Arg->getLocation(), 426 DeclarationName()); 427 if (T.isNull()) 428 return QualType(); 429 430 InstantiatedTemplateArgs.push_back( 431 TemplateArgument(Arg->getLocation(), T)); 432 break; 433 } 434 435 case TemplateArgument::Declaration: 436 case TemplateArgument::Integral: 437 InstantiatedTemplateArgs.push_back(*Arg); 438 break; 439 440 case TemplateArgument::Expression: 441 assert(false && "Cannot instantiate expressions yet"); 442 break; 443 } 444 } 445 446 // FIXME: We're missing the locations of the template name, '<', and 447 // '>'. 448 return SemaRef.CheckClassTemplateId(cast<ClassTemplateDecl>(T->getTemplate()), 449 Loc, 450 SourceLocation(), 451 &InstantiatedTemplateArgs[0], 452 InstantiatedTemplateArgs.size(), 453 SourceLocation()); 454} 455 456QualType 457TemplateTypeInstantiator:: 458InstantiateObjCInterfaceType(const ObjCInterfaceType *T, 459 unsigned Quals) const { 460 assert(false && "Objective-C types cannot be dependent"); 461 return QualType(); 462} 463 464QualType 465TemplateTypeInstantiator:: 466InstantiateObjCQualifiedInterfaceType(const ObjCQualifiedInterfaceType *T, 467 unsigned Quals) const { 468 assert(false && "Objective-C types cannot be dependent"); 469 return QualType(); 470} 471 472QualType 473TemplateTypeInstantiator:: 474InstantiateObjCQualifiedIdType(const ObjCQualifiedIdType *T, 475 unsigned Quals) const { 476 assert(false && "Objective-C types cannot be dependent"); 477 return QualType(); 478} 479 480QualType 481TemplateTypeInstantiator:: 482InstantiateObjCQualifiedClassType(const ObjCQualifiedClassType *T, 483 unsigned Quals) const { 484 assert(false && "Objective-C types cannot be dependent"); 485 return QualType(); 486} 487 488/// \brief The actual implementation of Sema::InstantiateType(). 489QualType TemplateTypeInstantiator::Instantiate(QualType T) const { 490 // If T is not a dependent type, there is nothing to do. 491 if (!T->isDependentType()) 492 return T; 493 494 switch (T->getTypeClass()) { 495#define TYPE(Class, Base) \ 496 case Type::Class: \ 497 return Instantiate##Class##Type(cast<Class##Type>(T.getTypePtr()), \ 498 T.getCVRQualifiers()); 499#define ABSTRACT_TYPE(Class, Base) 500#include "clang/AST/TypeNodes.def" 501 } 502 503 assert(false && "Not all types have been decoded for instantiation"); 504 return QualType(); 505} 506 507/// \brief Instantiate the type T with a given set of template arguments. 508/// 509/// This routine substitutes the given template arguments into the 510/// type T and produces the instantiated type. 511/// 512/// \param T the type into which the template arguments will be 513/// substituted. If this type is not dependent, it will be returned 514/// immediately. 515/// 516/// \param TemplateArgs the template arguments that will be 517/// substituted for the top-level template parameters within T. 518/// 519/// \param NumTemplateArgs the number of template arguments provided 520/// by TemplateArgs. 521/// 522/// \param Loc the location in the source code where this substitution 523/// is being performed. It will typically be the location of the 524/// declarator (if we're instantiating the type of some declaration) 525/// or the location of the type in the source code (if, e.g., we're 526/// instantiating the type of a cast expression). 527/// 528/// \param Entity the name of the entity associated with a declaration 529/// being instantiated (if any). May be empty to indicate that there 530/// is no such entity (if, e.g., this is a type that occurs as part of 531/// a cast expression) or that the entity has no name (e.g., an 532/// unnamed function parameter). 533/// 534/// \returns If the instantiation succeeds, the instantiated 535/// type. Otherwise, produces diagnostics and returns a NULL type. 536QualType Sema::InstantiateType(QualType T, 537 const TemplateArgument *TemplateArgs, 538 unsigned NumTemplateArgs, 539 SourceLocation Loc, DeclarationName Entity) { 540 assert(!ActiveTemplateInstantiations.empty() && 541 "Cannot perform an instantiation without some context on the " 542 "instantiation stack"); 543 544 // If T is not a dependent type, there is nothing to do. 545 if (!T->isDependentType()) 546 return T; 547 548 TemplateTypeInstantiator Instantiator(*this, TemplateArgs, NumTemplateArgs, 549 Loc, Entity); 550 return Instantiator(T); 551} 552 553/// \brief Instantiate the base class specifiers of the given class 554/// template specialization. 555/// 556/// Produces a diagnostic and returns true on error, returns false and 557/// attaches the instantiated base classes to the class template 558/// specialization if successful. 559bool 560Sema::InstantiateBaseSpecifiers( 561 ClassTemplateSpecializationDecl *ClassTemplateSpec, 562 ClassTemplateDecl *ClassTemplate) { 563 bool Invalid = false; 564 llvm::SmallVector<CXXBaseSpecifier*, 8> InstantiatedBases; 565 for (ClassTemplateSpecializationDecl::base_class_iterator 566 Base = ClassTemplate->getTemplatedDecl()->bases_begin(), 567 BaseEnd = ClassTemplate->getTemplatedDecl()->bases_end(); 568 Base != BaseEnd; ++Base) { 569 if (!Base->getType()->isDependentType()) { 570 // FIXME: Allocate via ASTContext 571 InstantiatedBases.push_back(new CXXBaseSpecifier(*Base)); 572 continue; 573 } 574 575 QualType BaseType = InstantiateType(Base->getType(), 576 ClassTemplateSpec->getTemplateArgs(), 577 ClassTemplateSpec->getNumTemplateArgs(), 578 Base->getSourceRange().getBegin(), 579 DeclarationName()); 580 if (BaseType.isNull()) { 581 Invalid = true; 582 continue; 583 } 584 585 if (CXXBaseSpecifier *InstantiatedBase 586 = CheckBaseSpecifier(ClassTemplateSpec, 587 Base->getSourceRange(), 588 Base->isVirtual(), 589 Base->getAccessSpecifierAsWritten(), 590 BaseType, 591 /*FIXME: Not totally accurate */ 592 Base->getSourceRange().getBegin())) 593 InstantiatedBases.push_back(InstantiatedBase); 594 else 595 Invalid = true; 596 } 597 598 if (!Invalid && 599 AttachBaseSpecifiers(ClassTemplateSpec, &InstantiatedBases[0], 600 InstantiatedBases.size())) 601 Invalid = true; 602 603 return Invalid; 604} 605 606bool 607Sema::InstantiateClassTemplateSpecialization( 608 ClassTemplateSpecializationDecl *ClassTemplateSpec, 609 bool ExplicitInstantiation) { 610 // Perform the actual instantiation on the canonical declaration. 611 ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>( 612 Context.getCanonicalDecl(ClassTemplateSpec)); 613 614 // We can only instantiate something that hasn't already been 615 // instantiated or specialized. Fail without any diagnostics: our 616 // caller will provide an error message. 617 if (ClassTemplateSpec->getSpecializationKind() != TSK_Undeclared) 618 return true; 619 620 // FIXME: Push this class template instantiation onto the 621 // instantiation stack, checking for recursion that exceeds a 622 // certain depth. 623 624 // FIXME: Perform class template partial specialization to select 625 // the best template. 626 ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate(); 627 628 if (!Template->getTemplatedDecl()->getDefinition(Context)) { 629 Diag(ClassTemplateSpec->getLocation(), 630 diag::err_template_implicit_instantiate_undefined) 631 << Context.getTypeDeclType(ClassTemplateSpec); 632 Diag(Template->getTemplatedDecl()->getLocation(), 633 diag::note_template_decl_here); 634 return true; 635 } 636 637 // Note that this is an instantiation. 638 ClassTemplateSpec->setSpecializationKind( 639 ExplicitInstantiation? TSK_ExplicitInstantiation 640 : TSK_ImplicitInstantiation); 641 642 643 bool Invalid = false; 644 645 InstantiatingTemplate Inst(*this, ClassTemplateSpec->getLocation(), 646 ClassTemplateSpec); 647 if (Inst) 648 return true; 649 650 // Enter the scope of this instantiation. We don't use 651 // PushDeclContext because we don't have a scope. 652 DeclContext *PreviousContext = CurContext; 653 CurContext = ClassTemplateSpec; 654 655 // Start the definition of this instantiation. 656 ClassTemplateSpec->startDefinition(); 657 658 // FIXME: Create the injected-class-name for the 659 // instantiation. Should this be a typedef or something like it? 660 661 // Instantiate the base class specifiers. 662 if (InstantiateBaseSpecifiers(ClassTemplateSpec, Template)) 663 Invalid = true; 664 665 // FIXME: Instantiate all of the members. 666 667 // Add any implicitly-declared members that we might need. 668 AddImplicitlyDeclaredMembersToClass(ClassTemplateSpec); 669 670 // Finish the definition of this instantiation. 671 // FIXME: ActOnFields does more checking, which we'll eventually need. 672 ClassTemplateSpec->completeDefinition(Context); 673 674 // Exit the scope of this instantiation. 675 CurContext = PreviousContext; 676 677 return Invalid; 678} 679