mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Keep track of whether a given Swift 'import' statement is '@_exported'
This commit is contained in:
@@ -117,16 +117,16 @@ bool ModuleDependencyInfo::isTestableImport(StringRef moduleName) const {
|
||||
}
|
||||
|
||||
void ModuleDependencyInfo::addOptionalModuleImport(
|
||||
StringRef module, llvm::StringSet<> *alreadyAddedModules) {
|
||||
StringRef module, bool isExported, llvm::StringSet<> *alreadyAddedModules) {
|
||||
if (!alreadyAddedModules || alreadyAddedModules->insert(module).second)
|
||||
storage->optionalModuleImports.push_back(module.str());
|
||||
storage->optionalModuleImports.push_back({module.str(), isExported});
|
||||
}
|
||||
|
||||
void ModuleDependencyInfo::addModuleImport(
|
||||
StringRef module, llvm::StringSet<> *alreadyAddedModules,
|
||||
StringRef module, bool isExported, llvm::StringSet<> *alreadyAddedModules,
|
||||
const SourceManager *sourceManager, SourceLoc sourceLocation) {
|
||||
auto scannerImportLocToDiagnosticLocInfo =
|
||||
[&sourceManager](SourceLoc sourceLocation) {
|
||||
[&sourceManager, isExported](SourceLoc sourceLocation) {
|
||||
auto lineAndColumnNumbers =
|
||||
sourceManager->getLineAndColumnInBuffer(sourceLocation);
|
||||
return ScannerImportStatementInfo::ImportDiagnosticLocationInfo(
|
||||
@@ -137,14 +137,16 @@ void ModuleDependencyInfo::addModuleImport(
|
||||
sourceManager->isOwning(sourceLocation);
|
||||
|
||||
if (alreadyAddedModules && alreadyAddedModules->contains(module)) {
|
||||
if (validSourceLocation) {
|
||||
// Find a prior import of this module and add import location
|
||||
for (auto &existingImport : storage->moduleImports) {
|
||||
if (existingImport.importIdentifier == module) {
|
||||
// Find a prior import of this module and add import location
|
||||
// and adjust whether or not this module is ever imported as exported
|
||||
for (auto &existingImport : storage->moduleImports) {
|
||||
if (existingImport.importIdentifier == module) {
|
||||
if (validSourceLocation) {
|
||||
existingImport.addImportLocation(
|
||||
scannerImportLocToDiagnosticLocInfo(sourceLocation));
|
||||
break;
|
||||
scannerImportLocToDiagnosticLocInfo(sourceLocation));
|
||||
}
|
||||
existingImport.isExported |= isExported;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -153,15 +155,15 @@ void ModuleDependencyInfo::addModuleImport(
|
||||
|
||||
if (validSourceLocation)
|
||||
storage->moduleImports.push_back(ScannerImportStatementInfo(
|
||||
module.str(), scannerImportLocToDiagnosticLocInfo(sourceLocation)));
|
||||
module.str(), isExported, scannerImportLocToDiagnosticLocInfo(sourceLocation)));
|
||||
else
|
||||
storage->moduleImports.push_back(
|
||||
ScannerImportStatementInfo(module.str()));
|
||||
ScannerImportStatementInfo(module.str(), isExported));
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleDependencyInfo::addModuleImport(
|
||||
ImportPath::Module module, llvm::StringSet<> *alreadyAddedModules,
|
||||
ImportPath::Module module, bool isExported, llvm::StringSet<> *alreadyAddedModules,
|
||||
const SourceManager *sourceManager, SourceLoc sourceLocation) {
|
||||
std::string ImportedModuleName = module.front().Item.str().str();
|
||||
auto submodulePath = module.getSubmodulePath();
|
||||
@@ -174,7 +176,7 @@ void ModuleDependencyInfo::addModuleImport(
|
||||
alreadyAddedModules);
|
||||
}
|
||||
|
||||
addModuleImport(ImportedModuleName, alreadyAddedModules,
|
||||
addModuleImport(ImportedModuleName, isExported, alreadyAddedModules,
|
||||
sourceManager, sourceLocation);
|
||||
}
|
||||
|
||||
@@ -203,7 +205,8 @@ void ModuleDependencyInfo::addModuleImports(
|
||||
importDecl->isExported()))
|
||||
continue;
|
||||
|
||||
addModuleImport(realPath, &alreadyAddedModules, sourceManager,
|
||||
addModuleImport(realPath, importDecl->isExported(),
|
||||
&alreadyAddedModules, sourceManager,
|
||||
importDecl->getLoc());
|
||||
|
||||
// Additionally, keep track of which dependencies of a Source
|
||||
|
||||
Reference in New Issue
Block a user