This is an archive of the discontinued LLVM Phabricator instance.

FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef
ClosedPublic

Authored by dexonsmith on Oct 30 2020, 10:50 AM.

Details

Summary

Add FileEntryRef::getDir, which returns a DirectoryEntryRef. This
includes a few changes:

  • Customize OptionalStorage so that Optional<DirectoryEntryRef> is pointer-sized (like the change made to Optional<FileEntryRef>). Factored out a common class, FileMgr::MapEntryOptionalStorage, to reduce the code duplication.
  • Store an Optional<DirectoryEntryRef> in FileEntryRef::MapValue. This is set if and only if MapValue has a real FileEntry.
  • Change FileManager::getFileRef and getVirtualFileRef to use getDirectoryRef and store it in the StringMap for FileEntryRef.

Diff Detail

Event Timeline

dexonsmith created this revision.Oct 30 2020, 10:50 AM
dexonsmith requested review of this revision.Oct 30 2020, 10:50 AM
jansvoboda11 accepted this revision.Nov 30 2020, 8:58 AM

Left tiny question inline, but LGTM anyways.

clang/unittests/Basic/FileEntryTest.cpp
95

Dead variable, do we need it?

This revision is now accepted and ready to land.Nov 30 2020, 8:58 AM
dexonsmith added inline comments.
clang/unittests/Basic/FileEntryTest.cpp
95

Thanks, nice catch, that looks vestigial. I'll delete that line in a follow-up.

Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2020, 2:51 PM

Thanks again for the review, landed in 1b042de5b29af4869a77ecbc632029fba0313dec.

clang/unittests/Basic/FileEntryTest.cpp
95

Deleted this stray line in 94f537c6b2bb55c8e058a9989d02ab0d68a0c61a; turns out it was originally a copy/paste bug from ac49500cd0484e1b2dcf37fa4c0dade6f113c2c9.