@@ -924,10 +924,6 @@ ASTPrinter &ASTPrinter::operator<<(DeclName name) {
924
924
return *this ;
925
925
}
926
926
927
- // FIXME: We need to undef 'defer' when including Tokens.def. It is restored
928
- // below.
929
- #undef defer
930
-
931
927
ASTPrinter &operator <<(ASTPrinter &printer, tok keyword) {
932
928
StringRef name;
933
929
switch (keyword) {
@@ -3791,75 +3787,89 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3791
3787
return ;
3792
3788
3793
3789
if (info.isAutoClosure () && !Options.excludeAttrKind (TAK_autoclosure)) {
3794
- Printer.printSimpleAttr (" @autoclosure" );
3795
- Printer << " " ;
3790
+ Printer.printSimpleAttr (" @autoclosure" ) << " " ;
3796
3791
}
3797
3792
if (inParameterPrinting && !info.isNoEscape () &&
3798
3793
!Options.excludeAttrKind (TAK_escaping)) {
3799
- Printer.printSimpleAttr (" @escaping" );
3800
- Printer << " " ;
3794
+ Printer.printSimpleAttr (" @escaping" ) << " " ;
3801
3795
}
3802
3796
3803
3797
if (Options.PrintFunctionRepresentationAttrs &&
3804
- !Options.excludeAttrKind (TAK_convention)) {
3798
+ !Options.excludeAttrKind (TAK_convention) &&
3799
+ info.getSILRepresentation () != SILFunctionType::Representation::Thick) {
3800
+ Printer.callPrintStructurePre (PrintStructureKind::BuiltinAttribute);
3801
+ Printer.printAttrName (" @convention" );
3802
+ Printer << " (" ;
3805
3803
// TODO: coalesce into a single convention attribute.
3806
3804
switch (info.getSILRepresentation ()) {
3807
3805
case SILFunctionType::Representation::Thick:
3808
- break ;
3806
+ llvm_unreachable ( " thick is not printed " ) ;
3809
3807
case SILFunctionType::Representation::Thin:
3810
- Printer << " @convention( thin) " ;
3808
+ Printer << " thin" ;
3811
3809
break ;
3812
3810
case SILFunctionType::Representation::Block:
3813
- Printer << " @convention( block) " ;
3811
+ Printer << " block" ;
3814
3812
break ;
3815
3813
case SILFunctionType::Representation::CFunctionPointer:
3816
- Printer << " @convention(c) " ;
3814
+ Printer << " c " ;
3817
3815
break ;
3818
3816
case SILFunctionType::Representation::Method:
3819
- Printer << " @convention( method) " ;
3817
+ Printer << " method" ;
3820
3818
break ;
3821
3819
case SILFunctionType::Representation::ObjCMethod:
3822
- Printer << " @convention( objc_method) " ;
3820
+ Printer << " objc_method" ;
3823
3821
break ;
3824
3822
case SILFunctionType::Representation::WitnessMethod:
3825
- Printer << " @convention( witness_method) " ;
3823
+ Printer << " witness_method" ;
3826
3824
break ;
3827
3825
}
3826
+ Printer << " )" ;
3827
+ Printer.printStructurePost (PrintStructureKind::BuiltinAttribute);
3828
+ Printer << " " ;
3828
3829
}
3829
3830
}
3830
3831
3831
3832
void printFunctionExtInfo (SILFunctionType::ExtInfo info) {
3832
3833
if (Options.SkipAttributes )
3833
3834
return ;
3834
3835
3835
- if (Options.PrintFunctionRepresentationAttrs ) {
3836
+ if (Options.PrintFunctionRepresentationAttrs &&
3837
+ !Options.excludeAttrKind (TAK_convention) &&
3838
+ info.getRepresentation () != SILFunctionType::Representation::Thick) {
3839
+ Printer.callPrintStructurePre (PrintStructureKind::BuiltinAttribute);
3840
+ Printer.printAttrName (" @convention" );
3841
+ Printer << " (" ;
3836
3842
// TODO: coalesce into a single convention attribute.
3837
3843
switch (info.getRepresentation ()) {
3838
3844
case SILFunctionType::Representation::Thick:
3839
- break ;
3845
+ llvm_unreachable ( " thick is not printed " ) ;
3840
3846
case SILFunctionType::Representation::Thin:
3841
- Printer << " @convention( thin) " ;
3847
+ Printer << " thin" ;
3842
3848
break ;
3843
3849
case SILFunctionType::Representation::Block:
3844
- Printer << " @convention( block) " ;
3850
+ Printer << " block" ;
3845
3851
break ;
3846
3852
case SILFunctionType::Representation::CFunctionPointer:
3847
- Printer << " @convention(c) " ;
3853
+ Printer << " c " ;
3848
3854
break ;
3849
3855
case SILFunctionType::Representation::Method:
3850
- Printer << " @convention( method) " ;
3856
+ Printer << " method" ;
3851
3857
break ;
3852
3858
case SILFunctionType::Representation::ObjCMethod:
3853
- Printer << " @convention( objc_method) " ;
3859
+ Printer << " objc_method" ;
3854
3860
break ;
3855
3861
case SILFunctionType::Representation::WitnessMethod:
3856
- Printer << " @convention( witness_method) " ;
3862
+ Printer << " witness_method" ;
3857
3863
break ;
3858
3864
}
3865
+ Printer << " )" ;
3866
+ Printer.printStructurePost (PrintStructureKind::BuiltinAttribute);
3867
+ Printer << " " ;
3859
3868
}
3860
3869
3861
- if (info.isPseudogeneric ())
3862
- Printer << " @pseudogeneric " ;
3870
+ if (info.isPseudogeneric ()) {
3871
+ Printer.printSimpleAttr (" @pseudogeneric" ) << " " ;
3872
+ }
3863
3873
}
3864
3874
3865
3875
void visitFunctionType (FunctionType *T) {
0 commit comments