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

Nick Lewycky nicholas at mxc.ca
Thu Jul 22 10:56:57 PDT 2010


Author: nicholas
Date: Thu Jul 22 12:56:53 2010
New Revision: 109127

URL: http://llvm.org/viewvc/llvm-project?rev=109127&view=rev
Log:
Don't crash when an explicit template instantiation has no user-written
arguments. This happens in clang itself where template:

  template <typename T> T const *getAs();

gets specialized with:

  template<> inline clang::TypedefType const *getAs() { ... }

and there's no TemplateArgumentList.

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=109127&r1=109126&r2=109127&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Jul 22 12:56:53 2010
@@ -1318,9 +1318,13 @@
       D->getTemplateSpecializationInfo()) {
     if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
         FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
-      const TemplateArgumentListInfo *TALI = FTSI->TemplateArgumentsAsWritten;
-      TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getArgumentArray(),
-                                                TALI->size()));
+      // A specialization might not have explicit template arguments if it has
+      // a templated return type and concrete arguments.
+      if (const TemplateArgumentListInfo *TALI =
+          FTSI->TemplateArgumentsAsWritten) {
+        TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getArgumentArray(),
+                                                  TALI->size()));
+      }
     }
   }
 





More information about the cfe-commits mailing list