[PATCH] D123197: Remove a few effectively-unused FileEntry APIs. NFC

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 6 11:49:07 PDT 2022


dexonsmith added inline comments.


================
Comment at: clang/include/clang/Basic/FileEntry.h:332-334
+  FileEntry();
+  FileEntry(const FileEntry &) = delete;
+  FileEntry &operator=(const FileEntry &) = delete;
----------------
Aha, now I understand why you needed a factory in the FileEntryTest: because you made the constructor private.

Instead, can we add an initializing constructor to `FileEntry`? It'd be fine for that to be public; it seems implausible for someone to misuse it.


================
Comment at: clang/lib/Basic/FileManager.cpp:422-462
   if (!getStatValue(InterndFileName, Status, true, nullptr)) {
     Status = llvm::vfs::Status(
       Status.getName(), Status.getUniqueID(),
       llvm::sys::toTimePoint(ModificationTime),
       Status.getUser(), Status.getGroup(), Size,
       Status.getType(), Status.getPermissions());
 
----------------
This dance'll be a bit different if there's an initializing constructor, but maybe it'd be cleaner anyway:
```
lang=c++
FileEntry **Slot = nullptr;
if (!getStat...) {
  Status = ...; // and update name in Status with fillRealPathName()
  Slot = &UniqueRealFiles[Status.getUniqueID()];
  if (*Slot) return early;
} else {
  Status = ...;
  VirtualFileEntries.push_back(nullptr);
  Slot = &VirtualFileEntries.back();
}
UFE = *Slot = new (FilesAlloc.Allocate()) FileEntry(Status, Dir, NextFileUID++);
NamedFileEnt.second = FileEntryRef::MapValue(*UFE, *DirInfo);
UFE->LastRef = UFE;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123197/new/

https://reviews.llvm.org/D123197



More information about the cfe-commits mailing list