diff --git a/include/swift/AST/PrintOptions.h b/include/swift/AST/PrintOptions.h index 1da42a4c944..87b1b408927 100644 --- a/include/swift/AST/PrintOptions.h +++ b/include/swift/AST/PrintOptions.h @@ -67,6 +67,9 @@ struct PrintOptions { /// \brief Whether to print implicit parts of the AST. bool SkipImplicit = false; + /// \brief Whether to print unavailable parts of the AST. + bool SkipUnavailable = false; + bool PrintImplicitAttrs = true; /// \brief Whether to print documentation comments attached to declarations. diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index d3fc23a414e..b00499c9c28 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -553,6 +553,9 @@ void PrintAST::printMembers(ArrayRef members, bool needComma) { if (Options.SkipImplicit && member->isImplicit()) continue; + if (Options.SkipUnavailable && member->getAttrs().isUnavailable()) + continue; + indent(); visit(member); if (needComma && member != members.back()) diff --git a/lib/IDE/ModuleInterfacePrinting.cpp b/lib/IDE/ModuleInterfacePrinting.cpp index 64ca9ba016d..6a929444619 100644 --- a/lib/IDE/ModuleInterfacePrinting.cpp +++ b/lib/IDE/ModuleInterfacePrinting.cpp @@ -131,6 +131,10 @@ void swift::ide::printSubmoduleInterface( // Separate the declarations that we are going to print into different // buckets. for (Decl *D : Decls) { + // If requested, skip unavailable declarations. + if (Options.SkipUnavailable && D->getAttrs().isUnavailable()) + continue; + if (auto ID = dyn_cast(D)) { ImportDecls.push_back(ID); continue; @@ -145,8 +149,9 @@ void swift::ide::printSubmoduleInterface( auto *OwningModule = Importer.getClangOwningModule(CN); auto I = ClangDecls.find(OwningModule); - if (I != ClangDecls.end()) + if (I != ClangDecls.end()) { I->second.push_back({ D, Loc }); + } continue; } SwiftDecls.push_back(D);