[PATCH] D137304: [clang] Store filename per include instead of mutating filename

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 2 17:34:28 PDT 2022


dexonsmith added inline comments.


================
Comment at: clang/include/clang/Basic/SourceManager.h:652-662
+  llvm::DenseMap<FileEntryRef, SrcMgr::NamedContentCache *,
+                 FileEntryRefSameRefDenseMapInfo>
+      NamedFileInfos;
+
   /// Memoized information about all of the files tracked by this
   /// SourceManager.
   ///
----------------
It feels expensive to have both of these maps. I wonder if instead we could do something like:

```
lang=c++
DenseMap<const FileEntry*, TinyPtrSet<NamedContentCache*>> FirstFileInfo;
```
I.e., lookup by `FileEntry*`, then linear search for the right `FileEntryRef`.

Similar idea: just point at `NamedContentCache*` directly here, but add `NamedContentCache *NamedContentCache::Next` to turn it into a linked list. Also lookup by `FileEntry*` and then a linear search for the right ref.

Note that `FileInfo` itself would have a direct pointer to the right thing; no need for a linear search.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137304



More information about the cfe-commits mailing list