[clang-tools-extra] c6d2078 - [clangd] Improve diagnostics in dexp interface
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 00:51:33 PDT 2020
Author: Kirill Bobyrev
Date: 2020-08-11T09:50:33+02:00
New Revision: c6d2078a35d536c8fa152fa9205924f8f10cbaac
URL: https://github.com/llvm/llvm-project/commit/c6d2078a35d536c8fa152fa9205924f8f10cbaac
DIFF: https://github.com/llvm/llvm-project/commit/c6d2078a35d536c8fa152fa9205924f8f10cbaac.diff
LOG: [clangd] Improve diagnostics in dexp interface
When running dexp in remote mode without --project-root it shuts down
with an assertion. This is not the desired behaviour: instruct user on
how to run it properly when the configuration is incorrect.
Added:
Modified:
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index ca35f620bba1..7652dbb92d02 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -30,10 +30,12 @@ llvm::cl::opt<std::string> IndexLocation(
llvm::cl::Positional);
llvm::cl::opt<std::string>
- ExecCommand("c", llvm::cl::desc("Command to execute and then exit"));
+ ExecCommand("c", llvm::cl::desc("Command to execute and then exit."));
-llvm::cl::opt<std::string> ProjectRoot("project-root",
- llvm::cl::desc("Path to the project"));
+llvm::cl::opt<std::string> ProjectRoot(
+ "project-root",
+ llvm::cl::desc(
+ "Path to the project. Required when connecting using remote index."));
static constexpr char Overview[] = R"(
This is an **experimental** interactive tool to process user-provided search
@@ -373,10 +375,14 @@ int main(int argc, const char *argv[]) {
llvm::cl::ResetCommandLineParser(); // We reuse it for REPL commands.
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+ bool RemoteMode = llvm::StringRef(IndexLocation).startswith("remote:");
+ if (RemoteMode && ProjectRoot.empty()) {
+ llvm::errs() << "--project-root is required in remote mode\n";
+ return -1;
+ }
+
std::unique_ptr<SymbolIndex> Index;
- reportTime(llvm::StringRef(IndexLocation).startswith("remote:")
- ? "Remote index client creation"
- : "Dex build",
+ reportTime(RemoteMode ? "Remote index client creation" : "Dex build",
[&]() { Index = openIndex(IndexLocation); });
if (!Index) {
More information about the cfe-commits
mailing list