[cfe-commits] r108007 - /cfe/trunk/lib/AST/DeclPrinter.cpp

Craig Silverstein csilvers2000 at yahoo.com
Fri Jul 9 13:25:10 PDT 2010


Author: csilvers
Date: Fri Jul  9 15:25:10 2010
New Revision: 108007

URL: http://llvm.org/viewvc/llvm-project?rev=108007&view=rev
Log:
Fix a crashing but trying to print a TemplateTemplateParmDecl
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

Modified:
    cfe/trunk/lib/AST/DeclPrinter.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=108007&r1=108006&r2=108007&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jul  9 15:25:10 2010
@@ -654,7 +654,11 @@
 
   Out << "> ";
 
-  Visit(D->getTemplatedDecl());
+  if (isa<TemplateTemplateParmDecl>(D)) {
+    Out << "class " << D->getName();
+  } else {
+    Visit(D->getTemplatedDecl());
+  }
 }
 
 //----------------------------------------------------------------------------





More information about the cfe-commits mailing list