@@ -350,7 +350,7 @@ ASTPrinter &operator<<(ASTPrinter &printer, tok keyword) {
350
350
SmallString<16 > Buffer;
351
351
llvm::raw_svector_ostream OS (Buffer);
352
352
OS << keyword;
353
- printer.printKeyword (Buffer.str ());
353
+ printer.printKeyword (Buffer.str (), PrintOptions () );
354
354
return printer;
355
355
}
356
356
@@ -575,7 +575,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
575
575
Printer << tok::kw_public;
576
576
break ;
577
577
case AccessLevel::Open:
578
- Printer.printKeyword (" open" );
578
+ Printer.printKeyword (" open" , Options );
579
579
break ;
580
580
}
581
581
Printer << suffix << " " ;
@@ -1614,11 +1614,9 @@ static StringRef getAccessorLabel(AccessorDecl *accessor) {
1614
1614
1615
1615
void PrintAST::printMutatingModifiersIfNeeded (const AccessorDecl *accessor) {
1616
1616
if (accessor->isAssumedNonMutating () && accessor->isMutating ()) {
1617
- Printer.printKeyword (" mutating" );
1618
- Printer << " " ;
1617
+ Printer.printKeyword (" mutating" , Options, " " );
1619
1618
} else if (accessor->isExplicitNonMutating ()) {
1620
- Printer.printKeyword (" nonmutating" );
1621
- Printer << " " ;
1619
+ Printer.printKeyword (" nonmutating" , Options, " " );
1622
1620
}
1623
1621
}
1624
1622
@@ -1675,17 +1673,17 @@ void PrintAST::printAccessors(const AbstractStorageDecl *ASD) {
1675
1673
Printer << " {" ;
1676
1674
if (mutatingGetter) {
1677
1675
Printer << " " ;
1678
- Printer.printKeyword (" mutating" );
1676
+ Printer.printKeyword (" mutating" , Options );
1679
1677
}
1680
1678
Printer << " " ;
1681
- Printer.printKeyword (" get" );
1679
+ Printer.printKeyword (" get" , Options );
1682
1680
if (settable) {
1683
1681
if (nonmutatingSetter) {
1684
1682
Printer << " " ;
1685
- Printer.printKeyword (" nonmutating" );
1683
+ Printer.printKeyword (" nonmutating" , Options );
1686
1684
}
1687
1685
Printer << " " ;
1688
- Printer.printKeyword (" set" );
1686
+ Printer.printKeyword (" set" , Options );
1689
1687
}
1690
1688
Printer << " }" ;
1691
1689
return ;
@@ -1728,7 +1726,7 @@ void PrintAST::printAccessors(const AbstractStorageDecl *ASD) {
1728
1726
if (!PrintAccessorBody) {
1729
1727
Printer << " " ;
1730
1728
printMutatingModifiersIfNeeded (Accessor);
1731
- Printer.printKeyword (getAccessorLabel (Accessor));
1729
+ Printer.printKeyword (getAccessorLabel (Accessor), Options );
1732
1730
} else {
1733
1731
{
1734
1732
IndentRAII IndentMore (*this );
@@ -2364,13 +2362,13 @@ static void printParameterFlags(ASTPrinter &printer, PrintOptions options,
2364
2362
/* nothing */
2365
2363
break ;
2366
2364
case ValueOwnership::InOut:
2367
- printer << " inout " ;
2365
+ printer. printKeyword ( " inout " , options, " " ) ;
2368
2366
break ;
2369
2367
case ValueOwnership::Shared:
2370
- printer << " __shared " ;
2368
+ printer. printKeyword ( " __shared " , options, " " ) ;
2371
2369
break ;
2372
2370
case ValueOwnership::Owned:
2373
- printer << " __owned " ;
2371
+ printer. printKeyword ( " __owned " , options, " " ) ;
2374
2372
break ;
2375
2373
}
2376
2374
}
@@ -2530,7 +2528,7 @@ void PrintAST::printOneParameter(const ParamDecl *param,
2530
2528
case DefaultArgumentKind::Function:
2531
2529
case DefaultArgumentKind::DSOHandle:
2532
2530
case DefaultArgumentKind::NilLiteral:
2533
- Printer.printKeyword (defaultArgStr);
2531
+ Printer.printKeyword (defaultArgStr, Options );
2534
2532
break ;
2535
2533
default :
2536
2534
Printer << defaultArgStr;
@@ -2665,11 +2663,9 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
2665
2663
if (decl->isStatic ())
2666
2664
printStaticKeyword (decl->getCorrectStaticSpelling ());
2667
2665
if (decl->isMutating () && !decl->getAttrs ().hasAttribute <MutatingAttr>()) {
2668
- Printer.printKeyword (" mutating" );
2669
- Printer << " " ;
2666
+ Printer.printKeyword (" mutating" , Options, " " );
2670
2667
} else if (decl->isConsuming () && !decl->getAttrs ().hasAttribute <ConsumingAttr>()) {
2671
- Printer.printKeyword (" __consuming" );
2672
- Printer << " " ;
2668
+ Printer.printKeyword (" __consuming" , Options, " " );
2673
2669
}
2674
2670
Printer << tok::kw_func << " " ;
2675
2671
}
@@ -2846,8 +2842,7 @@ void PrintAST::visitConstructorDecl(ConstructorDecl *decl) {
2846
2842
isClassContext = dc->getSelfClassDecl () != nullptr ;
2847
2843
}
2848
2844
if (isClassContext) {
2849
- Printer.printKeyword (" convenience" );
2850
- Printer << " " ;
2845
+ Printer.printKeyword (" convenience" , Options, " " );
2851
2846
} else {
2852
2847
assert (decl->getDeclContext ()->getExtendedProtocolDecl () &&
2853
2848
" unexpected convenience initializer" );
@@ -2896,8 +2891,8 @@ void PrintAST::visitDestructorDecl(DestructorDecl *decl) {
2896
2891
}
2897
2892
2898
2893
void PrintAST::visitInfixOperatorDecl (InfixOperatorDecl *decl) {
2899
- Printer.printKeyword (" infix" );
2900
- Printer << " " << tok::kw_operator << " " ;
2894
+ Printer.printKeyword (" infix" , Options, " " );
2895
+ Printer << tok::kw_operator << " " ;
2901
2896
recordDeclLoc (decl,
2902
2897
[&]{
2903
2898
Printer.printName (decl->getName ());
@@ -2928,33 +2923,30 @@ void PrintAST::visitPrecedenceGroupDecl(PrecedenceGroupDecl *decl) {
2928
2923
if (!decl->isAssociativityImplicit () ||
2929
2924
!decl->isNonAssociative ()) {
2930
2925
indent ();
2931
- Printer.printKeyword (" associativity" );
2932
- Printer << " : " ;
2926
+ Printer.printKeyword (" associativity" , Options, " : " );
2933
2927
switch (decl->getAssociativity ()) {
2934
2928
case Associativity::None:
2935
- Printer.printKeyword (" none" );
2929
+ Printer.printKeyword (" none" , Options );
2936
2930
break ;
2937
2931
case Associativity::Left:
2938
- Printer.printKeyword (" left" );
2932
+ Printer.printKeyword (" left" , Options );
2939
2933
break ;
2940
2934
case Associativity::Right:
2941
- Printer.printKeyword (" right" );
2935
+ Printer.printKeyword (" right" , Options );
2942
2936
break ;
2943
2937
}
2944
2938
Printer.printNewline ();
2945
2939
}
2946
2940
if (!decl->isAssignmentImplicit () ||
2947
2941
decl->isAssignment ()) {
2948
2942
indent ();
2949
- Printer.printKeyword (" assignment" );
2950
- Printer << " : " ;
2951
- Printer.printKeyword (decl->isAssignment () ? " true" : " false" );
2943
+ Printer.printKeyword (" assignment" , Options, " : " );
2944
+ Printer.printKeyword (decl->isAssignment () ? " true" : " false" , Options);
2952
2945
Printer.printNewline ();
2953
2946
}
2954
2947
if (!decl->getHigherThan ().empty ()) {
2955
2948
indent ();
2956
- Printer.printKeyword (" higherThan" );
2957
- Printer << " : " ;
2949
+ Printer.printKeyword (" higherThan" , Options, " : " );
2958
2950
if (!decl->getHigherThan ().empty ()) {
2959
2951
Printer << decl->getHigherThan ()[0 ].Name ;
2960
2952
for (auto &rel : decl->getHigherThan ().slice (1 ))
@@ -2964,8 +2956,7 @@ void PrintAST::visitPrecedenceGroupDecl(PrecedenceGroupDecl *decl) {
2964
2956
}
2965
2957
if (!decl->getLowerThan ().empty ()) {
2966
2958
indent ();
2967
- Printer.printKeyword (" lowerThan" );
2968
- Printer << " : " ;
2959
+ Printer.printKeyword (" lowerThan" , Options, " : " );
2969
2960
if (!decl->getLowerThan ().empty ()) {
2970
2961
Printer << decl->getLowerThan ()[0 ].Name ;
2971
2962
for (auto &rel : decl->getLowerThan ().slice (1 ))
@@ -2979,8 +2970,8 @@ void PrintAST::visitPrecedenceGroupDecl(PrecedenceGroupDecl *decl) {
2979
2970
}
2980
2971
2981
2972
void PrintAST::visitPrefixOperatorDecl (PrefixOperatorDecl *decl) {
2982
- Printer.printKeyword (" prefix" );
2983
- Printer << " " << tok::kw_operator << " " ;
2973
+ Printer.printKeyword (" prefix" , Options, " " );
2974
+ Printer << tok::kw_operator << " " ;
2984
2975
recordDeclLoc (decl,
2985
2976
[&]{
2986
2977
Printer.printName (decl->getName ());
@@ -2997,8 +2988,8 @@ void PrintAST::visitPrefixOperatorDecl(PrefixOperatorDecl *decl) {
2997
2988
}
2998
2989
2999
2990
void PrintAST::visitPostfixOperatorDecl (PostfixOperatorDecl *decl) {
3000
- Printer.printKeyword (" postfix" );
3001
- Printer << " " << tok::kw_operator << " " ;
2991
+ Printer.printKeyword (" postfix" , Options, " " );
2992
+ Printer << tok::kw_operator << " " ;
3002
2993
recordDeclLoc (decl,
3003
2994
[&]{
3004
2995
Printer.printName (decl->getName ());
@@ -3035,8 +3026,7 @@ void PrintAST::visitReturnStmt(ReturnStmt *stmt) {
3035
3026
}
3036
3027
3037
3028
void PrintAST::visitYieldStmt (YieldStmt *stmt) {
3038
- Printer.printKeyword (" yield" );
3039
- Printer << " " ;
3029
+ Printer.printKeyword (" yield" , Options, " " );
3040
3030
bool parens = (stmt->getYields ().size () != 1
3041
3031
|| stmt->getLParenLoc ().isValid ());
3042
3032
if (parens) Printer << " (" ;
0 commit comments