https://github.com/hjyamauchi created https://github.com/llvm/llvm-project/pull/128267
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 ``` >From c23ba6d0195f727955e7f777ebb339124719104e Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi <hjyamau...@gmail.com> Date: Fri, 21 Feb 2025 17:43:30 -0800 Subject: [PATCH] Exclude RedirectingFileSystem with null OverlayFileDir in VFSUsage 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 ``` --- clang/lib/Lex/HeaderSearch.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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() && _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits