summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/tool/ClangdMain.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2018-08-01 17:39:29 +0000
committerAlex Lorenz <arphaman@gmail.com>2018-08-01 17:39:29 +0000
commitf808786a6543b7a00e3b51da5b27ce57fce0db6f (patch)
tree1b040d6330e0d24b4c23f21e5c7f22d44c4a9827 /clang-tools-extra/clangd/tool/ClangdMain.cpp
parentf6d1923c8640c7931c51a7b8254663c23835924e (diff)
downloadbcm5719-llvm-f808786a6543b7a00e3b51da5b27ce57fce0db6f.tar.gz
bcm5719-llvm-f808786a6543b7a00e3b51da5b27ce57fce0db6f.zip
[clangd] allow clients to control the compilation database by passing in
compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request This commit allows clangd to use an in-memory compilation database that's controlled from the LSP client (-compile_args_from=lsp). It extends the 'workspace/didChangeConfiguration' request to allow the client to pass in a compilation database subset that needs to be updated in the workspace. Differential Revision: https://reviews.llvm.org/D49758 llvm-svn: 338597
Diffstat (limited to 'clang-tools-extra/clangd/tool/ClangdMain.cpp')
-rw-r--r--clang-tools-extra/clangd/tool/ClangdMain.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 95ffdfad52e..9e161f5e850 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -173,6 +173,18 @@ static llvm::cl::opt<Path> YamlSymbolFile(
"eventually. Don't rely on it."),
llvm::cl::init(""), llvm::cl::Hidden);
+enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
+
+static llvm::cl::opt<CompileArgsFrom> CompileArgsFrom(
+ "compile_args_from", llvm::cl::desc("The source of compile commands"),
+ llvm::cl::values(clEnumValN(LSPCompileArgs, "lsp",
+ "All compile commands come from LSP and "
+ "'compile_commands.json' files are ignored"),
+ clEnumValN(FilesystemCompileArgs, "filesystem",
+ "All compile commands come from the "
+ "'compile_commands.json' files")),
+ llvm::cl::init(FilesystemCompileArgs), llvm::cl::Hidden);
+
int main(int argc, char *argv[]) {
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
@@ -289,7 +301,9 @@ int main(int argc, char *argv[]) {
}
// Initialize and run ClangdLSPServer.
- ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath, Opts);
+ ClangdLSPServer LSPServer(
+ Out, CCOpts, CompileCommandsDirPath,
+ /*ShouldUseInMemoryCDB=*/CompileArgsFrom == LSPCompileArgs, Opts);
constexpr int NoShutdownRequestErrorCode = 1;
llvm::set_thread_name("clangd.main");
// Change stdin to binary to not lose \r\n on windows.
OpenPOWER on IntegriCloud