This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Move caching of compile args out of ClangdServer.
ClosedPublic

Authored by ilya-biryukov on Jun 12 2018, 3:07 AM.

Details

Summary

Caching is now handled by ClangdLSPServer and hidden behind the
GlobalCompilationDatabase interface. This simplifies ClangdServer.
This change also removes the SkipCache flag from addDocument,
which is now obsolete.

No behavioral changes are intended, the clangd binary still caches the
compile commands on the first read.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Jun 12 2018, 3:07 AM
ilya-biryukov edited the summary of this revision. (Show Details)Jun 12 2018, 3:10 AM

After looking at it more closely, it seems caching happens in the underlying compilation databases anyway. So I guess we don't even need the CachingCompilationDatabase.
I'll remove it.

  • Remove CachingCompilationDb
  • Revert "Remove CachingCompilationDb". Turns out we do need it internally (Thanks, Sam!) :-)
sammccall accepted this revision.Jun 12 2018, 10:35 AM
sammccall added inline comments.
clangd/GlobalCompilationDatabase.cpp
137

return try_emplace(File, std::move(Command)).second?

(This has different behavior if the cache was filled while you unlocked, but it's arguably the right behavior and doesn't really matter).

clangd/GlobalCompilationDatabase.h
93

const ref

This revision is now accepted and ready to land.Jun 12 2018, 10:35 AM
ilya-biryukov marked 2 inline comments as done.
  • Address review comments
clangd/GlobalCompilationDatabase.cpp
137

Thanks, good catch! We'd rather return the cached value rather than the computed one.

This revision was automatically updated to reflect the committed changes.
clangd/ClangdServer.cpp