[PATCH] D51674: [clangd] Fix async index loading (from r341376).

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 5 04:41:09 PDT 2018


sammccall updated this revision to Diff 164012.
sammccall added a comment.

Don't load index asynchronously if -run-synchronously is passed.

Nothing needs this today, but it's less surprising behavior.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51674

Files:
  clangd/tool/ClangdMain.cpp


Index: clangd/tool/ClangdMain.cpp
===================================================================
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -271,14 +271,17 @@
     Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   std::unique_ptr<SymbolIndex> StaticIdx;
+  std::future<void> AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !YamlSymbolFile.empty()) {
     // Load the index asynchronously. Meanwhile SwapIndex returns no results.
     SwapIndex *Placeholder;
     StaticIdx.reset(Placeholder = new SwapIndex(llvm::make_unique<MemIndex>()));
-    runAsync<void>([Placeholder] {
+    AsyncIndexLoad = runAsync<void>([Placeholder] {
       if (auto Idx = loadIndex(YamlSymbolFile))
         Placeholder->reset(std::move(Idx));
     });
+    if (RunSynchronously)
+      AsyncIndexLoad.wait();
   }
   Opts.StaticIndex = StaticIdx.get();
   Opts.AsyncThreadsCount = WorkerThreadsCount;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51674.164012.patch
Type: text/x-patch
Size: 969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180905/d7fd2fad/attachment-0001.bin>


More information about the cfe-commits mailing list