[clang] [llvm] [clang] NFC: Remove `{File, Directory}Entry::getName()` (PR #74910)
https://github.com/jansvoboda11 closed https://github.com/llvm/llvm-project/pull/74910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] NFC: Remove `{File, Directory}Entry::getName()` (PR #74910)
https://github.com/benlangmuir approved this pull request. https://github.com/llvm/llvm-project/pull/74910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] NFC: Remove `{File, Directory}Entry::getName()` (PR #74910)
https://github.com/dexonsmith approved this pull request. Amazing! LGTM, once the branch is clear. https://github.com/llvm/llvm-project/pull/74910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] NFC: Remove `{File, Directory}Entry::getName()` (PR #74910)
jansvoboda11 wrote: Note: I'd like to merge this PR after we branch off for Clang 18 in January or February 2024. I had the patch lying around, so I figured I might as well create the PR. https://github.com/llvm/llvm-project/pull/74910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] NFC: Remove `{File, Directory}Entry::getName()` (PR #74910)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Jan Svoboda (jansvoboda11) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/74910.diff 7 Files Affected: - (modified) clang/include/clang/Basic/DirectoryEntry.h (-7) - (modified) clang/include/clang/Basic/FileEntry.h (-10) - (modified) clang/lib/Basic/FileManager.cpp (-26) - (modified) clang/unittests/Basic/FileManagerTest.cpp (-6) - (modified) llvm/include/llvm/Support/VirtualFileSystem.h (-3) - (modified) llvm/lib/Support/VirtualFileSystem.cpp (-1) - (modified) llvm/unittests/Support/VirtualFileSystemTest.cpp (-18) ``diff diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h index 906c2e9af23b31..35fe529ba79dff 100644 --- a/clang/include/clang/Basic/DirectoryEntry.h +++ b/clang/include/clang/Basic/DirectoryEntry.h @@ -41,13 +41,6 @@ class DirectoryEntry { DirectoryEntry =(const DirectoryEntry &) = delete; friend class FileManager; friend class FileEntryTestHelper; - - // FIXME: We should not be storing a directory entry name here. - StringRef Name; // Name of the directory. - -public: - LLVM_DEPRECATED("Use DirectoryEntryRef::getName() instead.", "") - StringRef getName() const { return Name; } }; /// A reference to a \c DirectoryEntry that includes the name of the directory diff --git a/clang/include/clang/Basic/FileEntry.h b/clang/include/clang/Basic/FileEntry.h index 35efa147950f06..68d4bf60930037 100644 --- a/clang/include/clang/Basic/FileEntry.h +++ b/clang/include/clang/Basic/FileEntry.h @@ -318,18 +318,8 @@ class FileEntry { /// The file content, if it is owned by the \p FileEntry. std::unique_ptr Content; - // First access name for this FileEntry. - // - // This is Optional only to allow delayed construction (FileEntryRef has no - // default constructor). It should always have a value in practice. - // - // TODO: remove this once everyone that needs a name uses FileEntryRef. - OptionalFileEntryRef LastRef; - public: ~FileEntry(); - LLVM_DEPRECATED("Use FileEntryRef::getName() instead.", "") - StringRef getName() const { return LastRef->getName(); } StringRef tryGetRealPathName() const { return RealPathName; } off_t getSize() const { return Size; } diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index d16626b1065213..e715e69f7bdbb0 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -107,7 +107,6 @@ void FileManager::addAncestorsAsVirtualDirs(StringRef Path) { // Add the virtual directory to the cache. auto *UDE = new (DirsAlloc.Allocate()) DirectoryEntry(); - UDE->Name = NamedDirEnt.first(); NamedDirEnt.second = *UDE; VirtualDirectoryEntries.push_back(UDE); @@ -179,7 +178,6 @@ FileManager::getDirectoryRef(StringRef DirName, bool CacheFailure) { // We don't have this directory yet, add it. We use the string // key from the SeenDirEntries map as the string. UDE = new (DirsAlloc.Allocate()) DirectoryEntry(); -UDE->Name = InterndDirName; } NamedDirEnt.second = *UDE; @@ -324,32 +322,10 @@ FileManager::getFileRef(StringRef Filename, bool openFile, bool CacheFailure) { FileEntryRef ReturnedRef(*NamedFileEnt); if (ReusingEntry) { // Already have an entry with this inode, return it. - -// FIXME: This hack ensures that `getDir()` will use the path that was -// used to lookup this file, even if we found a file by different path -// first. This is required in order to find a module's structure when its -// headers/module map are mapped in the VFS. -// -// See above for how this will eventually be removed. `IsVFSMapped` -// *cannot* be narrowed to `ExposesExternalVFSPath` as crash reproducers -// also depend on this logic and they have `use-external-paths: false`. -if (() != UFE->Dir && Status.IsVFSMapped) - UFE->Dir = (); - -// Always update LastRef to the last name by which a file was accessed. -// FIXME: Neither this nor always using the first reference is correct; we -// want to switch towards a design where we return a FileName object that -// encapsulates both the name by which the file was accessed and the -// corresponding FileEntry. -// FIXME: LastRef should be removed from FileEntry once all clients adopt -// FileEntryRef. -UFE->LastRef = ReturnedRef; - return ReturnedRef; } // Otherwise, we don't have this file yet, add it. - UFE->LastRef = ReturnedRef; UFE->Size = Status.getSize(); UFE->ModTime = llvm::sys::toTimeT(Status.getLastModificationTime()); UFE->Dir = (); @@ -461,7 +437,6 @@ FileEntryRef FileManager::getVirtualFileRef(StringRef Filename, off_t Size, } NamedFileEnt.second = FileEntryRef::MapValue(*UFE, *DirInfo); - UFE->LastRef = FileEntryRef(NamedFileEnt); UFE->Size= Size; UFE->ModTime = ModificationTime; UFE->Dir = >getDirEntry(); @@ -490,7 +465,6 @@
[clang] [llvm] [clang] NFC: Remove `{File, Directory}Entry::getName()` (PR #74910)
https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/74910 None >From f1a4ff8dc30b755e95fcd4871eb59b0d49f86c7b Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Thu, 7 Dec 2023 09:29:14 -0800 Subject: [PATCH] [clang] NFC: Remove `{File,Directory}Entry::getName()` --- clang/include/clang/Basic/DirectoryEntry.h| 7 - clang/include/clang/Basic/FileEntry.h | 10 --- clang/lib/Basic/FileManager.cpp | 26 --- clang/unittests/Basic/FileManagerTest.cpp | 6 - llvm/include/llvm/Support/VirtualFileSystem.h | 3 --- llvm/lib/Support/VirtualFileSystem.cpp| 1 - .../Support/VirtualFileSystemTest.cpp | 18 - 7 files changed, 71 deletions(-) diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h index 906c2e9af23b3..35fe529ba79df 100644 --- a/clang/include/clang/Basic/DirectoryEntry.h +++ b/clang/include/clang/Basic/DirectoryEntry.h @@ -41,13 +41,6 @@ class DirectoryEntry { DirectoryEntry =(const DirectoryEntry &) = delete; friend class FileManager; friend class FileEntryTestHelper; - - // FIXME: We should not be storing a directory entry name here. - StringRef Name; // Name of the directory. - -public: - LLVM_DEPRECATED("Use DirectoryEntryRef::getName() instead.", "") - StringRef getName() const { return Name; } }; /// A reference to a \c DirectoryEntry that includes the name of the directory diff --git a/clang/include/clang/Basic/FileEntry.h b/clang/include/clang/Basic/FileEntry.h index 35efa147950f0..68d4bf6093003 100644 --- a/clang/include/clang/Basic/FileEntry.h +++ b/clang/include/clang/Basic/FileEntry.h @@ -318,18 +318,8 @@ class FileEntry { /// The file content, if it is owned by the \p FileEntry. std::unique_ptr Content; - // First access name for this FileEntry. - // - // This is Optional only to allow delayed construction (FileEntryRef has no - // default constructor). It should always have a value in practice. - // - // TODO: remove this once everyone that needs a name uses FileEntryRef. - OptionalFileEntryRef LastRef; - public: ~FileEntry(); - LLVM_DEPRECATED("Use FileEntryRef::getName() instead.", "") - StringRef getName() const { return LastRef->getName(); } StringRef tryGetRealPathName() const { return RealPathName; } off_t getSize() const { return Size; } diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index d16626b106521..e715e69f7bdbb 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -107,7 +107,6 @@ void FileManager::addAncestorsAsVirtualDirs(StringRef Path) { // Add the virtual directory to the cache. auto *UDE = new (DirsAlloc.Allocate()) DirectoryEntry(); - UDE->Name = NamedDirEnt.first(); NamedDirEnt.second = *UDE; VirtualDirectoryEntries.push_back(UDE); @@ -179,7 +178,6 @@ FileManager::getDirectoryRef(StringRef DirName, bool CacheFailure) { // We don't have this directory yet, add it. We use the string // key from the SeenDirEntries map as the string. UDE = new (DirsAlloc.Allocate()) DirectoryEntry(); -UDE->Name = InterndDirName; } NamedDirEnt.second = *UDE; @@ -324,32 +322,10 @@ FileManager::getFileRef(StringRef Filename, bool openFile, bool CacheFailure) { FileEntryRef ReturnedRef(*NamedFileEnt); if (ReusingEntry) { // Already have an entry with this inode, return it. - -// FIXME: This hack ensures that `getDir()` will use the path that was -// used to lookup this file, even if we found a file by different path -// first. This is required in order to find a module's structure when its -// headers/module map are mapped in the VFS. -// -// See above for how this will eventually be removed. `IsVFSMapped` -// *cannot* be narrowed to `ExposesExternalVFSPath` as crash reproducers -// also depend on this logic and they have `use-external-paths: false`. -if (() != UFE->Dir && Status.IsVFSMapped) - UFE->Dir = (); - -// Always update LastRef to the last name by which a file was accessed. -// FIXME: Neither this nor always using the first reference is correct; we -// want to switch towards a design where we return a FileName object that -// encapsulates both the name by which the file was accessed and the -// corresponding FileEntry. -// FIXME: LastRef should be removed from FileEntry once all clients adopt -// FileEntryRef. -UFE->LastRef = ReturnedRef; - return ReturnedRef; } // Otherwise, we don't have this file yet, add it. - UFE->LastRef = ReturnedRef; UFE->Size = Status.getSize(); UFE->ModTime = llvm::sys::toTimeT(Status.getLastModificationTime()); UFE->Dir = (); @@ -461,7 +437,6 @@ FileEntryRef FileManager::getVirtualFileRef(StringRef Filename, off_t Size, } NamedFileEnt.second = FileEntryRef::MapValue(*UFE, *DirInfo); - UFE->LastRef =