22
22
#include " swift/AST/LinkLibrary.h"
23
23
#include " swift/Basic/CXXStdlibKind.h"
24
24
#include " swift/Basic/LLVM.h"
25
+ #include " swift/Serialization/Validation.h"
25
26
#include " clang/CAS/CASOptions.h"
26
27
#include " clang/Tooling/DependencyScanning/DependencyScanningService.h"
27
28
#include " clang/Tooling/DependencyScanning/DependencyScanningTool.h"
@@ -155,30 +156,35 @@ struct ScannerImportStatementInfo {
155
156
uint32_t columnNumber;
156
157
};
157
158
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) {}
161
163
162
164
ScannerImportStatementInfo (std::string importIdentifier, bool isExported,
165
+ AccessLevel accessLevel,
163
166
ImportDiagnosticLocationInfo location)
164
- : importLocations({location} ), importIdentifier(importIdentifier ),
165
- isExported(isExported) {}
167
+ : importIdentifier(importIdentifier ), importLocations({location} ),
168
+ isExported(isExported), accessLevel(accessLevel) {}
166
169
167
170
ScannerImportStatementInfo (std::string importIdentifier, bool isExported,
171
+ AccessLevel accessLevel,
168
172
SmallVector<ImportDiagnosticLocationInfo, 4 > locations)
169
- : importLocations(locations ), importIdentifier(importIdentifier ),
170
- isExported(isExported) {}
173
+ : importIdentifier(importIdentifier ), importLocations(locations ),
174
+ isExported(isExported), accessLevel(accessLevel) {}
171
175
172
176
void addImportLocation (ImportDiagnosticLocationInfo location) {
173
177
importLocations.push_back (location);
174
178
}
175
179
176
- // / Buffer, line & column number of the import statement
177
- SmallVector<ImportDiagnosticLocationInfo, 4 > importLocations;
178
180
// / Imported module string. e.g. "Foo.Bar" in 'import Foo.Bar'
179
181
std::string importIdentifier;
182
+ // / Buffer, line & column number of the import statement
183
+ SmallVector<ImportDiagnosticLocationInfo, 4 > importLocations;
180
184
// / Is this an @_exported import
181
185
bool isExported;
186
+ // / Access level of this dependency
187
+ AccessLevel accessLevel;
182
188
};
183
189
184
190
// / Base class for the variant storage of ModuleDependencyInfo.
@@ -406,15 +412,18 @@ class SwiftBinaryModuleDependencyStorage
406
412
StringRef sourceInfoPath,
407
413
ArrayRef<ScannerImportStatementInfo> moduleImports,
408
414
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)
412
420
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftBinary,
413
421
moduleImports, optionalModuleImports,
414
422
linkLibraries, moduleCacheKey),
415
423
compiledModulePath (compiledModulePath), moduleDocPath(moduleDocPath),
416
424
sourceInfoPath(sourceInfoPath), headerImport(headerImport),
417
425
definingModuleInterfacePath(definingModuleInterface),
426
+ serializedSearchPaths(serializedSearchPaths),
418
427
isFramework(isFramework), isStatic(isStatic),
419
428
userModuleVersion(userModuleVersion) {}
420
429
@@ -441,6 +450,9 @@ class SwiftBinaryModuleDependencyStorage
441
450
// / Source files on which the header inputs depend.
442
451
std::vector<std::string> headerSourceFiles;
443
452
453
+ // / Search paths this module was built with which got serialized
454
+ std::vector<serialization::SearchPath> serializedSearchPaths;
455
+
444
456
// / (Clang) modules on which the header inputs depend.
445
457
std::vector<ModuleDependencyID> headerModuleDependencies;
446
458
@@ -613,15 +625,17 @@ class ModuleDependencyInfo {
613
625
StringRef sourceInfoPath,
614
626
ArrayRef<ScannerImportStatementInfo> moduleImports,
615
627
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) {
619
633
return ModuleDependencyInfo (
620
634
std::make_unique<SwiftBinaryModuleDependencyStorage>(
621
635
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));
625
639
}
626
640
627
641
// / Describe the main Swift module.
@@ -933,6 +947,7 @@ class ModuleDependencyInfo {
933
947
// / Add a dependency on the given module, if it was not already in the set.
934
948
void
935
949
addOptionalModuleImport (StringRef module , bool isExported,
950
+ AccessLevel accessLevel,
936
951
llvm::StringSet<> *alreadyAddedModules = nullptr );
937
952
938
953
// / Add all of the module imports in the given source
@@ -943,12 +958,14 @@ class ModuleDependencyInfo {
943
958
944
959
// / Add a dependency on the given module, if it was not already in the set.
945
960
void addModuleImport (ImportPath::Module module , bool isExported,
961
+ AccessLevel accessLevel,
946
962
llvm::StringSet<> *alreadyAddedModules = nullptr ,
947
963
const SourceManager *sourceManager = nullptr ,
948
964
SourceLoc sourceLocation = SourceLoc());
949
965
950
966
// / Add a dependency on the given module, if it was not already in the set.
951
967
void addModuleImport (StringRef module , bool isExported,
968
+ AccessLevel accessLevel,
952
969
llvm::StringSet<> *alreadyAddedModules = nullptr ,
953
970
const SourceManager *sourceManager = nullptr ,
954
971
SourceLoc sourceLocation = SourceLoc());
0 commit comments