summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/tool/ClangdMain.cpp
diff options
context:
space:
mode:
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