FileManager: Shrink FileEntryRef to the size of a pointer
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 15 Oct 2020 15:39:07 +0000 (11:39 -0400)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 27 Oct 2020 18:55:41 +0000 (14:55 -0400)
commit917acac960d40280ea02ea453e594034b1be1f6b
tree77725736105c187559617b78904af3ede6fee5f7
parent83154c541806468802d687a8b3c8f1a65e92199c
FileManager: Shrink FileEntryRef to the size of a pointer

Shrink `FileEntryRef` to the size of a pointer, by having it directly
reference the `StringMapEntry` the same way that `DirectoryEntryRef`
does. This makes `FileEntryRef::FileEntryRef` private as a side effect
(`FileManager` is a friend!).

There are two helper types added within `FileEntryRef`:

- `FileEntryRef::MapValue` is the type stored in
  `FileManager::SeenFileEntries`. It's a replacement for
  `SeenFileEntryOrRedirect`, where the second pointer type has been
  changed from `StringRef*` to `MapEntry*` (see next bullet).
- `FileEntryRef::MapEntry` is the instantiation of `StringMapEntry<>`
  where `MapValue` is stored. This is what `FileEntryRef` has a pointer
  to, in order to grab the name in addition to the value.

Differential Revision: https://reviews.llvm.org/D89488
clang/include/clang/Basic/FileManager.h
clang/lib/Basic/FileManager.cpp
clang/lib/Basic/SourceManager.cpp
clang/unittests/Basic/FileManagerTest.cpp