diff options
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index e69a1ce644..a5eb7793b8 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -697,9 +697,13 @@ static NamedDecl *findInstantiationOf(ASTContext &Ctx, NamedDecl * Sema::InstantiateDeclRef(NamedDecl *D, const TemplateArgumentList &TemplateArgs) { DeclContext *ParentDC = D->getDeclContext(); + if (isa<ParmVarDecl>(D) || ParentDC->isFunctionOrMethod()) { + // D is a local of some kind. Look into the map of local + // declarations to their instantiations. + return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D)); + } - if (!ParentDC->isFileContext()) { - NamedDecl *ParentDecl = cast<NamedDecl>(ParentDC); + if (NamedDecl *ParentDecl = dyn_cast<NamedDecl>(ParentDC)) { ParentDecl = InstantiateDeclRef(ParentDecl, TemplateArgs); if (!ParentDecl) return 0; @@ -707,12 +711,6 @@ Sema::InstantiateDeclRef(NamedDecl *D, const TemplateArgumentList &TemplateArgs) ParentDC = cast<DeclContext>(ParentDecl); } - if (ParentDC->isFunctionOrMethod()) { - // D is a local of some kind. Look into the map of local - // variables to their instantiations. - return cast<NamedDecl>(CurrentInstantiationScope->getInstantiationOf(D)); - } - if (ParentDC != D->getDeclContext()) { // We performed some kind of instantiation in the parent context, // so now we need to look into the instantiated parent context to |