mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Dependency Scanning] Keep track of whether a given Swift 'import' statement is '@_exported'
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -60,6 +60,8 @@ using IsStaticField = BCFixed<1>;
|
||||
using IsForceLoadField = BCFixed<1>;
|
||||
/// A bit taht indicates whether or not an import statement is optional
|
||||
using IsOptionalImport = BCFixed<1>;
|
||||
/// A bit taht indicates whether or not an import statement is @_exported
|
||||
using IsExportedImport = BCFixed<1>;
|
||||
|
||||
/// Source location fields
|
||||
using LineNumberField = BCFixed<32>;
|
||||
@@ -176,7 +178,8 @@ using ImportStatementLayout =
|
||||
IdentifierIDField, // bufferIdentifier
|
||||
LineNumberField, // lineNumber
|
||||
ColumnNumberField, // columnNumber
|
||||
IsOptionalImport // isOptional
|
||||
IsOptionalImport, // isOptional
|
||||
IsExportedImport // isExported
|
||||
>;
|
||||
using ImportStatementArrayLayout =
|
||||
BCRecordLayout<IMPORT_STATEMENT_ARRAY_NODE, IdentifierIDArryField>;
|
||||
|
||||
@@ -171,6 +171,7 @@ protected:
|
||||
|
||||
struct BinaryModuleImports {
|
||||
llvm::StringSet<> moduleImports;
|
||||
llvm::StringSet<> exportedModules;
|
||||
std::string headerImport;
|
||||
};
|
||||
|
||||
@@ -185,7 +186,7 @@ protected:
|
||||
|
||||
/// If the module has a package name matching the one
|
||||
/// specified, return a set of package-only imports for this module.
|
||||
static llvm::ErrorOr<llvm::StringSet<>>
|
||||
static llvm::ErrorOr<std::vector<ScannerImportStatementInfo>>
|
||||
getMatchingPackageOnlyImportsOfModule(Twine modulePath,
|
||||
bool isFramework,
|
||||
bool isRequiredOSSAModules,
|
||||
|
||||
Reference in New Issue
Block a user