[cfe-commits] r72848 - /cfe/trunk/lib/AST/DeclPrinter.cpp
Anders Carlsson
andersca at mac.com
Wed Jun 3 22:37:43 PDT 2009
Author: andersca
Date: Thu Jun 4 00:37:43 2009
New Revision: 72848
URL: http://llvm.org/viewvc/llvm-project?rev=72848&view=rev
Log:
Minor improvements to template parameter writing.
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=72848&r1=72847&r2=72848&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Thu Jun 4 00:37:43 2009
@@ -508,8 +508,50 @@
}
void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) {
- // TODO: Write template parameters.
- Out << "template <...> ";
+ Out << "template <";
+
+ TemplateParameterList *Params = D->getTemplateParameters();
+ for (unsigned i = 0, e = Params->size(); i != e; ++i) {
+ if (i != 0)
+ Out << ", ";
+
+ const Decl *Param = Params->getParam(i);
+ if (const TemplateTypeParmDecl *TTP =
+ dyn_cast<TemplateTypeParmDecl>(Param)) {
+
+ QualType ParamType =
+ Context.getTypeDeclType(const_cast<TemplateTypeParmDecl*>(TTP));
+
+ if (TTP->wasDeclaredWithTypename())
+ Out << "typename ";
+ else
+ Out << "class ";
+
+ Out << ParamType.getAsString(Policy);
+
+ if (TTP->hasDefaultArgument()) {
+ Out << " = ";
+ Out << TTP->getDefaultArgument().getAsString(Policy);
+ };
+ } else if (const NonTypeTemplateParmDecl *NTTP =
+ dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+ Out << NTTP->getType().getAsString(Policy);
+
+ if (IdentifierInfo *Name = NTTP->getIdentifier()) {
+ Out << ' ';
+ Out << Name->getName();
+ }
+
+ if (NTTP->hasDefaultArgument()) {
+ Out << " = ";
+ NTTP->getDefaultArgument()->printPretty(Out, Context, 0, Policy,
+ Indentation);
+ }
+ }
+ }
+
+ Out << "> ";
+
Visit(D->getTemplatedDecl());
}
More information about the cfe-commits
mailing list