diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2024-01-24 17:41:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 08:41:14 -0800 |
commit | 6c1dbd5359c4336d03b11faeaea8459b421f2c5c (patch) | |
tree | 8fd263dfe71430a2438196751fb3bcf0ec8305d9 /clang/lib/Basic/FileManager.cpp | |
parent | 56444d5687818938a6ce798e7221aa920c54098e (diff) | |
download | llvm-6c1dbd5359c4336d03b11faeaea8459b421f2c5c.zip llvm-6c1dbd5359c4336d03b11faeaea8459b421f2c5c.tar.gz llvm-6c1dbd5359c4336d03b11faeaea8459b421f2c5c.tar.bz2 |
[clang] NFC: Remove `{File,Directory}Entry::getName()` (#74910)
The files and directories that Clang accesses are uniqued by their
inode. For each inode `FileManager` will create exactly one `FileEntry`
or `DirectoryEntry` object, which makes answering the question _"Are
these two files/directories the same?"_ a simple pointer equality check.
However, since the same inode can be accessed through multiple different
paths, asking the `FileEntry` or `DirectoryEntry` object _"What is your
name?"_ doesn't have clear semantics. In c0ff9908 we started reporting
the most recent name used to access the entry, which turned out to be
necessary for Clang modules. However, the long-term solution has always
been to explicitly track the as-requested name. This has been
implemented in 4dc5573a as `FileEntryRef` and `DirectoryEntryRef`.
The `DirectoryEntry::getName()` interface has been deprecated since the
Clang 17 release and `FileEntry::getName()` since Clang 18. We have
replaced uses of these deprecated APIs in `main` with
`DirectoryEntryRef::getName()` and `FileEntryRef::getName()`
respectively.
This makes it possible to remove `{File,Directory}Entry::getName()` for
good along with the `FileManager` code that implements them.
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 974c8c2..4e77b17 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 (&DirInfo.getDirEntry() != UFE->Dir && Status.IsVFSMapped) - UFE->Dir = &DirInfo.getDirEntry(); - - // 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 = &DirInfo.getDirEntry(); @@ -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 = &DirInfo->getDirEntry(); @@ -490,7 +465,6 @@ OptionalFileEntryRef FileManager::getBypassFile(FileEntryRef VF) { FileEntry *BFE = new (FilesAlloc.Allocate()) FileEntry(); BypassFileEntries.push_back(BFE); Insertion.first->second = FileEntryRef::MapValue(*BFE, VF.getDir()); - BFE->LastRef = FileEntryRef(*Insertion.first); BFE->Size = Status.getSize(); BFE->Dir = VF.getFileEntry().Dir; BFE->ModTime = llvm::sys::toTimeT(Status.getLastModificationTime()); |