diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2023-01-13 18:38:09 -0800 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2023-01-13 18:38:11 -0800 |
commit | 347028a4d8da8aa1ae311c95424999fcd31d98cb (patch) | |
tree | 3bddb8245710e950da11c55126ff6c9ef2152bce /clang/lib/Frontend/DependencyFile.cpp | |
parent | 277a9f6e5f85bfa1c58ca21c26a5a74326f002ff (diff) | |
download | llvm-347028a4d8da8aa1ae311c95424999fcd31d98cb.zip llvm-347028a4d8da8aa1ae311c95424999fcd31d98cb.tar.gz llvm-347028a4d8da8aa1ae311c95424999fcd31d98cb.tar.bz2 |
[clang] Report the on-disk paths for inputs to module compiles
Since D135636, PCM files contain the "as requested" path of input files. The machinery for generating dependency files reports those paths as they appeared in the PCM file, which may confuse consumers that are not aware of VFS overlays that might've been in place at compile-time.
This patch makes sure the "use-external-name" setting is being respected when generating dependency files in modular builds by piping the paths serialized in PCMs through `FileEntryRef::getName()` before putting them into dependency files.
rdar://103459532
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D141644
Diffstat (limited to 'clang/lib/Frontend/DependencyFile.cpp')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index 6a0a718..e19ccdf 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -108,7 +108,9 @@ struct DepCollectorMMCallbacks : public ModuleMapCallbacks { struct DepCollectorASTListener : public ASTReaderListener { DependencyCollector &DepCollector; - DepCollectorASTListener(DependencyCollector &L) : DepCollector(L) { } + FileManager &FileMgr; + DepCollectorASTListener(DependencyCollector &L, FileManager &FileMgr) + : DepCollector(L), FileMgr(FileMgr) {} bool needsInputFileVisitation() override { return true; } bool needsSystemInputFileVisitation() override { return DepCollector.needSystemDependencies(); @@ -124,6 +126,11 @@ struct DepCollectorASTListener : public ASTReaderListener { if (IsOverridden || IsExplicitModule) return true; + // Run this through the FileManager in order to respect 'use-external-name' + // in case we have a VFS overlay. + if (auto FE = FileMgr.getOptionalFileRef(Filename)) + Filename = FE->getName(); + DepCollector.maybeAddDependency(Filename, /*FromModule*/true, IsSystem, /*IsModuleFile*/false, /*IsMissing*/false); return true; @@ -176,7 +183,8 @@ void DependencyCollector::attachToPreprocessor(Preprocessor &PP) { std::make_unique<DepCollectorMMCallbacks>(*this)); } void DependencyCollector::attachToASTReader(ASTReader &R) { - R.addListener(std::make_unique<DepCollectorASTListener>(*this)); + R.addListener( + std::make_unique<DepCollectorASTListener>(*this, R.getFileManager())); } DependencyFileGenerator::DependencyFileGenerator( |