[PATCH] D151398: [clang] Make `FileEntryRef::getDir()` return the as-requested `DirectoryEntryRef`
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 24 19:42:42 PDT 2023
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, bnbarham, rmaz.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
For redirected file entries, `FileEntryRef::getDir()` returns the parent directory entry of the target file entry. This differs from `FileEntry::getDir()` that always returns the parent directory that was last used to look up that file.
After switching from `FileEntry` to `FileEntryRef` for umbrella headers in D142113 <https://reviews.llvm.org/D142113>, this discrepancy became observable and caused Clang to emit incorrect diagnostics.
This patch changes Clang so that it always associates `FileEntryRef` with the parent directory that was used to look it up. This brings its behavior closer to `FileEntry`, but without the hacky mutation.
This also ensures that `llvm::sys::path::parent_path(FileRef->getNameAsRequested()) == FileRef->getDir()->getName()`. Previously, `FileRef->getDir()` would fall underneath the redirecting VFS into the world of on-disk paths.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151398
Files:
clang/include/clang/Basic/FileEntry.h
clang/lib/Basic/FileManager.cpp
clang/test/Modules/vfs-umbrella-same-dir.m
clang/unittests/Basic/FileEntryTest.cpp
clang/unittests/Basic/FileManagerTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151398.525408.patch
Type: text/x-patch
Size: 5549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230525/94c14da3/attachment.bin>
More information about the cfe-commits
mailing list