19
19
#include " swift/AST/ASTMangler.h"
20
20
#include " swift/AST/ASTVisitor.h"
21
21
#include " swift/AST/Attr.h"
22
- #include " swift/AST/ClangModuleLoader.h"
23
22
#include " swift/AST/Comment.h"
24
23
#include " swift/AST/Decl.h"
25
24
#include " swift/AST/Expr.h"
@@ -99,8 +98,7 @@ static bool contributesToParentTypeStorage(const AbstractStorageDecl *ASD) {
99
98
return !ND->isResilient () && ASD->hasStorage () && !ASD->isStatic ();
100
99
}
101
100
102
- PrintOptions PrintOptions::printSwiftInterfaceFile (bool preferTypeRepr,
103
- bool printFullConvention) {
101
+ PrintOptions PrintOptions::printSwiftInterfaceFile (bool preferTypeRepr) {
104
102
PrintOptions result;
105
103
result.PrintLongAttrsOnSeparateLines = true ;
106
104
result.TypeDefinitions = true ;
@@ -117,9 +115,6 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(bool preferTypeRepr,
117
115
result.OpaqueReturnTypePrinting =
118
116
OpaqueReturnTypePrintingMode::StableReference;
119
117
result.PreferTypeRepr = preferTypeRepr;
120
- if (printFullConvention)
121
- result.PrintFunctionRepresentationAttrs =
122
- PrintOptions::FunctionRepresentationMode::Full;
123
118
124
119
// We should print __consuming, __owned, etc for the module interface file.
125
120
result.SkipUnderscoredKeywords = false ;
@@ -326,14 +321,6 @@ void ASTPrinter::callPrintDeclPre(const Decl *D,
326
321
printDeclPre (D, Bracket);
327
322
}
328
323
329
- ASTPrinter &ASTPrinter::operator <<(QuotedString s) {
330
- llvm::SmallString<32 > Str;
331
- llvm::raw_svector_ostream OS (Str);
332
- OS << s;
333
- printTextImpl (OS.str ());
334
- return *this ;
335
- }
336
-
337
324
ASTPrinter &ASTPrinter::operator <<(unsigned long long N) {
338
325
llvm::SmallString<32 > Str;
339
326
llvm::raw_svector_ostream OS (Str);
@@ -3491,15 +3478,6 @@ void Pattern::print(llvm::raw_ostream &OS, const PrintOptions &Options) const {
3491
3478
// Type Printing
3492
3479
// ===----------------------------------------------------------------------===//
3493
3480
3494
- template <typename ExtInfo>
3495
- void printCType (ASTContext &Ctx, ASTPrinter &Printer, ExtInfo &info) {
3496
- auto *cml = Ctx.getClangModuleLoader ();
3497
- SmallString<64 > buf;
3498
- llvm::raw_svector_ostream os (buf);
3499
- info.getUncommonInfo ().getValue ().printClangFunctionType (cml, os);
3500
- Printer << " , cType: " << QuotedString (os.str ());
3501
- }
3502
-
3503
3481
namespace {
3504
3482
class TypePrinter : public TypeVisitor <TypePrinter> {
3505
3483
using super = TypeVisitor;
@@ -3862,7 +3840,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3862
3840
visit (staticSelfT);
3863
3841
}
3864
3842
3865
- void printFunctionExtInfo (ASTContext &Ctx, AnyFunctionType::ExtInfo info) {
3843
+ void printFunctionExtInfo (AnyFunctionType::ExtInfo info) {
3866
3844
if (Options.SkipAttributes )
3867
3845
return ;
3868
3846
@@ -3875,18 +3853,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3875
3853
}
3876
3854
}
3877
3855
3878
- SmallString<64 > buf;
3879
- switch (Options.PrintFunctionRepresentationAttrs ) {
3880
- case PrintOptions::FunctionRepresentationMode::None:
3881
- return ;
3882
- case PrintOptions::FunctionRepresentationMode::Full:
3883
- case PrintOptions::FunctionRepresentationMode::NameOnly:
3884
- if (Options.excludeAttrKind (TAK_convention) ||
3885
- info.getSILRepresentation () == SILFunctionType::Representation::Thick)
3886
- return ;
3887
-
3888
- bool printNameOnly = Options.PrintFunctionRepresentationAttrs ==
3889
- PrintOptions::FunctionRepresentationMode::NameOnly;
3856
+ if (Options.PrintFunctionRepresentationAttrs &&
3857
+ !Options.excludeAttrKind (TAK_convention) &&
3858
+ info.getSILRepresentation () != SILFunctionType::Representation::Thick) {
3890
3859
Printer.callPrintStructurePre (PrintStructureKind::BuiltinAttribute);
3891
3860
Printer.printAttrName (" @convention" );
3892
3861
Printer << " (" ;
@@ -3902,11 +3871,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3902
3871
break ;
3903
3872
case SILFunctionType::Representation::CFunctionPointer:
3904
3873
Printer << " c" ;
3905
- // FIXME: [clang-function-type-serialization] Once we start serializing
3906
- // Clang function types, we should be able to remove the second check.
3907
- if (printNameOnly || !info.getUncommonInfo ().hasValue ())
3908
- break ;
3909
- printCType (Ctx, Printer, info);
3910
3874
break ;
3911
3875
case SILFunctionType::Representation::Method:
3912
3876
Printer << " method" ;
@@ -3927,8 +3891,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3927
3891
}
3928
3892
}
3929
3893
3930
- void printFunctionExtInfo (ASTContext &Ctx,
3931
- SILFunctionType::ExtInfo info,
3894
+ void printFunctionExtInfo (SILFunctionType::ExtInfo info,
3932
3895
ProtocolConformanceRef witnessMethodConformance) {
3933
3896
if (Options.SkipAttributes )
3934
3897
return ;
@@ -3942,19 +3905,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3942
3905
}
3943
3906
}
3944
3907
3945
-
3946
- SmallString<64 > buf;
3947
- switch (Options.PrintFunctionRepresentationAttrs ) {
3948
- case PrintOptions::FunctionRepresentationMode::None:
3949
- break ;
3950
- case PrintOptions::FunctionRepresentationMode::NameOnly:
3951
- case PrintOptions::FunctionRepresentationMode::Full:
3952
- if (Options.excludeAttrKind (TAK_convention) ||
3953
- info.getRepresentation () == SILFunctionType::Representation::Thick)
3954
- break ;
3955
-
3956
- bool printNameOnly = Options.PrintFunctionRepresentationAttrs ==
3957
- PrintOptions::FunctionRepresentationMode::NameOnly;
3908
+ if (Options.PrintFunctionRepresentationAttrs &&
3909
+ !Options.excludeAttrKind (TAK_convention) &&
3910
+ info.getRepresentation () != SILFunctionType::Representation::Thick) {
3958
3911
Printer.callPrintStructurePre (PrintStructureKind::BuiltinAttribute);
3959
3912
Printer.printAttrName (" @convention" );
3960
3913
Printer << " (" ;
@@ -3969,11 +3922,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
3969
3922
break ;
3970
3923
case SILFunctionType::Representation::CFunctionPointer:
3971
3924
Printer << " c" ;
3972
- // FIXME: [clang-function-type-serialization] Once we start serializing
3973
- // Clang function types, we should be able to remove the second check.
3974
- if (printNameOnly || !info.getUncommonInfo ().hasValue ())
3975
- break ;
3976
- printCType (Ctx, Printer, info);
3977
3925
break ;
3978
3926
case SILFunctionType::Representation::Method:
3979
3927
Printer << " method" ;
@@ -4043,7 +3991,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
4043
3991
Printer.printStructurePost (PrintStructureKind::FunctionType);
4044
3992
};
4045
3993
4046
- printFunctionExtInfo (T->getASTContext (), T-> getExtInfo ());
3994
+ printFunctionExtInfo (T->getExtInfo ());
4047
3995
4048
3996
// If we're stripping argument labels from types, do it when printing.
4049
3997
visitAnyFunctionTypeParams (T->getParams (), /* printLabels*/ false );
@@ -4080,7 +4028,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
4080
4028
Printer.printStructurePost (PrintStructureKind::FunctionType);
4081
4029
};
4082
4030
4083
- printFunctionExtInfo (T->getASTContext (), T-> getExtInfo ());
4031
+ printFunctionExtInfo (T->getExtInfo ());
4084
4032
printGenericSignature (T->getGenericSignature (),
4085
4033
PrintAST::PrintParams |
4086
4034
PrintAST::PrintRequirements);
@@ -4133,7 +4081,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
4133
4081
4134
4082
void visitSILFunctionType (SILFunctionType *T) {
4135
4083
printSILCoroutineKind (T->getCoroutineKind ());
4136
- printFunctionExtInfo (T->getASTContext (), T-> getExtInfo (),
4084
+ printFunctionExtInfo (T->getExtInfo (),
4137
4085
T->getWitnessMethodConformanceOrInvalid ());
4138
4086
printCalleeConvention (T->getCalleeConvention ());
4139
4087
0 commit comments