[Dependency Scanning] Keep track of whether a given Swift 'import' statement is '@_exported'

This commit is contained in:
Artem Chikin
2025-02-26 15:52:46 -08:00
parent 714c862d37
commit 809dbf0994
8 changed files with 70 additions and 40 deletions

View File

@@ -154,12 +154,14 @@ struct ScannerImportStatementInfo {
uint32_t columnNumber;
};
ScannerImportStatementInfo(std::string importIdentifier)
: importLocations(), importIdentifier(importIdentifier) {}
ScannerImportStatementInfo(std::string importIdentifier, bool isExported)
: importLocations(), importIdentifier(importIdentifier),
isExported(isExported) {}
ScannerImportStatementInfo(std::string importIdentifier,
ScannerImportStatementInfo(std::string importIdentifier, bool isExported,
ImportDiagnosticLocationInfo location)
: importLocations({location}), importIdentifier(importIdentifier) {}
: importLocations({location}), importIdentifier(importIdentifier),
isExported(isExported) {}
void addImportLocation(ImportDiagnosticLocationInfo location) {
importLocations.push_back(location);
@@ -169,6 +171,8 @@ struct ScannerImportStatementInfo {
SmallVector<ImportDiagnosticLocationInfo, 4> importLocations;
/// Imported module string. e.g. "Foo.Bar" in 'import Foo.Bar'
std::string importIdentifier;
/// Is this an @_exported import
bool isExported;
};
/// Base class for the variant storage of ModuleDependencyInfo.
@@ -927,7 +931,7 @@ public:
/// Add a dependency on the given module, if it was not already in the set.
void
addOptionalModuleImport(StringRef module,
addOptionalModuleImport(StringRef module, bool isExported,
llvm::StringSet<> *alreadyAddedModules = nullptr);
/// Add all of the module imports in the given source
@@ -937,13 +941,13 @@ public:
const SourceManager *sourceManager);
/// Add a dependency on the given module, if it was not already in the set.
void addModuleImport(ImportPath::Module module,
void addModuleImport(ImportPath::Module module, bool isExported,
llvm::StringSet<> *alreadyAddedModules = nullptr,
const SourceManager *sourceManager = nullptr,
SourceLoc sourceLocation = SourceLoc());
/// Add a dependency on the given module, if it was not already in the set.
void addModuleImport(StringRef module,
void addModuleImport(StringRef module, bool isExported,
llvm::StringSet<> *alreadyAddedModules = nullptr,
const SourceManager *sourceManager = nullptr,
SourceLoc sourceLocation = SourceLoc());