@@ -341,7 +341,8 @@ void DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl,
341341 SimpleInit = Init;
342342
343343 if (SimpleInit)
344- SimpleInit->printPretty (Out, nullptr , Policy, Indentation);
344+ SimpleInit->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
345+ &Context);
345346 else {
346347 for (unsigned I = 0 ; I != NumArgs; ++I) {
347348 assert (Args[I] != nullptr && " Expected non-null Expr" );
@@ -350,7 +351,8 @@ void DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl,
350351
351352 if (I)
352353 Out << " , " ;
353- Args[I]->printPretty (Out, nullptr , Policy, Indentation);
354+ Args[I]->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
355+ &Context);
354356 }
355357 }
356358 }
@@ -568,13 +570,14 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) {
568570}
569571
570572static void printExplicitSpecifier (ExplicitSpecifier ES, llvm::raw_ostream &Out,
571- PrintingPolicy &Policy,
572- unsigned Indentation ) {
573+ PrintingPolicy &Policy, unsigned Indentation,
574+ const ASTContext &Context ) {
573575 std::string Proto = " explicit" ;
574576 llvm::raw_string_ostream EOut (Proto);
575577 if (ES.getExpr ()) {
576578 EOut << " (" ;
577- ES.getExpr ()->printPretty (EOut, nullptr , Policy, Indentation);
579+ ES.getExpr ()->printPretty (EOut, nullptr , Policy, Indentation, " \n " ,
580+ &Context);
578581 EOut << " )" ;
579582 }
580583 EOut << " " ;
@@ -616,7 +619,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
616619 if (D->isConsteval ()) Out << " consteval " ;
617620 ExplicitSpecifier ExplicitSpec = ExplicitSpecifier::getFromDecl (D);
618621 if (ExplicitSpec.isSpecified ())
619- printExplicitSpecifier (ExplicitSpec, Out, Policy, Indentation);
622+ printExplicitSpecifier (ExplicitSpec, Out, Policy, Indentation, Context );
620623 }
621624
622625 PrintingPolicy SubPolicy (Policy);
@@ -720,7 +723,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
720723 Proto += " (" ;
721724 llvm::raw_string_ostream EOut (Proto);
722725 FT->getNoexceptExpr ()->printPretty (EOut, nullptr , SubPolicy,
723- Indentation);
726+ Indentation, " \n " , &Context );
724727 EOut.flush ();
725728 Proto += EOut.str ();
726729 Proto += " )" ;
@@ -744,7 +747,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
744747
745748 if (Expr *TrailingRequiresClause = D->getTrailingRequiresClause ()) {
746749 Out << " requires " ;
747- TrailingRequiresClause->printPretty (Out, nullptr , SubPolicy, Indentation);
750+ TrailingRequiresClause->printPretty (Out, nullptr , SubPolicy, Indentation,
751+ " \n " , &Context);
748752 }
749753 } else {
750754 Ty.print (Out, Policy, Proto);
@@ -776,7 +780,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
776780 Out << ' ' ;
777781
778782 if (D->getBody ())
779- D->getBody ()->printPretty (Out, nullptr , SubPolicy, Indentation);
783+ D->getBody ()->printPretty (Out, nullptr , SubPolicy, Indentation, " \n " ,
784+ &Context);
780785 } else {
781786 if (!Policy.TerseOutput && isa<CXXConstructorDecl>(*D))
782787 Out << " {}" ;
@@ -821,7 +826,8 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
821826
822827 if (D->isBitField ()) {
823828 Out << " : " ;
824- D->getBitWidth ()->printPretty (Out, nullptr , Policy, Indentation);
829+ D->getBitWidth ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
830+ &Context);
825831 }
826832
827833 Expr *Init = D->getInClassInitializer ();
@@ -830,7 +836,7 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
830836 Out << " " ;
831837 else
832838 Out << " = " ;
833- Init->printPretty (Out, nullptr , Policy, Indentation);
839+ Init->printPretty (Out, nullptr , Policy, Indentation, " \n " , &Context );
834840 }
835841 prettyPrintAttributes (D);
836842}
@@ -895,7 +901,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
895901 PrintingPolicy SubPolicy (Policy);
896902 SubPolicy.SuppressSpecifiers = false ;
897903 SubPolicy.IncludeTagDefinition = false ;
898- Init->printPretty (Out, nullptr , SubPolicy, Indentation);
904+ Init->printPretty (Out, nullptr , SubPolicy, Indentation, " \n " , &Context );
899905 if ((D->getInitStyle () == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
900906 Out << " )" ;
901907 }
@@ -909,7 +915,8 @@ void DeclPrinter::VisitParmVarDecl(ParmVarDecl *D) {
909915
910916void DeclPrinter::VisitFileScopeAsmDecl (FileScopeAsmDecl *D) {
911917 Out << " __asm (" ;
912- D->getAsmString ()->printPretty (Out, nullptr , Policy, Indentation);
918+ D->getAsmString ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
919+ &Context);
913920 Out << " )" ;
914921}
915922
@@ -920,10 +927,11 @@ void DeclPrinter::VisitImportDecl(ImportDecl *D) {
920927
921928void DeclPrinter::VisitStaticAssertDecl (StaticAssertDecl *D) {
922929 Out << " static_assert(" ;
923- D->getAssertExpr ()->printPretty (Out, nullptr , Policy, Indentation);
930+ D->getAssertExpr ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
931+ &Context);
924932 if (StringLiteral *SL = D->getMessage ()) {
925933 Out << " , " ;
926- SL->printPretty (Out, nullptr , Policy, Indentation);
934+ SL->printPretty (Out, nullptr , Policy, Indentation, " \n " , &Context );
927935 }
928936 Out << " )" ;
929937}
@@ -1110,8 +1118,8 @@ void DeclPrinter::VisitTemplateDecl(const TemplateDecl *D) {
11101118 Visit (TD);
11111119 else if (const auto *Concept = dyn_cast<ConceptDecl>(D)) {
11121120 Out << " concept " << Concept->getName () << " = " ;
1113- Concept->getConstraintExpr ()->printPretty (Out, nullptr , Policy,
1114- Indentation );
1121+ Concept->getConstraintExpr ()->printPretty (Out, nullptr , Policy, Indentation,
1122+ " \n " , &Context );
11151123 Out << " ;" ;
11161124 }
11171125}
@@ -1271,7 +1279,8 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
12711279
12721280 if (OMD->getBody () && !Policy.TerseOutput ) {
12731281 Out << ' ' ;
1274- OMD->getBody ()->printPretty (Out, nullptr , Policy);
1282+ OMD->getBody ()->printPretty (Out, nullptr , Policy, Indentation, " \n " ,
1283+ &Context);
12751284 }
12761285 else if (Policy.PolishForDeclaration )
12771286 Out << ' ;' ;
@@ -1651,7 +1660,7 @@ void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
16511660 Out << " : " ;
16521661 D->getType ().print (Out, Policy);
16531662 Out << " : " ;
1654- D->getCombiner ()->printPretty (Out, nullptr , Policy, 0 );
1663+ D->getCombiner ()->printPretty (Out, nullptr , Policy, 0 , " \n " , &Context );
16551664 Out << " )" ;
16561665 if (auto *Init = D->getInitializer ()) {
16571666 Out << " initializer(" ;
@@ -1665,7 +1674,7 @@ void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
16651674 case OMPDeclareReductionDecl::CallInit:
16661675 break ;
16671676 }
1668- Init->printPretty (Out, nullptr , Policy, 0 );
1677+ Init->printPretty (Out, nullptr , Policy, 0 , " \n " , &Context );
16691678 if (D->getInitializerKind () == OMPDeclareReductionDecl::DirectInit)
16701679 Out << " )" ;
16711680 Out << " )" ;
@@ -1693,7 +1702,7 @@ void DeclPrinter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
16931702}
16941703
16951704void DeclPrinter::VisitOMPCapturedExprDecl (OMPCapturedExprDecl *D) {
1696- D->getInit ()->printPretty (Out, nullptr , Policy, Indentation);
1705+ D->getInit ()->printPretty (Out, nullptr , Policy, Indentation, " \n " , &Context );
16971706}
16981707
16991708void DeclPrinter::VisitTemplateTypeParmDecl (const TemplateTypeParmDecl *TTP) {
@@ -1727,6 +1736,7 @@ void DeclPrinter::VisitNonTypeTemplateParmDecl(
17271736
17281737 if (NTTP->hasDefaultArgument ()) {
17291738 Out << " = " ;
1730- NTTP->getDefaultArgument ()->printPretty (Out, nullptr , Policy, Indentation);
1739+ NTTP->getDefaultArgument ()->printPretty (Out, nullptr , Policy, Indentation,
1740+ " \n " , &Context);
17311741 }
17321742}
0 commit comments