From 4a5d086b50bcf6df6c2f2ddc69ed44d92582c728 Mon Sep 17 00:00:00 2001 From: Craig Silverstein Date: Fri, 9 Jul 2010 20:25:10 +0000 Subject: [PATCH] Fix a crashing but trying to print a TemplateTemplateParmDecl for code like this: template 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 llvm-svn: 108007 --- clang/lib/AST/DeclPrinter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index c43789497601..765772dd13f9 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -654,7 +654,11 @@ void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) { Out << "> "; - Visit(D->getTemplatedDecl()); + if (isa(D)) { + Out << "class " << D->getName(); + } else { + Visit(D->getTemplatedDecl()); + } } //----------------------------------------------------------------------------