@@ -105,6 +105,8 @@ namespace {
105
105
void VisitOMPDeclareReductionDecl (OMPDeclareReductionDecl *D);
106
106
void VisitOMPDeclareMapperDecl (OMPDeclareMapperDecl *D);
107
107
void VisitOMPCapturedExprDecl (OMPCapturedExprDecl *D);
108
+ void VisitTemplateTypeParmDecl (const TemplateTypeParmDecl *TTP);
109
+ void VisitNonTypeTemplateParmDecl (const NonTypeTemplateParmDecl *NTTP);
108
110
109
111
void printTemplateParameters (const TemplateParameterList *Params,
110
112
bool OmitTemplateKW = false );
@@ -1051,37 +1053,10 @@ void DeclPrinter::printTemplateParameters(const TemplateParameterList *Params,
1051
1053
else
1052
1054
NeedComma = true ;
1053
1055
1054
- if (auto TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
1055
-
1056
- if (const TypeConstraint *TC = TTP->getTypeConstraint ())
1057
- TC->print (Out, Policy);
1058
- else if (TTP->wasDeclaredWithTypename ())
1059
- Out << " typename" ;
1060
- else
1061
- Out << " class" ;
1062
-
1063
- if (TTP->isParameterPack ())
1064
- Out << " ..." ;
1065
- else if (!TTP->getName ().empty ())
1066
- Out << ' ' ;
1067
-
1068
- Out << *TTP;
1069
-
1070
- if (TTP->hasDefaultArgument ()) {
1071
- Out << " = " ;
1072
- Out << TTP->getDefaultArgument ().getAsString (Policy);
1073
- };
1056
+ if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
1057
+ VisitTemplateTypeParmDecl (TTP);
1074
1058
} else if (auto NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
1075
- StringRef Name;
1076
- if (IdentifierInfo *II = NTTP->getIdentifier ())
1077
- Name = II->getName ();
1078
- printDeclType (NTTP->getType (), Name, NTTP->isParameterPack ());
1079
-
1080
- if (NTTP->hasDefaultArgument ()) {
1081
- Out << " = " ;
1082
- NTTP->getDefaultArgument ()->printPretty (Out, nullptr , Policy,
1083
- Indentation);
1084
- }
1059
+ VisitNonTypeTemplateParmDecl (NTTP);
1085
1060
} else if (auto TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
1086
1061
VisitTemplateDecl (TTPD);
1087
1062
// FIXME: print the default argument, if present.
@@ -1705,3 +1680,36 @@ void DeclPrinter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) {
1705
1680
D->getInit ()->printPretty (Out, nullptr , Policy, Indentation);
1706
1681
}
1707
1682
1683
+ void DeclPrinter::VisitTemplateTypeParmDecl (const TemplateTypeParmDecl *TTP) {
1684
+ if (const TypeConstraint *TC = TTP->getTypeConstraint ())
1685
+ TC->print (Out, Policy);
1686
+ else if (TTP->wasDeclaredWithTypename ())
1687
+ Out << " typename" ;
1688
+ else
1689
+ Out << " class" ;
1690
+
1691
+ if (TTP->isParameterPack ())
1692
+ Out << " ..." ;
1693
+ else if (!TTP->getName ().empty ())
1694
+ Out << ' ' ;
1695
+
1696
+ Out << *TTP;
1697
+
1698
+ if (TTP->hasDefaultArgument ()) {
1699
+ Out << " = " ;
1700
+ Out << TTP->getDefaultArgument ().getAsString (Policy);
1701
+ }
1702
+ }
1703
+
1704
+ void DeclPrinter::VisitNonTypeTemplateParmDecl (
1705
+ const NonTypeTemplateParmDecl *NTTP) {
1706
+ StringRef Name;
1707
+ if (IdentifierInfo *II = NTTP->getIdentifier ())
1708
+ Name = II->getName ();
1709
+ printDeclType (NTTP->getType (), Name, NTTP->isParameterPack ());
1710
+
1711
+ if (NTTP->hasDefaultArgument ()) {
1712
+ Out << " = " ;
1713
+ NTTP->getDefaultArgument ()->printPretty (Out, nullptr , Policy, Indentation);
1714
+ }
1715
+ }
0 commit comments