aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ModuleDependencyCollector.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2023-01-13 18:38:09 -0800
committerJan Svoboda <jan_svoboda@apple.com>2023-01-13 18:38:11 -0800
commit347028a4d8da8aa1ae311c95424999fcd31d98cb (patch)
tree3bddb8245710e950da11c55126ff6c9ef2152bce /clang/lib/Frontend/ModuleDependencyCollector.cpp
parent277a9f6e5f85bfa1c58ca21c26a5a74326f002ff (diff)
downloadllvm-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/ModuleDependencyCollector.cpp')
-rw-r--r--clang/lib/Frontend/ModuleDependencyCollector.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index 99a2875d..b4b312b 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -26,13 +26,19 @@ namespace {
/// Private implementations for ModuleDependencyCollector
class ModuleDependencyListener : public ASTReaderListener {
ModuleDependencyCollector &Collector;
+ FileManager &FileMgr;
public:
- ModuleDependencyListener(ModuleDependencyCollector &Collector)
- : Collector(Collector) {}
+ ModuleDependencyListener(ModuleDependencyCollector &Collector,
+ FileManager &FileMgr)
+ : Collector(Collector), FileMgr(FileMgr) {}
bool needsInputFileVisitation() override { return true; }
bool needsSystemInputFileVisitation() override { return true; }
bool visitInputFile(StringRef Filename, bool IsSystem, bool IsOverridden,
bool IsExplicitModule) override {
+ // 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();
Collector.addFile(Filename);
return true;
}
@@ -99,7 +105,8 @@ struct ModuleDependencyMMCallbacks : public ModuleMapCallbacks {
}
void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
- R.addListener(std::make_unique<ModuleDependencyListener>(*this));
+ R.addListener(
+ std::make_unique<ModuleDependencyListener>(*this, R.getFileManager()));
}
void ModuleDependencyCollector::attachToPreprocessor(Preprocessor &PP) {