@@ -5724,8 +5724,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
5724
5724
5725
5725
ASTPrinter &Printer;
5726
5726
const PrintOptions &Options;
5727
- std::optional<llvm::DenseMap<const clang::Module *, ModuleDecl *>>
5728
- VisibleClangModules;
5729
5727
5730
5728
void printGenericArgs (ArrayRef<Type> flatArgs) {
5731
5729
Printer << " <" ;
@@ -5799,56 +5797,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
5799
5797
return T->hasSimpleTypeRepr ();
5800
5798
}
5801
5799
5802
- // / Computes the map that is cached by `getVisibleClangModules()`.
5803
- // / Do not call directly.
5804
- llvm::DenseMap<const clang::Module *, ModuleDecl *>
5805
- computeVisibleClangModules () {
5806
- assert (Options.CurrentModule &&
5807
- " CurrentModule needs to be set to determine imported Clang modules" );
5808
-
5809
- llvm::DenseMap<const clang::Module *, ModuleDecl *> Result;
5810
-
5811
- // For the current module, consider both private and public imports.
5812
- ModuleDecl::ImportFilter Filter = ModuleDecl::ImportFilterKind::Exported;
5813
- Filter |= ModuleDecl::ImportFilterKind::Default;
5814
-
5815
- // For private or package swiftinterfaces, also look through @_spiOnly imports.
5816
- if (!Options.printPublicInterface ())
5817
- Filter |= ModuleDecl::ImportFilterKind::SPIOnly;
5818
- // Consider package import for package interface
5819
- if (Options.printPackageInterface ())
5820
- Filter |= ModuleDecl::ImportFilterKind::PackageOnly;
5821
-
5822
- SmallVector<ImportedModule, 4 > Imports;
5823
- Options.CurrentModule ->getImportedModules (Imports, Filter);
5824
-
5825
- SmallVector<ModuleDecl *, 4 > ModulesToProcess;
5826
- for (const auto &Import : Imports) {
5827
- ModulesToProcess.push_back (Import.importedModule );
5828
- }
5829
-
5830
- SmallPtrSet<ModuleDecl *, 4 > Processed;
5831
- while (!ModulesToProcess.empty ()) {
5832
- ModuleDecl *Mod = ModulesToProcess.back ();
5833
- ModulesToProcess.pop_back ();
5834
-
5835
- if (!Processed.insert (Mod).second )
5836
- continue ;
5837
-
5838
- if (const clang::Module *ClangModule = Mod->findUnderlyingClangModule ())
5839
- Result[ClangModule] = Mod;
5840
-
5841
- // For transitive imports, consider only public imports.
5842
- Imports.clear ();
5843
- Mod->getImportedModules (Imports, ModuleDecl::ImportFilterKind::Exported);
5844
- for (const auto &Import : Imports) {
5845
- ModulesToProcess.push_back (Import.importedModule );
5846
- }
5847
- }
5848
-
5849
- return Result;
5850
- }
5851
-
5852
5800
// / Returns all Clang modules that are visible from `Options.CurrentModule`.
5853
5801
// / This includes any modules that are imported transitively through public
5854
5802
// / (`@_exported`) imports.
@@ -5857,10 +5805,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
5857
5805
// / corresponding Swift module.
5858
5806
const llvm::DenseMap<const clang::Module *, ModuleDecl *> &
5859
5807
getVisibleClangModules () {
5860
- if (!VisibleClangModules) {
5861
- VisibleClangModules = computeVisibleClangModules ();
5862
- }
5863
- return *VisibleClangModules;
5808
+ return Options.CurrentModule ->getVisibleClangModules (Options.InterfaceContentKind );
5864
5809
}
5865
5810
5866
5811
template <typename T>
0 commit comments