Simplify swift::getInheritedForPrinting to take a PrintOptions

This lets us make some more assumptions in the next commit, but I
think it's also just a nice cleanup to /not/ allow random predicates
here.

There were three callers of this API:

- PrintAST, which was using PrintOptions::shouldPrint but /also/
  incorrectly notifying listeners that a declaration would be skipped.

- (IDE) Interface generation, which uses PrintOptions::shouldPrint to
  count how many "inherits" there will be.

- SwiftDocSupport's reportRelated, which does no filtering at all.
  Creating a PrintOptions here is a little more expensive, but still.

No intended functionality change.
This commit is contained in:
Jordan Rose
2019-05-14 14:52:17 -07:00
parent e9384bb351
commit c622f6b8dd
5 changed files with 11 additions and 15 deletions

View File

@@ -547,7 +547,7 @@ static void reportRelated(ASTContext &Ctx, const Decl *D,
passInheritsAndConformancesForValueDecl(TAD, Consumer);
} else if (const auto *TD = dyn_cast<TypeDecl>(D)) {
llvm::SmallVector<TypeLoc, 4> AllInherits;
getInheritedForPrinting(TD, [](const Decl* d) { return true; }, AllInherits);
getInheritedForPrinting(TD, PrintOptions(), AllInherits);
passInherits(AllInherits, Consumer);
passConforms(TD->getSatisfiedProtocolRequirements(/*Sorted=*/true),
Consumer);