diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -2021,7 +2021,7 @@ DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); }) -#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND) \ +#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND) \ DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, { \ /* For implicit instantiations ("set x;"), we don't want to \ recurse at all, since the instatiated template isn't written in \ @@ -2035,17 +2035,21 @@ TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); \ \ TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); \ - if (!getDerived().shouldVisitTemplateInstantiations() && \ - D->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) \ + if (getDerived().shouldVisitTemplateInstantiations() || \ + D->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) { \ + /* Traverse base definition for explicit specializations */ \ + TRY_TO(Traverse##DECLKIND##Helper(D)); \ + } else { \ /* Returning from here skips traversing the \ declaration context of the *TemplateSpecializationDecl \ (embedded in the DEF_TRAVERSE_DECL() macro) \ which contains the instantiated members of the template. */ \ return true; \ + } \ }) -DEF_TRAVERSE_TMPL_SPEC_DECL(Class) -DEF_TRAVERSE_TMPL_SPEC_DECL(Var) +DEF_TRAVERSE_TMPL_SPEC_DECL(Class, CXXRecord) +DEF_TRAVERSE_TMPL_SPEC_DECL(Var, Var) template bool RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(