[PATCH] Fix crashes during template recovery

Alp Toker alp at nuanti.com
Fri Dec 6 04:56:32 PST 2013


ActOnVariableDeclarator() sometimes calls 
setTemplateParameterListsInfo() with an empty template parameter list 
during error recovery.

Currently asserts on invalid with cases like these:

|template <class _Tp>||
||typename remove_reference {}||
||remove_reference<int> type;|

|template <class = void>||
||remove_reference;||
||remove_reference<>;|

The attached patch simply removes the assertion assert(NumTPLists > 0).

As far as I can tell the code path is equipped to deal with NumTPLists 
== 0 so this shouldn't cause a problem, but would appreciate review from 
someone familiar with the template code.

Related to PR17191.

Alp.


-- 
http://www.nuanti.com
the browser experts

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131206/14e99b1b/attachment.html>
-------------- next part --------------
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index c75cf20..05f8baf 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1513,7 +1513,6 @@ void
 DeclaratorDecl::setTemplateParameterListsInfo(ASTContext &Context,
                                               unsigned NumTPLists,
                                               TemplateParameterList **TPLists) {
-  assert(NumTPLists > 0);
   // Make sure the extended decl info is allocated.
   if (!hasExtInfo()) {
     // Save (non-extended) type source info pointer.


More information about the cfe-commits mailing list