@@ -1720,9 +1720,9 @@ void ModuleDecl::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
17201720 FORWARD (getImportedModules, (modules, filter));
17211721}
17221722
1723- void ModuleDecl::getMissingImportedModules (
1723+ void ModuleDecl::getImplicitImportsForModuleInterface (
17241724 SmallVectorImpl<ImportedModule> &imports) const {
1725- FORWARD (getMissingImportedModules , (imports));
1725+ FORWARD (getImplicitImportsForModuleInterface , (imports));
17261726}
17271727
17281728const llvm::DenseMap<const clang::Module *, ModuleDecl *> &
@@ -1811,9 +1811,9 @@ SourceFile::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
18111811 }
18121812}
18131813
1814- void SourceFile::getMissingImportedModules (
1814+ void SourceFile::getImplicitImportsForModuleInterface (
18151815 SmallVectorImpl<ImportedModule> &modules) const {
1816- for (auto module : MissingImportedModules )
1816+ for (auto module : ImplicitImportsForModuleInterface )
18171817 modules.push_back (module );
18181818}
18191819
@@ -2817,13 +2817,13 @@ bool SourceFile::hasImportsWithFlag(ImportFlags flag) const {
28172817 ctx.evaluator , HasImportsMatchingFlagRequest{mutableThis, flag}, false );
28182818}
28192819
2820- ImportFlags SourceFile::getImportFlags (const ModuleDecl *module ) const {
2821- unsigned flags = 0x0 ;
2820+ void SourceFile::forEachImportOfModule (
2821+ const ModuleDecl *module ,
2822+ llvm::function_ref<void (AttributedImport<ImportedModule> &)> callback) {
28222823 for (auto import : *Imports) {
28232824 if (import .module .importedModule == module )
2824- flags |= import . options . toRaw ( );
2825+ callback ( import );
28252826 }
2826- return ImportFlags (flags);
28272827}
28282828
28292829bool SourceFile::hasTestableOrPrivateImport (
@@ -4093,62 +4093,3 @@ version::Version ModuleDecl::getLanguageVersionBuiltWith() const {
40934093
40944094 return version::Version ();
40954095}
4096-
4097- bool swift::diagnoseMissingImportForMember (const ValueDecl *decl,
4098- const DeclContext *dc,
4099- SourceLoc loc) {
4100- if (decl->findImport (dc))
4101- return false ;
4102-
4103- auto &ctx = dc->getASTContext ();
4104- auto definingModule = decl->getModuleContext ();
4105- ctx.Diags .diagnose (loc, diag::candidate_from_missing_import,
4106- decl->getDescriptiveKind (), decl->getName (),
4107- definingModule);
4108-
4109- SourceLoc bestLoc =
4110- ctx.Diags .getBestAddImportFixItLoc (decl, dc->getParentSourceFile ());
4111- if (!bestLoc.isValid ())
4112- return false ;
4113-
4114- llvm::SmallString<64 > importText;
4115-
4116- // Check other source files for import flags that should be applied to the
4117- // fix-it for consistency with the rest of the imports in the module.
4118- auto parentModule = dc->getParentModule ();
4119- OptionSet<ImportFlags> flags;
4120- for (auto file : parentModule->getFiles ()) {
4121- if (auto sf = dyn_cast<SourceFile>(file))
4122- flags |= sf->getImportFlags (definingModule);
4123- }
4124-
4125- if (flags.contains (ImportFlags::Exported) ||
4126- parentModule->isClangOverlayOf (definingModule))
4127- importText += " @_exported " ;
4128- if (flags.contains (ImportFlags::ImplementationOnly))
4129- importText += " @_implementationOnly " ;
4130- if (flags.contains (ImportFlags::WeakLinked))
4131- importText += " @_weakLinked " ;
4132- if (flags.contains (ImportFlags::SPIOnly))
4133- importText += " @_spiOnly " ;
4134-
4135- // FIXME: Access level should be considered, too.
4136-
4137- // @_spi imports.
4138- if (decl->isSPI ()) {
4139- auto spiGroups = decl->getSPIGroups ();
4140- if (!spiGroups.empty ()) {
4141- importText += " @_spi(" ;
4142- importText += spiGroups[0 ].str ();
4143- importText += " ) " ;
4144- }
4145- }
4146-
4147- importText += " import " ;
4148- importText += definingModule->getName ().str ();
4149- importText += " \n " ;
4150- ctx.Diags .diagnose (bestLoc, diag::candidate_add_import, definingModule)
4151- .fixItInsert (bestLoc, importText);
4152-
4153- return true ;
4154- }
0 commit comments