Skip to content

Commit c23ba6d

Browse files
committed
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 ```
1 parent 5f8da7e commit c23ba6d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,16 @@ std::vector<bool> HeaderSearch::collectVFSUsageAndClear() const {
149149

150150
llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
151151
// TODO: This only works if the `RedirectingFileSystem`s were all created by
152-
// `createVFSFromOverlayFiles`.
152+
// `createVFSFromOverlayFiles`. But at least exclude the ones with null
153+
// OverlayFileDir.
153154
RootFS.visit([&](llvm::vfs::FileSystem &FS) {
154155
if (auto *RFS = dyn_cast<llvm::vfs::RedirectingFileSystem>(&FS)) {
155-
VFSUsage.push_back(RFS->hasBeenUsed());
156-
RFS->clearHasBeenUsed();
156+
// Skip a `RedirectingFileSystem` with null OverlayFileDir which indicates
157+
// that they aren't created by `createVFSFromOverlayFiles`.
158+
if (!RFS->getOverlayFileDir().empty()) {
159+
VFSUsage.push_back(RFS->hasBeenUsed());
160+
RFS->clearHasBeenUsed();
161+
}
157162
}
158163
});
159164
assert(VFSUsage.size() == getHeaderSearchOpts().VFSOverlayFiles.size() &&

0 commit comments

Comments
 (0)