[cfe-commits] r107098 - /cfe/trunk/include/clang/AST/RecursiveASTVisitor.h

Craig Silverstein csilvers2000 at yahoo.com
Mon Jun 28 16:42:10 PDT 2010


Author: csilvers
Date: Mon Jun 28 18:42:10 2010
New Revision: 107098

URL: http://llvm.org/viewvc/llvm-project?rev=107098&view=rev
Log:
Fix up ClassTemplateSpecializationDecl: For implicit instantiations
("set<int> 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<int> -- is written, and will still get a
callback of TemplateSpecializationType).  For explicit instantiations
("template set<int>;"), 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

Modified:
    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=107098&r1=107097&r2=107098&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Jun 28 18:42:10 2010
@@ -890,16 +890,19 @@
   })
 
 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<int> 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<int> -- is written, and will still get a callback of
+    // TemplateSpecializationType).  For explicit instantiations
+    // ("template set<int>;"), 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 <typename Derived>





More information about the cfe-commits mailing list