]> granicus.if.org Git - clang/commitdiff
Fix a crashing but trying to print a TemplateTemplateParmDecl
authorCraig Silverstein <csilvers2000@yahoo.com>
Fri, 9 Jul 2010 20:25:10 +0000 (20:25 +0000)
committerCraig Silverstein <csilvers2000@yahoo.com>
Fri, 9 Jul 2010 20:25:10 +0000 (20:25 +0000)
for code like this:
   template<template<typename T> class U> class V {};

The problem is that the DeclPrinter assumed all TemplateDecls
have a getTemplatedClass(), but template template params don't
(so we got a NULL dereference).  The solution is to detect if
we're a template template param, and construct the template
class name ('class U') specially in this case.

OKed by dgregor and chandlerc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108007 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclPrinter.cpp

index c437894976015d5f024a3f9aedbac4420bf2ac1e..765772dd13f9be94ce613af7b6d23f75af269b6f 100644 (file)
@@ -654,7 +654,11 @@ void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) {
 
   Out << "> ";
 
-  Visit(D->getTemplatedDecl());
+  if (isa<TemplateTemplateParmDecl>(D)) {
+    Out << "class " << D->getName();
+  } else {
+    Visit(D->getTemplatedDecl());
+  }
 }
 
 //----------------------------------------------------------------------------