@@ -100,7 +100,7 @@ class PrebuiltModuleListener : public ASTReaderListener {
100
100
PrebuiltModulesAttrsMap &PrebuiltModulesASTMap,
101
101
const HeaderSearchOptions &HSOpts,
102
102
const LangOptions &LangOpts, DiagnosticsEngine &Diags,
103
- const llvm::SmallVector <StringRef> & StableDirs)
103
+ const ArrayRef <StringRef> StableDirs)
104
104
: PrebuiltModuleFiles(PrebuiltModuleFiles),
105
105
NewModuleFiles (NewModuleFiles),
106
106
PrebuiltModulesASTMap(PrebuiltModulesASTMap), ExistingHSOpts(HSOpts),
@@ -199,7 +199,7 @@ class PrebuiltModuleListener : public ASTReaderListener {
199
199
const LangOptions &ExistingLangOpts;
200
200
DiagnosticsEngine &Diags;
201
201
std::string CurrentFile;
202
- const llvm::SmallVector <StringRef> & StableDirs;
202
+ const ArrayRef <StringRef> StableDirs;
203
203
};
204
204
205
205
// / Visit the given prebuilt module and collect all of the modules it
@@ -208,16 +208,8 @@ static bool visitPrebuiltModule(StringRef PrebuiltModuleFilename,
208
208
CompilerInstance &CI,
209
209
PrebuiltModuleFilesT &ModuleFiles,
210
210
PrebuiltModulesAttrsMap &PrebuiltModulesASTMap,
211
- DiagnosticsEngine &Diags) {
212
-
213
- // Gather the set of stable directories to use as transitive dependencies are
214
- // discovered.
215
- llvm::SmallVector<StringRef> StableDirs;
216
- std::string SysrootToUse (CI.getHeaderSearchOpts ().Sysroot );
217
- if (!SysrootToUse.empty () &&
218
- (llvm::sys::path::root_directory (SysrootToUse) != SysrootToUse))
219
- StableDirs = {SysrootToUse, CI.getHeaderSearchOpts ().ResourceDir };
220
-
211
+ DiagnosticsEngine &Diags,
212
+ const ArrayRef<StringRef> StableDirs) {
221
213
// List of module files to be processed.
222
214
llvm::SmallVector<std::string> Worklist;
223
215
@@ -448,6 +440,15 @@ class DependencyScanningAction : public tooling::ToolAction {
448
440
auto *FileMgr = ScanInstance.createFileManager (FS);
449
441
ScanInstance.createSourceManager (*FileMgr);
450
442
443
+ // Create a collection of stable directories derived from the ScanInstance
444
+ // for determining whether module dependencies would fully resolve from
445
+ // those directories.
446
+ llvm::SmallVector<StringRef> StableDirs;
447
+ const StringRef Sysroot = ScanInstance.getHeaderSearchOpts ().Sysroot ;
448
+ if (!Sysroot.empty () &&
449
+ (llvm::sys::path::root_directory (Sysroot) != Sysroot))
450
+ StableDirs = {Sysroot, ScanInstance.getHeaderSearchOpts ().ResourceDir };
451
+
451
452
// Store a mapping of prebuilt module files and their properties like header
452
453
// search options. This will prevent the implicit build to create duplicate
453
454
// modules and will force reuse of the existing prebuilt module files
@@ -459,7 +460,7 @@ class DependencyScanningAction : public tooling::ToolAction {
459
460
ScanInstance.getPreprocessorOpts ().ImplicitPCHInclude ,
460
461
ScanInstance,
461
462
ScanInstance.getHeaderSearchOpts ().PrebuiltModuleFiles ,
462
- PrebuiltModulesASTMap, ScanInstance.getDiagnostics ()))
463
+ PrebuiltModulesASTMap, ScanInstance.getDiagnostics (), StableDirs ))
463
464
return false ;
464
465
465
466
// Create the dependency collector that will collect the produced
@@ -489,7 +490,7 @@ class DependencyScanningAction : public tooling::ToolAction {
489
490
case ScanningOutputFormat::Full:
490
491
MDC = std::make_shared<ModuleDepCollector>(
491
492
Service, std::move (Opts), ScanInstance, Consumer, Controller,
492
- OriginalInvocation, std::move (PrebuiltModulesASTMap));
493
+ OriginalInvocation, std::move (PrebuiltModulesASTMap), StableDirs );
493
494
ScanInstance.addDependencyCollector (MDC);
494
495
break ;
495
496
}
0 commit comments