From: Craig Silverstein Date: Mon, 28 Jun 2010 23:42:10 +0000 (+0000) Subject: Fix up ClassTemplateSpecializationDecl: For implicit instantiations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc55618eb97c519b8c186c350cb419f89021b073;p=clang Fix up ClassTemplateSpecializationDecl: For implicit instantiations ("set x;"), we don't want to recurse at all, since the instatiated class isn't written in the source code anywhere. (Note the instatiated *type* -- set -- is written, and will still get a callback of TemplateSpecializationType). For explicit instantiations ("template set;"), we do need a callback, since this is the only callback that's made for this instantiation. We use getTypeAsWritten() to distinguish. We will still need to figure out how to handle template specializations, which probably are still not quite correct. Reviewed by chandlerc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107098 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 8512ccda28..7a2a044c5f 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -890,16 +890,19 @@ DEF_TRAVERSE_DECL(CXXRecordDecl, { }) DEF_TRAVERSE_DECL(ClassTemplateSpecializationDecl, { - // FIXME: we probably want to traverse the TemplateArgumentLoc for - // explicitly-written specializations and instantiations, rather - // than the computed template arguments. - const TemplateArgumentList &TAL = D->getTemplateArgs(); - for (unsigned I = 0; I < TAL.size(); ++I) { - TRY_TO(TraverseTemplateArgument(TAL.get(I))); - } - // FIXME: I think we only want to traverse this if it's an explicit - // specialization. - TRY_TO(TraverseCXXRecordHelper(D)); + // For implicit instantiations ("set x;"), we don't want to + // recurse at all, since the instatiated class isn't written in + // the source code anywhere. (Note the instatiated *type* -- + // set -- is written, and will still get a callback of + // TemplateSpecializationType). For explicit instantiations + // ("template set;"), we do need a callback, since this + // is the only callback that's made for this instantiation. + // We use getTypeAsWritten() to distinguish. + // FIXME: see how we want to handle template specializations. + TypeSourceInfo* TSI = D->getTypeAsWritten(); + if (TSI) + TRY_TO(TraverseType(TSI->getType())); + return true; }) template