[ScanDependency] Add -experimental-clang-importer-direct-cc1-scan

Add an experimental option to tell dependency scanner to report clang
cc1 args should be used to construct clang importer in all constructed
swift-frontend tasks.
This commit is contained in:
Steven Wu
2024-02-23 12:15:57 -08:00
parent fb3c268abc
commit cb17ea8e66
7 changed files with 50 additions and 3 deletions

View File

@@ -347,6 +347,8 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(
std::string rootID;
std::vector<std::string> buildArgs;
auto clangImporter =
static_cast<ClangImporter *>(ScanASTContext.getClangModuleLoader());
if (tracker) {
tracker->startTracking();
for (auto fileUnit : mainModule->getFiles()) {
@@ -359,8 +361,6 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(
ScanCompilerInvocation.getSearchPathOptions());
// Fetch some dependency files from clang importer.
std::vector<std::string> clangDependencyFiles;
auto clangImporter =
static_cast<ClangImporter *>(ScanASTContext.getClangModuleLoader());
clangImporter->addClangInvovcationDependencies(clangDependencyFiles);
llvm::for_each(clangDependencyFiles,
[&](std::string &file) { tracker->trackFile(file); });
@@ -372,7 +372,9 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(
return std::make_error_code(std::errc::io_error);
}
rootID = root->getID().toString();
}
if (ScanASTContext.ClangImporterOpts.ClangImporterDirectCC1Scan) {
buildArgs.push_back("-direct-clang-cc1-module-build");
for (auto &arg : clangImporter->getSwiftExplicitModuleDirectCC1Args()) {
buildArgs.push_back("-Xcc");