@@ -366,7 +366,7 @@ ASTPrinter &operator<<(ASTPrinter &printer, tok keyword) {
366
366
SmallString<16 > Buffer;
367
367
llvm::raw_svector_ostream OS (Buffer);
368
368
OS << keyword;
369
- printer.printKeyword (Buffer.str ());
369
+ printer.printKeyword (Buffer.str (), PrintOptions () );
370
370
return printer;
371
371
}
372
372
@@ -591,7 +591,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
591
591
Printer << tok::kw_public;
592
592
break ;
593
593
case AccessLevel::Open:
594
- Printer.printKeyword (" open" );
594
+ Printer.printKeyword (" open" , Options );
595
595
break ;
596
596
}
597
597
Printer << suffix << " " ;
@@ -1630,11 +1630,9 @@ static StringRef getAccessorLabel(AccessorDecl *accessor) {
1630
1630
1631
1631
void PrintAST::printMutatingModifiersIfNeeded (const AccessorDecl *accessor) {
1632
1632
if (accessor->isAssumedNonMutating () && accessor->isMutating ()) {
1633
- Printer.printKeyword (" mutating" );
1634
- Printer << " " ;
1633
+ Printer.printKeyword (" mutating" , Options, " " );
1635
1634
} else if (accessor->isExplicitNonMutating ()) {
1636
- Printer.printKeyword (" nonmutating" );
1637
- Printer << " " ;
1635
+ Printer.printKeyword (" nonmutating" , Options, " " );
1638
1636
}
1639
1637
}
1640
1638
@@ -1691,17 +1689,17 @@ void PrintAST::printAccessors(const AbstractStorageDecl *ASD) {
1691
1689
Printer << " {" ;
1692
1690
if (mutatingGetter) {
1693
1691
Printer << " " ;
1694
- Printer.printKeyword (" mutating" );
1692
+ Printer.printKeyword (" mutating" , Options );
1695
1693
}
1696
1694
Printer << " " ;
1697
- Printer.printKeyword (" get" );
1695
+ Printer.printKeyword (" get" , Options );
1698
1696
if (settable) {
1699
1697
if (nonmutatingSetter) {
1700
1698
Printer << " " ;
1701
- Printer.printKeyword (" nonmutating" );
1699
+ Printer.printKeyword (" nonmutating" , Options );
1702
1700
}
1703
1701
Printer << " " ;
1704
- Printer.printKeyword (" set" );
1702
+ Printer.printKeyword (" set" , Options );
1705
1703
}
1706
1704
Printer << " }" ;
1707
1705
return ;
@@ -1744,7 +1742,7 @@ void PrintAST::printAccessors(const AbstractStorageDecl *ASD) {
1744
1742
if (!PrintAccessorBody) {
1745
1743
Printer << " " ;
1746
1744
printMutatingModifiersIfNeeded (Accessor);
1747
- Printer.printKeyword (getAccessorLabel (Accessor));
1745
+ Printer.printKeyword (getAccessorLabel (Accessor), Options );
1748
1746
} else {
1749
1747
{
1750
1748
IndentRAII IndentMore (*this );
@@ -2380,13 +2378,13 @@ static void printParameterFlags(ASTPrinter &printer, PrintOptions options,
2380
2378
/* nothing */
2381
2379
break ;
2382
2380
case ValueOwnership::InOut:
2383
- printer << " inout " ;
2381
+ printer. printKeyword ( " inout " , options, " " ) ;
2384
2382
break ;
2385
2383
case ValueOwnership::Shared:
2386
- printer << " __shared " ;
2384
+ printer. printKeyword ( " __shared " , options, " " ) ;
2387
2385
break ;
2388
2386
case ValueOwnership::Owned:
2389
- printer << " __owned " ;
2387
+ printer. printKeyword ( " __owned " , options, " " ) ;
2390
2388
break ;
2391
2389
}
2392
2390
}
@@ -2546,7 +2544,7 @@ void PrintAST::printOneParameter(const ParamDecl *param,
2546
2544
case DefaultArgumentKind::Function:
2547
2545
case DefaultArgumentKind::DSOHandle:
2548
2546
case DefaultArgumentKind::NilLiteral:
2549
- Printer.printKeyword (defaultArgStr);
2547
+ Printer.printKeyword (defaultArgStr, Options );
2550
2548
break ;
2551
2549
default :
2552
2550
Printer << defaultArgStr;
@@ -2681,11 +2679,9 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
2681
2679
if (decl->isStatic ())
2682
2680
printStaticKeyword (decl->getCorrectStaticSpelling ());
2683
2681
if (decl->isMutating () && !decl->getAttrs ().hasAttribute <MutatingAttr>()) {
2684
- Printer.printKeyword (" mutating" );
2685
- Printer << " " ;
2682
+ Printer.printKeyword (" mutating" , Options, " " );
2686
2683
} else if (decl->isConsuming () && !decl->getAttrs ().hasAttribute <ConsumingAttr>()) {
2687
- Printer.printKeyword (" __consuming" );
2688
- Printer << " " ;
2684
+ Printer.printKeyword (" __consuming" , Options, " " );
2689
2685
}
2690
2686
Printer << tok::kw_func << " " ;
2691
2687
}
@@ -2862,8 +2858,7 @@ void PrintAST::visitConstructorDecl(ConstructorDecl *decl) {
2862
2858
isClassContext = dc->getSelfClassDecl () != nullptr ;
2863
2859
}
2864
2860
if (isClassContext) {
2865
- Printer.printKeyword (" convenience" );
2866
- Printer << " " ;
2861
+ Printer.printKeyword (" convenience" , Options, " " );
2867
2862
} else {
2868
2863
assert (decl->getDeclContext ()->getExtendedProtocolDecl () &&
2869
2864
" unexpected convenience initializer" );
@@ -2912,8 +2907,8 @@ void PrintAST::visitDestructorDecl(DestructorDecl *decl) {
2912
2907
}
2913
2908
2914
2909
void PrintAST::visitInfixOperatorDecl (InfixOperatorDecl *decl) {
2915
- Printer.printKeyword (" infix" );
2916
- Printer << " " << tok::kw_operator << " " ;
2910
+ Printer.printKeyword (" infix" , Options, " " );
2911
+ Printer << tok::kw_operator << " " ;
2917
2912
recordDeclLoc (decl,
2918
2913
[&]{
2919
2914
Printer.printName (decl->getName ());
@@ -2944,33 +2939,30 @@ void PrintAST::visitPrecedenceGroupDecl(PrecedenceGroupDecl *decl) {
2944
2939
if (!decl->isAssociativityImplicit () ||
2945
2940
!decl->isNonAssociative ()) {
2946
2941
indent ();
2947
- Printer.printKeyword (" associativity" );
2948
- Printer << " : " ;
2942
+ Printer.printKeyword (" associativity" , Options, " : " );
2949
2943
switch (decl->getAssociativity ()) {
2950
2944
case Associativity::None:
2951
- Printer.printKeyword (" none" );
2945
+ Printer.printKeyword (" none" , Options );
2952
2946
break ;
2953
2947
case Associativity::Left:
2954
- Printer.printKeyword (" left" );
2948
+ Printer.printKeyword (" left" , Options );
2955
2949
break ;
2956
2950
case Associativity::Right:
2957
- Printer.printKeyword (" right" );
2951
+ Printer.printKeyword (" right" , Options );
2958
2952
break ;
2959
2953
}
2960
2954
Printer.printNewline ();
2961
2955
}
2962
2956
if (!decl->isAssignmentImplicit () ||
2963
2957
decl->isAssignment ()) {
2964
2958
indent ();
2965
- Printer.printKeyword (" assignment" );
2966
- Printer << " : " ;
2967
- Printer.printKeyword (decl->isAssignment () ? " true" : " false" );
2959
+ Printer.printKeyword (" assignment" , Options, " : " );
2960
+ Printer.printKeyword (decl->isAssignment () ? " true" : " false" , Options);
2968
2961
Printer.printNewline ();
2969
2962
}
2970
2963
if (!decl->getHigherThan ().empty ()) {
2971
2964
indent ();
2972
- Printer.printKeyword (" higherThan" );
2973
- Printer << " : " ;
2965
+ Printer.printKeyword (" higherThan" , Options, " : " );
2974
2966
if (!decl->getHigherThan ().empty ()) {
2975
2967
Printer << decl->getHigherThan ()[0 ].Name ;
2976
2968
for (auto &rel : decl->getHigherThan ().slice (1 ))
@@ -2980,8 +2972,7 @@ void PrintAST::visitPrecedenceGroupDecl(PrecedenceGroupDecl *decl) {
2980
2972
}
2981
2973
if (!decl->getLowerThan ().empty ()) {
2982
2974
indent ();
2983
- Printer.printKeyword (" lowerThan" );
2984
- Printer << " : " ;
2975
+ Printer.printKeyword (" lowerThan" , Options, " : " );
2985
2976
if (!decl->getLowerThan ().empty ()) {
2986
2977
Printer << decl->getLowerThan ()[0 ].Name ;
2987
2978
for (auto &rel : decl->getLowerThan ().slice (1 ))
@@ -2995,8 +2986,8 @@ void PrintAST::visitPrecedenceGroupDecl(PrecedenceGroupDecl *decl) {
2995
2986
}
2996
2987
2997
2988
void PrintAST::visitPrefixOperatorDecl (PrefixOperatorDecl *decl) {
2998
- Printer.printKeyword (" prefix" );
2999
- Printer << " " << tok::kw_operator << " " ;
2989
+ Printer.printKeyword (" prefix" , Options, " " );
2990
+ Printer << tok::kw_operator << " " ;
3000
2991
recordDeclLoc (decl,
3001
2992
[&]{
3002
2993
Printer.printName (decl->getName ());
@@ -3013,8 +3004,8 @@ void PrintAST::visitPrefixOperatorDecl(PrefixOperatorDecl *decl) {
3013
3004
}
3014
3005
3015
3006
void PrintAST::visitPostfixOperatorDecl (PostfixOperatorDecl *decl) {
3016
- Printer.printKeyword (" postfix" );
3017
- Printer << " " << tok::kw_operator << " " ;
3007
+ Printer.printKeyword (" postfix" , Options, " " );
3008
+ Printer << tok::kw_operator << " " ;
3018
3009
recordDeclLoc (decl,
3019
3010
[&]{
3020
3011
Printer.printName (decl->getName ());
@@ -3051,8 +3042,7 @@ void PrintAST::visitReturnStmt(ReturnStmt *stmt) {
3051
3042
}
3052
3043
3053
3044
void PrintAST::visitYieldStmt (YieldStmt *stmt) {
3054
- Printer.printKeyword (" yield" );
3055
- Printer << " " ;
3045
+ Printer.printKeyword (" yield" , Options, " " );
3056
3046
bool parens = (stmt->getYields ().size () != 1
3057
3047
|| stmt->getLParenLoc ().isValid ());
3058
3048
if (parens) Printer << " (" ;
0 commit comments