[all-commits] [llvm/llvm-project] 917aca: FileManager: Shrink FileEntryRef to the size of a ...

Duncan P. N. Exon Smith via All-commits all-commits at lists.llvm.org
Tue Oct 27 11:56:15 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 917acac960d40280ea02ea453e594034b1be1f6b
      https://github.com/llvm/llvm-project/commit/917acac960d40280ea02ea453e594034b1be1f6b
  Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
  Date:   2020-10-27 (Tue, 27 Oct 2020)

  Changed paths:
    M clang/include/clang/Basic/FileManager.h
    M clang/lib/Basic/FileManager.cpp
    M clang/lib/Basic/SourceManager.cpp
    M clang/unittests/Basic/FileManagerTest.cpp

  Log Message:
  -----------
  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




More information about the All-commits mailing list