@@ -3154,6 +3154,15 @@ suppressingFeatureConformanceSuppression(PrintOptions &options,
31543154 options.ExcludeAttrList .resize (originalExcludeAttrCount);
31553155}
31563156
3157+ static void
3158+ suppressingFeatureBitwiseCopyable2 (PrintOptions &options,
3159+ llvm::function_ref<void ()> action) {
3160+ unsigned originalExcludeAttrCount = options.ExcludeAttrList .size ();
3161+ llvm::SaveAndRestore<bool > scope (options.SuppressBitwiseCopyable , true );
3162+ action ();
3163+ options.ExcludeAttrList .resize (originalExcludeAttrCount);
3164+ }
3165+
31573166// / Suppress the printing of a particular feature.
31583167static void suppressingFeature (PrintOptions &options, Feature feature,
31593168 llvm::function_ref<void ()> action) {
@@ -3436,17 +3445,29 @@ void PrintAST::visitOpaqueTypeDecl(OpaqueTypeDecl *decl) {
34363445}
34373446
34383447void PrintAST::visitTypeAliasDecl (TypeAliasDecl *decl) {
3448+ auto name = decl->getName ();
3449+ bool suppressingBitwiseCopyable =
3450+ Options.SuppressBitwiseCopyable &&
3451+ decl->getModuleContext ()->isStdlibModule () &&
3452+ (decl->getNameStr () == " _BitwiseCopyable" );
3453+ if (suppressingBitwiseCopyable) {
3454+ name = decl->getASTContext ().getIdentifier (" BitwiseCopyable" );
3455+ }
34393456 printDocumentationComment (decl);
34403457 printAttributes (decl);
34413458 printAccess (decl);
34423459 Printer.printIntroducerKeyword (" typealias" , Options, " " );
34433460 printContextIfNeeded (decl);
34443461 recordDeclLoc (decl,
34453462 [&]{
3446- Printer.printName (decl-> getName () , getTypeMemberPrintNameContext (decl));
3463+ Printer.printName (name , getTypeMemberPrintNameContext (decl));
34473464 }, [&]{ // Signature
34483465 printGenericDeclGenericParams (decl);
34493466 });
3467+ if (suppressingBitwiseCopyable) {
3468+ Printer << " = Swift._BitwiseCopyable" ;
3469+ return ;
3470+ }
34503471 bool ShouldPrint = true ;
34513472 Type Ty = decl->getUnderlyingType ();
34523473
@@ -3627,6 +3648,12 @@ void PrintAST::printPrimaryAssociatedTypes(ProtocolDecl *decl) {
36273648}
36283649
36293650void PrintAST::visitProtocolDecl (ProtocolDecl *decl) {
3651+ auto name = decl->getName ();
3652+ if (Options.SuppressBitwiseCopyable &&
3653+ decl->getModuleContext ()->isStdlibModule () &&
3654+ (decl->getNameStr () == " BitwiseCopyable" )) {
3655+ name = decl->getASTContext ().getIdentifier (" _BitwiseCopyable" );
3656+ }
36303657 printDocumentationComment (decl);
36313658 printAttributes (decl);
36323659 printAccess (decl);
@@ -3640,7 +3667,7 @@ void PrintAST::visitProtocolDecl(ProtocolDecl *decl) {
36403667 printContextIfNeeded (decl);
36413668 recordDeclLoc (decl,
36423669 [&]{
3643- Printer.printName (decl-> getName () );
3670+ Printer.printName (name );
36443671 });
36453672
36463673 if (Options.PrintPrimaryAssociatedTypes ) {
0 commit comments