diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 7b9b4a1c0e8a..ce670315e216 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -253,6 +253,8 @@ namespace clang { ~LocalInstantiationScope() { Exit(); } + + const Sema &getSema() const { return SemaRef; } /// \brief Exit this local instantiation scope early. void Exit() { @@ -266,8 +268,6 @@ namespace clang { Exited = true; } - Decl *getInstantiationOf(const Decl *D); - /// \brief Find the instantiation of the declaration D within the current /// instantiation scope. /// diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 0ad9f7c53fb3..41e44ad6d10f 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2166,17 +2166,6 @@ bool Sema::Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, return Instantiator.TransformTemplateArguments(Args, NumArgs, Result); } -Decl *LocalInstantiationScope::getInstantiationOf(const Decl *D) { - llvm::PointerUnion *Found= findInstantiationOf(D); - assert(Found); - - if (Found->is()) - return Found->get(); - - return (*Found->get())[ - SemaRef.ArgumentPackSubstitutionIndex]; -} - llvm::PointerUnion * LocalInstantiationScope::findInstantiationOf(const Decl *D) { for (LocalInstantiationScope *Current = this; Current; diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 14524235d503..9197b5033028 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2860,7 +2860,16 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, (ParentDC->isFunctionOrMethod() && ParentDC->isDependentContext())) { // D is a local of some kind. Look into the map of local // declarations to their instantiations. - return cast(CurrentInstantiationScope->getInstantiationOf(D)); + typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; + llvm::PointerUnion *Found + = CurrentInstantiationScope->findInstantiationOf(D); + assert(Found); + + if (Decl *FD = Found->dyn_cast()) + return cast(FD); + + unsigned PackIdx = ArgumentPackSubstitutionIndex; + return cast((*Found->get())[PackIdx]); } if (CXXRecordDecl *Record = dyn_cast(D)) {