2222#include " swift/AST/LinkLibrary.h"
2323#include " swift/Basic/CXXStdlibKind.h"
2424#include " swift/Basic/LLVM.h"
25+ #include " swift/Serialization/Validation.h"
2526#include " clang/CAS/CASOptions.h"
2627#include " clang/Tooling/DependencyScanning/DependencyScanningService.h"
2728#include " clang/Tooling/DependencyScanning/DependencyScanningTool.h"
@@ -155,30 +156,35 @@ struct ScannerImportStatementInfo {
155156 uint32_t columnNumber;
156157 };
157158
158- ScannerImportStatementInfo (std::string importIdentifier, bool isExported)
159- : importLocations(), importIdentifier(importIdentifier),
160- isExported(isExported) {}
159+ ScannerImportStatementInfo (std::string importIdentifier, bool isExported,
160+ AccessLevel accessLevel)
161+ : importIdentifier(importIdentifier), importLocations(),
162+ isExported(isExported), accessLevel(accessLevel) {}
161163
162164 ScannerImportStatementInfo (std::string importIdentifier, bool isExported,
165+ AccessLevel accessLevel,
163166 ImportDiagnosticLocationInfo location)
164- : importLocations({location} ), importIdentifier(importIdentifier ),
165- isExported(isExported) {}
167+ : importIdentifier(importIdentifier ), importLocations({location} ),
168+ isExported(isExported), accessLevel(accessLevel) {}
166169
167170 ScannerImportStatementInfo (std::string importIdentifier, bool isExported,
171+ AccessLevel accessLevel,
168172 SmallVector<ImportDiagnosticLocationInfo, 4 > locations)
169- : importLocations(locations ), importIdentifier(importIdentifier ),
170- isExported(isExported) {}
173+ : importIdentifier(importIdentifier ), importLocations(locations ),
174+ isExported(isExported), accessLevel(accessLevel) {}
171175
172176 void addImportLocation (ImportDiagnosticLocationInfo location) {
173177 importLocations.push_back (location);
174178 }
175179
176- // / Buffer, line & column number of the import statement
177- SmallVector<ImportDiagnosticLocationInfo, 4 > importLocations;
178180 // / Imported module string. e.g. "Foo.Bar" in 'import Foo.Bar'
179181 std::string importIdentifier;
182+ // / Buffer, line & column number of the import statement
183+ SmallVector<ImportDiagnosticLocationInfo, 4 > importLocations;
180184 // / Is this an @_exported import
181185 bool isExported;
186+ // / Access level of this dependency
187+ AccessLevel accessLevel;
182188};
183189
184190// / Base class for the variant storage of ModuleDependencyInfo.
@@ -406,15 +412,18 @@ class SwiftBinaryModuleDependencyStorage
406412 StringRef sourceInfoPath,
407413 ArrayRef<ScannerImportStatementInfo> moduleImports,
408414 ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
409- ArrayRef<LinkLibrary> linkLibraries, StringRef headerImport,
410- StringRef definingModuleInterface, bool isFramework, bool isStatic,
411- StringRef moduleCacheKey, StringRef userModuleVersion)
415+ ArrayRef<LinkLibrary> linkLibraries,
416+ ArrayRef<serialization::SearchPath> serializedSearchPaths,
417+ StringRef headerImport, StringRef definingModuleInterface,
418+ bool isFramework, bool isStatic, StringRef moduleCacheKey,
419+ StringRef userModuleVersion)
412420 : ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftBinary,
413421 moduleImports, optionalModuleImports,
414422 linkLibraries, moduleCacheKey),
415423 compiledModulePath (compiledModulePath), moduleDocPath(moduleDocPath),
416424 sourceInfoPath(sourceInfoPath), headerImport(headerImport),
417425 definingModuleInterfacePath(definingModuleInterface),
426+ serializedSearchPaths(serializedSearchPaths),
418427 isFramework(isFramework), isStatic(isStatic),
419428 userModuleVersion(userModuleVersion) {}
420429
@@ -441,6 +450,9 @@ class SwiftBinaryModuleDependencyStorage
441450 // / Source files on which the header inputs depend.
442451 std::vector<std::string> headerSourceFiles;
443452
453+ // / Search paths this module was built with which got serialized
454+ std::vector<serialization::SearchPath> serializedSearchPaths;
455+
444456 // / (Clang) modules on which the header inputs depend.
445457 std::vector<ModuleDependencyID> headerModuleDependencies;
446458
@@ -613,15 +625,17 @@ class ModuleDependencyInfo {
613625 StringRef sourceInfoPath,
614626 ArrayRef<ScannerImportStatementInfo> moduleImports,
615627 ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
616- ArrayRef<LinkLibrary> linkLibraries, StringRef headerImport,
617- StringRef definingModuleInterface, bool isFramework,
618- bool isStatic, StringRef moduleCacheKey, StringRef userModuleVer) {
628+ ArrayRef<LinkLibrary> linkLibraries,
629+ ArrayRef<serialization::SearchPath> serializedSearchPaths,
630+ StringRef headerImport, StringRef definingModuleInterface,
631+ bool isFramework, bool isStatic, StringRef moduleCacheKey,
632+ StringRef userModuleVer) {
619633 return ModuleDependencyInfo (
620634 std::make_unique<SwiftBinaryModuleDependencyStorage>(
621635 compiledModulePath, moduleDocPath, sourceInfoPath, moduleImports,
622- optionalModuleImports, linkLibraries, headerImport ,
623- definingModuleInterface,isFramework, isStatic, moduleCacheKey ,
624- userModuleVer));
636+ optionalModuleImports, linkLibraries, serializedSearchPaths ,
637+ headerImport, definingModuleInterface,isFramework, isStatic,
638+ moduleCacheKey, userModuleVer));
625639 }
626640
627641 // / Describe the main Swift module.
@@ -933,6 +947,7 @@ class ModuleDependencyInfo {
933947 // / Add a dependency on the given module, if it was not already in the set.
934948 void
935949 addOptionalModuleImport (StringRef module , bool isExported,
950+ AccessLevel accessLevel,
936951 llvm::StringSet<> *alreadyAddedModules = nullptr );
937952
938953 // / Add all of the module imports in the given source
@@ -943,12 +958,14 @@ class ModuleDependencyInfo {
943958
944959 // / Add a dependency on the given module, if it was not already in the set.
945960 void addModuleImport (ImportPath::Module module , bool isExported,
961+ AccessLevel accessLevel,
946962 llvm::StringSet<> *alreadyAddedModules = nullptr ,
947963 const SourceManager *sourceManager = nullptr ,
948964 SourceLoc sourceLocation = SourceLoc());
949965
950966 // / Add a dependency on the given module, if it was not already in the set.
951967 void addModuleImport (StringRef module , bool isExported,
968+ AccessLevel accessLevel,
952969 llvm::StringSet<> *alreadyAddedModules = nullptr ,
953970 const SourceManager *sourceManager = nullptr ,
954971 SourceLoc sourceLocation = SourceLoc());
0 commit comments