[clangd] Add hot-reload of compile_commands.json and compile_flags.txt
authorSam McCall <sam.mccall@gmail.com>
Fri, 4 Dec 2020 08:09:03 +0000 (09:09 +0100)
committerSam McCall <sam.mccall@gmail.com>
Fri, 18 Dec 2020 10:16:46 +0000 (11:16 +0100)
commit98993193e9037345ad13720a62974064a5f3d953
tree943f09b6b9ecab587e0d6497145115ca0b0cc767
parenta89d751fb401540c89189e7c17ff64a6eca98587
[clangd] Add hot-reload of compile_commands.json and compile_flags.txt

When querying the CDB, we stat the underlying file to check it hasn't changed.
We don't do this every time, but only if we didn't check within 5 seconds.

This behavior only exists for compile_commands.json and compile_flags.txt.
The CDB plugin system doesn't expose enough information to handle others.

Slight behavior change: we now only look for `build/compile_commands.json`
rather than trying every CDB strategy under `build` subdirectories.

Differential Revision: https://reviews.llvm.org/D92663
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.h
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp