File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
include/swift/ClangImporter Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -409,6 +409,11 @@ class ClangImporter final : public ClangModuleLoader {
409
409
// / Reads the original source file name from PCH.
410
410
std::string getOriginalSourceFile (StringRef PCHFilename);
411
411
412
+ // / Add clang dependency file names.
413
+ // /
414
+ // / \param files The list of file to append dependencies to.
415
+ void addClangInvovcationDependencies (std::vector<std::string> &files);
416
+
412
417
// / Makes a temporary replica of the ClangImporter's CompilerInstance, reads a
413
418
// / module map into the replica and emits a PCM file for one of the modules it
414
419
// / declares. Delegates to clang for everything except construction of the
Original file line number Diff line number Diff line change @@ -446,6 +446,11 @@ void SwiftDependencyScanningService::setupCachingDependencyScanningService(
446
446
}
447
447
}
448
448
449
+ // Fetch some dependency files from clang importer.
450
+ auto clangImporter = static_cast <ClangImporter *>(
451
+ Instance.getASTContext ().getClangModuleLoader ());
452
+ clangImporter->addClangInvovcationDependencies (CommonDependencyFiles);
453
+
449
454
auto CachingFS =
450
455
llvm::cas::createCachingOnDiskFileSystem (Instance.getObjectStore ());
451
456
if (!CachingFS) {
Original file line number Diff line number Diff line change @@ -939,6 +939,27 @@ std::string ClangImporter::getOriginalSourceFile(StringRef PCHFilename) {
939
939
Impl.Instance ->getPCHContainerReader (), Impl.Instance ->getDiagnostics ());
940
940
}
941
941
942
+ void ClangImporter::addClangInvovcationDependencies (
943
+ std::vector<std::string> &files) {
944
+ auto addFiles = [&files](const auto &F) {
945
+ files.insert (files.end (), F.begin (), F.end ());
946
+ };
947
+ auto &invocation = *Impl.Invocation ;
948
+ // FIXME: Add file dependencies that are not accounted. The long term solution
949
+ // is to do a dependency scanning for clang importer and use that directly.
950
+ SmallVector<std::string, 4 > HeaderMapFileNames;
951
+ Impl.Instance ->getPreprocessor ().getHeaderSearchInfo ().getHeaderMapFileNames (
952
+ HeaderMapFileNames);
953
+ addFiles (HeaderMapFileNames);
954
+ addFiles (invocation.getHeaderSearchOpts ().VFSOverlayFiles );
955
+ // FIXME: Should not depend on working directory. Build system/swift driver
956
+ // should not pass working directory here but if that option is passed,
957
+ // repect that and add that into CASFS.
958
+ auto CWD = invocation.getFileSystemOpts ().WorkingDir ;
959
+ if (!CWD.empty ())
960
+ files.push_back (CWD);
961
+ }
962
+
942
963
Optional<std::string>
943
964
ClangImporter::getPCHFilename (const ClangImporterOptions &ImporterOptions,
944
965
StringRef SwiftPCHHash, bool &isExplicit) {
You can’t perform that action at this time.
0 commit comments