FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 29 Oct 2020 22:00:31 +0000 (18:00 -0400)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 30 Nov 2020 22:50:46 +0000 (14:50 -0800)
commit1b042de5b29af4869a77ecbc632029fba0313dec
tree1945db936a13b98307a63e797f302c8fce87c9fb
parent1b9f214efca7d5855f4e3dd1969c4cbe77078f97
FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

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

Differential Revision: https://reviews.llvm.org/D90484
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/lib/Basic/FileManager.cpp
clang/unittests/Basic/FileEntryTest.cpp