[clang] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage (PR #128267)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 21 17:55:13 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Hiroshi Yamauchi (hjyamauchi)
<details>
<summary>Changes</summary>
This is to avoid assertion failures like the following when RedirectingFileSystem's are created and used outside createVFSFromOverlayFiles.
```
Assertion failed: VFSUsage.size() == getHeaderSearchOpts().VFSOverlayFiles.size() && "A different number of RedirectingFileSystem's were present than " "-ivfsoverlay options passed to Clang!", file S:\SourceCache\llvm-project\clang\lib\Lex\HeaderSearch.cpp, line 162
```
---
Full diff: https://github.com/llvm/llvm-project/pull/128267.diff
1 Files Affected:
- (modified) clang/lib/Lex/HeaderSearch.cpp (+8-3)
``````````diff
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index bf8fe44e4ca9c..f1e011627d499 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -149,11 +149,16 @@ std::vector<bool> HeaderSearch::collectVFSUsageAndClear() const {
llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
// TODO: This only works if the `RedirectingFileSystem`s were all created by
- // `createVFSFromOverlayFiles`.
+ // `createVFSFromOverlayFiles`. But at least exclude the ones with null
+ // OverlayFileDir.
RootFS.visit([&](llvm::vfs::FileSystem &FS) {
if (auto *RFS = dyn_cast<llvm::vfs::RedirectingFileSystem>(&FS)) {
- VFSUsage.push_back(RFS->hasBeenUsed());
- RFS->clearHasBeenUsed();
+ // Skip a `RedirectingFileSystem` with null OverlayFileDir which indicates
+ // that they aren't created by `createVFSFromOverlayFiles`.
+ if (!RFS->getOverlayFileDir().empty()) {
+ VFSUsage.push_back(RFS->hasBeenUsed());
+ RFS->clearHasBeenUsed();
+ }
}
});
assert(VFSUsage.size() == getHeaderSearchOpts().VFSOverlayFiles.size() &&
``````````
</details>
https://github.com/llvm/llvm-project/pull/128267
More information about the cfe-commits
mailing list