diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 13:34:49 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 13:34:49 +0000 | 
| commit | 0623d7483df5fc17b32ba7bc5cb9c7beebf6db9c (patch) | |
| tree | 28726ef2038e86121e353aabf52297b35a48efa2 /contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
| parent | 7d523365ff1a3cc95bc058b33102500f61e8166d (diff) | |
| parent | 45b533945f0851ec234ca846e1af5ee1e4df0b6e (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 57 | 
1 files changed, 32 insertions, 25 deletions
| diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index aff2d1c96676..7a452af77839 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -813,6 +813,14 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {    Enum->setAccess(D->getAccess());    // Forward the mangling number from the template to the instantiated decl.    SemaRef.Context.setManglingNumber(Enum, SemaRef.Context.getManglingNumber(D)); +  // See if the old tag was defined along with a declarator. +  // If it did, mark the new tag as being associated with that declarator. +  if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D)) +    SemaRef.Context.addDeclaratorForUnnamedTagDecl(Enum, DD); +  // See if the old tag was defined along with a typedef. +  // If it did, mark the new tag as being associated with that typedef. +  if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D)) +    SemaRef.Context.addTypedefNameForUnnamedTagDecl(Enum, TND);    if (SubstQualifier(D, Enum)) return nullptr;    Owner->addDecl(Enum); @@ -827,7 +835,8 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {          SemaRef.SubstType(TI->getType(), TemplateArgs,                            UnderlyingLoc, DeclarationName());        SemaRef.CheckEnumRedeclaration(Def->getLocation(), Def->isScoped(), -                                     DefnUnderlying, Enum); +                                     DefnUnderlying, +                                     /*EnumUnderlyingIsImplicit=*/false, Enum);      }    } @@ -913,6 +922,11 @@ Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) {    llvm_unreachable("EnumConstantDecls can only occur within EnumDecls.");  } +Decl * +TemplateDeclInstantiator::VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D) { +  llvm_unreachable("BuiltinTemplateDecls cannot be instantiated."); +} +  Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {    bool isFriend = (D->getFriendObjectKind() != Decl::FOK_None); @@ -1143,6 +1157,7 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateDecl(VarTemplateDecl *D) {    VarDecl *VarInst =        cast_or_null<VarDecl>(VisitVarDecl(Pattern,                                           /*InstantiatingVarTemplate=*/true)); +  if (!VarInst) return nullptr;    DeclContext *DC = Owner; @@ -1297,6 +1312,16 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) {    SemaRef.Context.setManglingNumber(Record,                                      SemaRef.Context.getManglingNumber(D)); +  // See if the old tag was defined along with a declarator. +  // If it did, mark the new tag as being associated with that declarator. +  if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D)) +    SemaRef.Context.addDeclaratorForUnnamedTagDecl(Record, DD); + +  // See if the old tag was defined along with a typedef. +  // If it did, mark the new tag as being associated with that typedef. +  if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D)) +    SemaRef.Context.addTypedefNameForUnnamedTagDecl(Record, TND); +    Owner->addDecl(Record);    // DR1484 clarifies that the members of a local class are instantiated as part @@ -1657,7 +1682,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,    SmallVector<TemplateParameterList *, 4> TempParamLists;    unsigned NumTempParamLists = 0;    if (isFriend && (NumTempParamLists = D->getNumTemplateParameterLists())) { -    TempParamLists.set_size(NumTempParamLists); +    TempParamLists.resize(NumTempParamLists);      for (unsigned I = 0; I != NumTempParamLists; ++I) {        TemplateParameterList *TempParams = D->getTemplateParameterList(I);        TemplateParameterList *InstParams = SubstTemplateParams(TempParams); @@ -1809,9 +1834,9 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,    // context (which will be a namespace scope) as the template.    if (isFriend) {      if (NumTempParamLists) -      Method->setTemplateParameterListsInfo(SemaRef.Context, -                                            NumTempParamLists, -                                            TempParamLists.data()); +      Method->setTemplateParameterListsInfo( +          SemaRef.Context, +          llvm::makeArrayRef(TempParamLists.data(), NumTempParamLists));      Method->setLexicalDeclContext(Owner);      Method->setObjectOfFriendDecl(); @@ -2742,7 +2767,7 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) {    TemplateParameterList *InstL      = TemplateParameterList::Create(SemaRef.Context, L->getTemplateLoc(), -                                    L->getLAngleLoc(), &Params.front(), N, +                                    L->getLAngleLoc(), Params,                                      L->getRAngleLoc());    return InstL;  } @@ -3246,16 +3271,11 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,      // exception specification.      // DR1484: Local classes and their members are instantiated along with the      // containing function. -    bool RequireInstantiation = false; -    if (CXXRecordDecl *Cls = dyn_cast<CXXRecordDecl>(Tmpl->getDeclContext())) { -      if (Cls->isLocalClass()) -        RequireInstantiation = true; -    }      if (SemaRef.getLangOpts().CPlusPlus11 &&          EPI.ExceptionSpec.Type != EST_None &&          EPI.ExceptionSpec.Type != EST_DynamicNone &&          EPI.ExceptionSpec.Type != EST_BasicNoexcept && -        !RequireInstantiation) { +        !Tmpl->isLexicallyWithinFunctionOrMethod()) {        FunctionDecl *ExceptionSpecTemplate = Tmpl;        if (EPI.ExceptionSpec.Type == EST_Uninstantiated)          ExceptionSpecTemplate = EPI.ExceptionSpec.SourceTemplate; @@ -3619,19 +3639,6 @@ void Sema::BuildVariableInstantiation(      NewVar->setReferenced(OldVar->isReferenced());    } -  // See if the old variable had a type-specifier that defined an anonymous tag. -  // If it did, mark the new variable as being the declarator for the new -  // anonymous tag. -  if (const TagType *OldTagType = OldVar->getType()->getAs<TagType>()) { -    TagDecl *OldTag = OldTagType->getDecl(); -    if (OldTag->getDeclaratorForAnonDecl() == OldVar) { -      TagDecl *NewTag = NewVar->getType()->castAs<TagType>()->getDecl(); -      assert(!NewTag->hasNameForLinkage() && -             !NewTag->hasDeclaratorForAnonDecl()); -      NewTag->setDeclaratorForAnonDecl(NewVar); -    } -  } -    InstantiateAttrs(TemplateArgs, OldVar, NewVar, LateAttrs, StartingScope);    LookupResult Previous( | 
