diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2010-07-22 17:56:53 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2010-07-22 17:56:53 +0000 |
commit | a11b4bfcbeaa9ccbd0a8c709f9b36c24a8734ef1 (patch) | |
tree | ace98c13335d3235a362b26335f01bc5856a8cd4 | |
parent | f7109438ea0f742fc39a6d7ba4dfa8ae7336b174 (diff) | |
download | bcm5719-llvm-a11b4bfcbeaa9ccbd0a8c709f9b36c24a8734ef1.tar.gz bcm5719-llvm-a11b4bfcbeaa9ccbd0a8c709f9b36c24a8734ef1.zip |
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.
llvm-svn: 109127
-rw-r--r-- | clang/include/clang/AST/RecursiveASTVisitor.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index fc621977942..0b56772c97d 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1318,9 +1318,13 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) { 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())); + } } } |