[all-commits] [llvm/llvm-project] bdc3ce: [clang] Make `FileEntryRef::getDir()` return the a...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Thu May 25 12:37:21 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bdc3ce9e8f8dda42ed286f72094fbbdf0347cbfa
      https://github.com/llvm/llvm-project/commit/bdc3ce9e8f8dda42ed286f72094fbbdf0347cbfa
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2023-05-25 (Thu, 25 May 2023)

  Changed paths:
    M clang/include/clang/Basic/FileEntry.h
    M clang/lib/Basic/FileManager.cpp
    A clang/test/Modules/vfs-umbrella-same-dir.m
    M clang/unittests/Basic/FileEntryTest.cpp
    M clang/unittests/Basic/FileManagerTest.cpp

  Log Message:
  -----------
  [clang] Make `FileEntryRef::getDir()` return the as-requested `DirectoryEntryRef`

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, 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.

Reviewed By: benlangmuir, rmaz

Differential Revision: https://reviews.llvm.org/D151398




More information about the All-commits mailing list