mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Keep track of each imported module's access control
Adds an access control field for each imported module identified. When multiple imports of the same module are found, this keeps track of the most "open" access specifier.
This commit is contained in:
@@ -544,6 +544,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
|
||||
|
||||
case ImplicitStdlibKind::Stdlib:
|
||||
mainDependencies.addModuleImport("Swift", /* isExported */false,
|
||||
AccessLevel::Public,
|
||||
&alreadyAddedModules);
|
||||
break;
|
||||
}
|
||||
@@ -552,6 +553,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
|
||||
for (const auto &import : importInfo.AdditionalUnloadedImports) {
|
||||
mainDependencies.addModuleImport(import.module.getModulePath(),
|
||||
import.options.contains(ImportFlags::Exported),
|
||||
import.accessLevel,
|
||||
&alreadyAddedModules,
|
||||
&ScanASTContext.SourceMgr);
|
||||
}
|
||||
@@ -561,6 +563,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
|
||||
mainDependencies.addModuleImport(
|
||||
import.module.importedModule->getNameStr(),
|
||||
import.options.contains(ImportFlags::Exported),
|
||||
import.accessLevel,
|
||||
&alreadyAddedModules);
|
||||
}
|
||||
|
||||
@@ -574,6 +577,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
|
||||
if (importInfo.ShouldImportUnderlyingModule) {
|
||||
mainDependencies.addModuleImport(mainModule->getName().str(),
|
||||
/* isExported */ true,
|
||||
AccessLevel::Public,
|
||||
&alreadyAddedModules);
|
||||
}
|
||||
|
||||
@@ -584,6 +588,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
|
||||
ScanCompilerInvocation.getTBDGenOptions().embedSymbolsFromModules) {
|
||||
mainDependencies.addModuleImport(tbdSymbolModule,
|
||||
/* isExported */ false,
|
||||
AccessLevel::Public,
|
||||
&alreadyAddedModules);
|
||||
}
|
||||
}
|
||||
@@ -948,7 +953,8 @@ void ModuleDependencyScanner::resolveAllClangModuleDependencies(
|
||||
if (importInfo.importIdentifier ==
|
||||
ScanASTContext.Id_CxxStdlib.str()) {
|
||||
auto canonicalImportInfo = ScannerImportStatementInfo(
|
||||
"std", importInfo.isExported, importInfo.importLocations);
|
||||
"std", importInfo.isExported, importInfo.accessLevel,
|
||||
importInfo.importLocations);
|
||||
unresolvedImports.push_back(canonicalImportInfo);
|
||||
unresolvedImportIdentifiers.insert(
|
||||
canonicalImportInfo.importIdentifier);
|
||||
@@ -1475,7 +1481,9 @@ void ModuleDependencyScanner::resolveCrossImportOverlayDependencies(
|
||||
std::for_each(newOverlays.begin(), newOverlays.end(),
|
||||
[&](Identifier modName) {
|
||||
dummyMainDependencies.addModuleImport(modName.str(),
|
||||
/* isExported */ false);
|
||||
/* isExported */ false,
|
||||
// TODO: What is the right access level for a cross-import overlay?
|
||||
AccessLevel::Public);
|
||||
});
|
||||
|
||||
// Record the dummy main module's direct dependencies. The dummy main module
|
||||
|
||||
Reference in New Issue
Block a user