1919#include " swift/AST/ASTMangler.h"
2020#include " swift/AST/ASTVisitor.h"
2121#include " swift/AST/Attr.h"
22- #include " swift/AST/ClangModuleLoader.h"
2322#include " swift/AST/Comment.h"
2423#include " swift/AST/Decl.h"
2524#include " swift/AST/Expr.h"
@@ -99,8 +98,7 @@ static bool contributesToParentTypeStorage(const AbstractStorageDecl *ASD) {
9998 return !ND->isResilient () && ASD->hasStorage () && !ASD->isStatic ();
10099}
101100
102- PrintOptions PrintOptions::printSwiftInterfaceFile (bool preferTypeRepr,
103- bool printFullConvention) {
101+ PrintOptions PrintOptions::printSwiftInterfaceFile (bool preferTypeRepr) {
104102 PrintOptions result;
105103 result.PrintLongAttrsOnSeparateLines = true ;
106104 result.TypeDefinitions = true ;
@@ -117,9 +115,6 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(bool preferTypeRepr,
117115 result.OpaqueReturnTypePrinting =
118116 OpaqueReturnTypePrintingMode::StableReference;
119117 result.PreferTypeRepr = preferTypeRepr;
120- if (printFullConvention)
121- result.PrintFunctionRepresentationAttrs =
122- PrintOptions::FunctionRepresentationMode::Full;
123118
124119 // We should print __consuming, __owned, etc for the module interface file.
125120 result.SkipUnderscoredKeywords = false ;
@@ -326,14 +321,6 @@ void ASTPrinter::callPrintDeclPre(const Decl *D,
326321 printDeclPre (D, Bracket);
327322}
328323
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-
337324ASTPrinter &ASTPrinter::operator <<(unsigned long long N) {
338325 llvm::SmallString<32 > Str;
339326 llvm::raw_svector_ostream OS (Str);
@@ -3491,15 +3478,6 @@ void Pattern::print(llvm::raw_ostream &OS, const PrintOptions &Options) const {
34913478// Type Printing
34923479// ===----------------------------------------------------------------------===//
34933480
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-
35033481namespace {
35043482class TypePrinter : public TypeVisitor <TypePrinter> {
35053483 using super = TypeVisitor;
@@ -3862,7 +3840,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
38623840 visit (staticSelfT);
38633841 }
38643842
3865- void printFunctionExtInfo (ASTContext &Ctx, AnyFunctionType::ExtInfo info) {
3843+ void printFunctionExtInfo (AnyFunctionType::ExtInfo info) {
38663844 if (Options.SkipAttributes )
38673845 return ;
38683846
@@ -3875,18 +3853,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
38753853 }
38763854 }
38773855
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) {
38903859 Printer.callPrintStructurePre (PrintStructureKind::BuiltinAttribute);
38913860 Printer.printAttrName (" @convention" );
38923861 Printer << " (" ;
@@ -3902,11 +3871,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
39023871 break ;
39033872 case SILFunctionType::Representation::CFunctionPointer:
39043873 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);
39103874 break ;
39113875 case SILFunctionType::Representation::Method:
39123876 Printer << " method" ;
@@ -3927,8 +3891,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
39273891 }
39283892 }
39293893
3930- void printFunctionExtInfo (ASTContext &Ctx,
3931- SILFunctionType::ExtInfo info,
3894+ void printFunctionExtInfo (SILFunctionType::ExtInfo info,
39323895 ProtocolConformanceRef witnessMethodConformance) {
39333896 if (Options.SkipAttributes )
39343897 return ;
@@ -3942,19 +3905,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
39423905 }
39433906 }
39443907
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) {
39583911 Printer.callPrintStructurePre (PrintStructureKind::BuiltinAttribute);
39593912 Printer.printAttrName (" @convention" );
39603913 Printer << " (" ;
@@ -3969,11 +3922,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
39693922 break ;
39703923 case SILFunctionType::Representation::CFunctionPointer:
39713924 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);
39773925 break ;
39783926 case SILFunctionType::Representation::Method:
39793927 Printer << " method" ;
@@ -4043,7 +3991,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
40433991 Printer.printStructurePost (PrintStructureKind::FunctionType);
40443992 };
40453993
4046- printFunctionExtInfo (T->getASTContext (), T-> getExtInfo ());
3994+ printFunctionExtInfo (T->getExtInfo ());
40473995
40483996 // If we're stripping argument labels from types, do it when printing.
40493997 visitAnyFunctionTypeParams (T->getParams (), /* printLabels*/ false );
@@ -4080,7 +4028,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
40804028 Printer.printStructurePost (PrintStructureKind::FunctionType);
40814029 };
40824030
4083- printFunctionExtInfo (T->getASTContext (), T-> getExtInfo ());
4031+ printFunctionExtInfo (T->getExtInfo ());
40844032 printGenericSignature (T->getGenericSignature (),
40854033 PrintAST::PrintParams |
40864034 PrintAST::PrintRequirements);
@@ -4133,7 +4081,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
41334081
41344082 void visitSILFunctionType (SILFunctionType *T) {
41354083 printSILCoroutineKind (T->getCoroutineKind ());
4136- printFunctionExtInfo (T->getASTContext (), T-> getExtInfo (),
4084+ printFunctionExtInfo (T->getExtInfo (),
41374085 T->getWitnessMethodConformanceOrInvalid ());
41384086 printCalleeConvention (T->getCalleeConvention ());
41394087
0 commit comments