[PATCH] D92381: [clangd] Extract per-dir CDB cache to its own threadsafe class. NFC

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 9 08:39:54 PST 2020


sammccall marked 2 inline comments as done.
sammccall added inline comments.


================
Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:79
+  // Absolute canonical path that we're the cache for. (Not case-folded).
+  std::string Path;
+
----------------
kadircet wrote:
> nit: mark it const ?
Yeah, Done. I don't usually like const on members but all the other state is so complicated here and we definitely aren't movable and don't want to be.


================
Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:128
+
+    load();
+    CachePopulated = true;
----------------
kadircet wrote:
> nit: maybe stash modification of control signals to `load()` rather than having them split between `load()` and `get()` (or alternatively just change the `load` to return a `{shared,unique}_ptr` while making it a free function and then perform all the signal modifications inside `get`)
Moved them all into `get` to isolate the complexity somewhat. We can in fact infer NeedsBroadcast from the old/new CDB pointer.

Unfortunately making `load` a free function falls apart in the next patch as `load` gets complicated:
 - it needs to own the state of "which cached file corresponds to the current CDB" as well as the CDB itself
 - it needs to access and update the file cache state itself
 - it has a one-off query of the CachePopulated flag to avoid reloading plugin-based CDBs
It's of course *possible* to make it a free function but the signature is such a mess that I don't think it buys anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92381



More information about the cfe-commits mailing list