@@ -341,7 +341,8 @@ void DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl,
341
341
SimpleInit = Init;
342
342
343
343
if (SimpleInit)
344
- SimpleInit->printPretty (Out, nullptr , Policy, Indentation);
344
+ SimpleInit->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
345
+ &Context);
345
346
else {
346
347
for (unsigned I = 0 ; I != NumArgs; ++I) {
347
348
assert (Args[I] != nullptr && " Expected non-null Expr" );
@@ -350,7 +351,8 @@ void DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl,
350
351
351
352
if (I)
352
353
Out << " , " ;
353
- Args[I]->printPretty (Out, nullptr , Policy, Indentation);
354
+ Args[I]->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
355
+ &Context);
354
356
}
355
357
}
356
358
}
@@ -568,13 +570,14 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) {
568
570
}
569
571
570
572
static void printExplicitSpecifier (ExplicitSpecifier ES, llvm::raw_ostream &Out,
571
- PrintingPolicy &Policy,
572
- unsigned Indentation ) {
573
+ PrintingPolicy &Policy, unsigned Indentation,
574
+ const ASTContext &Context ) {
573
575
std::string Proto = " explicit" ;
574
576
llvm::raw_string_ostream EOut (Proto);
575
577
if (ES.getExpr ()) {
576
578
EOut << " (" ;
577
- ES.getExpr ()->printPretty (EOut, nullptr , Policy, Indentation);
579
+ ES.getExpr ()->printPretty (EOut, nullptr , Policy, Indentation, " \n " ,
580
+ &Context);
578
581
EOut << " )" ;
579
582
}
580
583
EOut << " " ;
@@ -616,7 +619,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
616
619
if (D->isConsteval ()) Out << " consteval " ;
617
620
ExplicitSpecifier ExplicitSpec = ExplicitSpecifier::getFromDecl (D);
618
621
if (ExplicitSpec.isSpecified ())
619
- printExplicitSpecifier (ExplicitSpec, Out, Policy, Indentation);
622
+ printExplicitSpecifier (ExplicitSpec, Out, Policy, Indentation, Context );
620
623
}
621
624
622
625
PrintingPolicy SubPolicy (Policy);
@@ -720,7 +723,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
720
723
Proto += " (" ;
721
724
llvm::raw_string_ostream EOut (Proto);
722
725
FT->getNoexceptExpr ()->printPretty (EOut, nullptr , SubPolicy,
723
- Indentation);
726
+ Indentation, " \n " , &Context );
724
727
EOut.flush ();
725
728
Proto += EOut.str ();
726
729
Proto += " )" ;
@@ -744,7 +747,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
744
747
745
748
if (Expr *TrailingRequiresClause = D->getTrailingRequiresClause ()) {
746
749
Out << " requires " ;
747
- TrailingRequiresClause->printPretty (Out, nullptr , SubPolicy, Indentation);
750
+ TrailingRequiresClause->printPretty (Out, nullptr , SubPolicy, Indentation,
751
+ " \n " , &Context);
748
752
}
749
753
} else {
750
754
Ty.print (Out, Policy, Proto);
@@ -776,7 +780,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
776
780
Out << ' ' ;
777
781
778
782
if (D->getBody ())
779
- D->getBody ()->printPretty (Out, nullptr , SubPolicy, Indentation);
783
+ D->getBody ()->printPretty (Out, nullptr , SubPolicy, Indentation, " \n " ,
784
+ &Context);
780
785
} else {
781
786
if (!Policy.TerseOutput && isa<CXXConstructorDecl>(*D))
782
787
Out << " {}" ;
@@ -821,7 +826,8 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
821
826
822
827
if (D->isBitField ()) {
823
828
Out << " : " ;
824
- D->getBitWidth ()->printPretty (Out, nullptr , Policy, Indentation);
829
+ D->getBitWidth ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
830
+ &Context);
825
831
}
826
832
827
833
Expr *Init = D->getInClassInitializer ();
@@ -830,7 +836,7 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
830
836
Out << " " ;
831
837
else
832
838
Out << " = " ;
833
- Init->printPretty (Out, nullptr , Policy, Indentation);
839
+ Init->printPretty (Out, nullptr , Policy, Indentation, " \n " , &Context );
834
840
}
835
841
prettyPrintAttributes (D);
836
842
}
@@ -895,7 +901,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
895
901
PrintingPolicy SubPolicy (Policy);
896
902
SubPolicy.SuppressSpecifiers = false ;
897
903
SubPolicy.IncludeTagDefinition = false ;
898
- Init->printPretty (Out, nullptr , SubPolicy, Indentation);
904
+ Init->printPretty (Out, nullptr , SubPolicy, Indentation, " \n " , &Context );
899
905
if ((D->getInitStyle () == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
900
906
Out << " )" ;
901
907
}
@@ -909,7 +915,8 @@ void DeclPrinter::VisitParmVarDecl(ParmVarDecl *D) {
909
915
910
916
void DeclPrinter::VisitFileScopeAsmDecl (FileScopeAsmDecl *D) {
911
917
Out << " __asm (" ;
912
- D->getAsmString ()->printPretty (Out, nullptr , Policy, Indentation);
918
+ D->getAsmString ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
919
+ &Context);
913
920
Out << " )" ;
914
921
}
915
922
@@ -920,10 +927,11 @@ void DeclPrinter::VisitImportDecl(ImportDecl *D) {
920
927
921
928
void DeclPrinter::VisitStaticAssertDecl (StaticAssertDecl *D) {
922
929
Out << " static_assert(" ;
923
- D->getAssertExpr ()->printPretty (Out, nullptr , Policy, Indentation);
930
+ D->getAssertExpr ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
931
+ &Context);
924
932
if (StringLiteral *SL = D->getMessage ()) {
925
933
Out << " , " ;
926
- SL->printPretty (Out, nullptr , Policy, Indentation);
934
+ SL->printPretty (Out, nullptr , Policy, Indentation, " \n " , &Context );
927
935
}
928
936
Out << " )" ;
929
937
}
@@ -1110,8 +1118,8 @@ void DeclPrinter::VisitTemplateDecl(const TemplateDecl *D) {
1110
1118
Visit (TD);
1111
1119
else if (const auto *Concept = dyn_cast<ConceptDecl>(D)) {
1112
1120
Out << " concept " << Concept->getName () << " = " ;
1113
- Concept->getConstraintExpr ()->printPretty (Out, nullptr , Policy,
1114
- Indentation );
1121
+ Concept->getConstraintExpr ()->printPretty (Out, nullptr , Policy, Indentation,
1122
+ " \n " , &Context );
1115
1123
Out << " ;" ;
1116
1124
}
1117
1125
}
@@ -1271,7 +1279,8 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
1271
1279
1272
1280
if (OMD->getBody () && !Policy.TerseOutput ) {
1273
1281
Out << ' ' ;
1274
- OMD->getBody ()->printPretty (Out, nullptr , Policy);
1282
+ OMD->getBody ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
1283
+ &Context);
1275
1284
}
1276
1285
else if (Policy.PolishForDeclaration )
1277
1286
Out << ' ;' ;
@@ -1651,7 +1660,7 @@ void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
1651
1660
Out << " : " ;
1652
1661
D->getType ().print (Out, Policy);
1653
1662
Out << " : " ;
1654
- D->getCombiner ()->printPretty (Out, nullptr , Policy, 0 );
1663
+ D->getCombiner ()->printPretty (Out, nullptr , Policy, 0 , " \n " , &Context );
1655
1664
Out << " )" ;
1656
1665
if (auto *Init = D->getInitializer ()) {
1657
1666
Out << " initializer(" ;
@@ -1665,7 +1674,7 @@ void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
1665
1674
case OMPDeclareReductionDecl::CallInit:
1666
1675
break ;
1667
1676
}
1668
- Init->printPretty (Out, nullptr , Policy, 0 );
1677
+ Init->printPretty (Out, nullptr , Policy, 0 , " \n " , &Context );
1669
1678
if (D->getInitializerKind () == OMPDeclareReductionDecl::DirectInit)
1670
1679
Out << " )" ;
1671
1680
Out << " )" ;
@@ -1693,7 +1702,7 @@ void DeclPrinter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
1693
1702
}
1694
1703
1695
1704
void DeclPrinter::VisitOMPCapturedExprDecl (OMPCapturedExprDecl *D) {
1696
- D->getInit ()->printPretty (Out, nullptr , Policy, Indentation);
1705
+ D->getInit ()->printPretty (Out, nullptr , Policy, Indentation, " \n " , &Context );
1697
1706
}
1698
1707
1699
1708
void DeclPrinter::VisitTemplateTypeParmDecl (const TemplateTypeParmDecl *TTP) {
@@ -1727,6 +1736,7 @@ void DeclPrinter::VisitNonTypeTemplateParmDecl(
1727
1736
1728
1737
if (NTTP->hasDefaultArgument ()) {
1729
1738
Out << " = " ;
1730
- NTTP->getDefaultArgument ()->printPretty (Out, nullptr , Policy, Indentation);
1739
+ NTTP->getDefaultArgument ()->printPretty (Out, nullptr , Policy, Indentation,
1740
+ " \n " , &Context);
1731
1741
}
1732
1742
}
0 commit comments