[clang-tools-extra] r344521 - [clangd] Add createIndex in dexp

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 15 08:12:40 PDT 2018


Author: hokein
Date: Mon Oct 15 08:12:40 2018
New Revision: 344521

URL: http://llvm.org/viewvc/llvm-project?rev=344521&view=rev
Log:
[clangd] Add createIndex in dexp

Summary:
This would allow easily injecting our internal customization.

Also updates the stale "symbol-collection-file" flag.

Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D53292

Modified:
    clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp?rev=344521&r1=344520&r2=344521&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp Mon Oct 15 08:12:40 2018
@@ -31,9 +31,9 @@ using namespace llvm;
 namespace {
 
 llvm::cl::opt<std::string>
-    SymbolCollection("symbol-collection-file",
-                     llvm::cl::desc("Path to the file with symbol collection"),
-                     llvm::cl::Positional, llvm::cl::Required);
+    IndexPath("index-path",
+              llvm::cl::desc("Path to the index"),
+              llvm::cl::Positional, llvm::cl::Required);
 
 static const std::string Overview = R"(
 This is an **experimental** interactive tool to process user-provided search
@@ -253,6 +253,10 @@ struct {
      llvm::make_unique<Refs>},
 };
 
+std::unique_ptr<SymbolIndex> openIndex(llvm::StringRef Index) {
+  return loadIndex(Index, /*URISchemes=*/{}, /*UseDex=*/true);
+}
+
 } // namespace
 
 int main(int argc, const char *argv[]) {
@@ -262,13 +266,11 @@ int main(int argc, const char *argv[]) {
 
   std::unique_ptr<SymbolIndex> Index;
   reportTime("Dex build", [&]() {
-    Index = loadIndex(SymbolCollection, /*URISchemes=*/{},
-                      /*UseDex=*/true);
+    Index = openIndex(IndexPath);
   });
 
   if (!Index) {
-    llvm::outs()
-        << "ERROR: Please provide a valid path to symbol collection file.\n";
+    llvm::outs() << "Failed to open the index.\n";
     return -1;
   }
 




More information about the cfe-commits mailing list