[clangd] Make in-memory CDB always available as an overlay, refactor.
authorSam McCall <sam.mccall@gmail.com>
Fri, 2 Nov 2018 13:09:36 +0000 (13:09 +0000)
committerSam McCall <sam.mccall@gmail.com>
Fri, 2 Nov 2018 13:09:36 +0000 (13:09 +0000)
commitc55d09a00e8067f27de2bb88c12a2bee64a2192a
tree484eb2a0f993d2ac16b00c4863397f90b3e11f8a
parent2eb6b4038a2a66a413efce8892d4c82ca6762e13
[clangd] Make in-memory CDB always available as an overlay, refactor.

Summary:
The new implementation is a GlobalCompilationDatabase that overlays a base.
Normally this is the directory-based CDB.
To preserve the behavior of compile_args_from=LSP, the base may be null.

The OverlayCDB is always present, and so the extensions to populate it
are always supported.

It also allows overriding the flags of the fallback command. This is
just unit-tested for now, but the plan is to expose this as an extension
on the initialize message. This addresses use cases like
https://github.com/thomasjo/atom-ide-cpp/issues/16

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D53687

llvm-svn: 345970
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp