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 IndexLocation( llvm::cl::Positional); llvm::cl::opt - 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 ProjectRoot("project-root", - llvm::cl::desc("Path to the project")); +llvm::cl::opt 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 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) {