[Dependency Scanning] Specify Explicit Module output path to the scanner explicitly

Instead of the code querying the compiler's built-in Clang instance, refactor the
dependency scanner to explicitly keep track of module output path. It is still
set according to '-module-cache-path' as it has been prior to this change, but
now the scanner can use a different module cache for scanning PCMs, as specified
with '-clang-scanner-module-cache-path', without affecting module output path.

Resolves rdar://113222853
This commit is contained in:
Artem Chikin
2023-08-04 13:14:44 -07:00
parent 8501f99cb2
commit 6ef79c4ba0
12 changed files with 79 additions and 55 deletions

View File

@@ -131,9 +131,10 @@ DependencyScanningTool::getDependencies(
auto Instance = std::move(*InstanceOrErr);
// Local scan cache instance, wrapping the shared global cache.
ModuleDependenciesCache cache(*ScanningService,
Instance->getMainModule()->getNameStr().str(),
Instance->getInvocation().getModuleScanningHash());
ModuleDependenciesCache cache(
*ScanningService, Instance->getMainModule()->getNameStr().str(),
Instance->getInvocation().getFrontendOptions().ExplicitModulesOutputPath,
Instance->getInvocation().getModuleScanningHash());
// Execute the scanning action, retrieving the in-memory result
auto DependenciesOrErr = performModuleScan(*Instance.get(), cache);
if (DependenciesOrErr.getError())
@@ -173,9 +174,10 @@ DependencyScanningTool::getDependencies(
auto Instance = std::move(*InstanceOrErr);
// Local scan cache instance, wrapping the shared global cache.
ModuleDependenciesCache cache(*ScanningService,
Instance->getMainModule()->getNameStr().str(),
Instance->getInvocation().getModuleScanningHash());
ModuleDependenciesCache cache(
*ScanningService, Instance->getMainModule()->getNameStr().str(),
Instance->getInvocation().getFrontendOptions().ExplicitModulesOutputPath,
Instance->getInvocation().getModuleScanningHash());
auto BatchScanResults = performBatchModuleScan(
*Instance.get(), cache, VersionedPCMInstanceCacheCache.get(),
Saver, BatchInput);