ArcsinX updated this revision to Diff 303766. ArcsinX added a comment. Do not use unique pointer for Index
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D91049/new/ https://reviews.llvm.org/D91049 Files: clang-tools-extra/clangd/index/remote/server/Server.cpp Index: clang-tools-extra/clangd/index/remote/server/Server.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/server/Server.cpp +++ clang-tools-extra/clangd/index/remote/server/Server.cpp @@ -357,24 +357,23 @@ return Status.getError().value(); } - auto Index = std::make_unique<clang::clangd::SwapIndex>( - clang::clangd::loadIndex(IndexPath)); - - if (!Index) { + auto SymIndex = clang::clangd::loadIndex(IndexPath); + if (!SymIndex) { llvm::errs() << "Failed to open the index.\n"; return -1; } + clang::clangd::SwapIndex Index(std::move(SymIndex)); std::thread HotReloadThread([&Index, &Status, &FS]() { llvm::vfs::Status LastStatus = *Status; static constexpr auto RefreshFrequency = std::chrono::seconds(30); while (!clang::clangd::shutdownRequested()) { - hotReload(*Index, llvm::StringRef(IndexPath), LastStatus, FS); + hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS); std::this_thread::sleep_for(RefreshFrequency); } }); - runServerAndWait(*Index, ServerAddress, IndexPath); + runServerAndWait(Index, ServerAddress, IndexPath); HotReloadThread.join(); }
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/server/Server.cpp +++ clang-tools-extra/clangd/index/remote/server/Server.cpp @@ -357,24 +357,23 @@ return Status.getError().value(); } - auto Index = std::make_unique<clang::clangd::SwapIndex>( - clang::clangd::loadIndex(IndexPath)); - - if (!Index) { + auto SymIndex = clang::clangd::loadIndex(IndexPath); + if (!SymIndex) { llvm::errs() << "Failed to open the index.\n"; return -1; } + clang::clangd::SwapIndex Index(std::move(SymIndex)); std::thread HotReloadThread([&Index, &Status, &FS]() { llvm::vfs::Status LastStatus = *Status; static constexpr auto RefreshFrequency = std::chrono::seconds(30); while (!clang::clangd::shutdownRequested()) { - hotReload(*Index, llvm::StringRef(IndexPath), LastStatus, FS); + hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS); std::this_thread::sleep_for(RefreshFrequency); } }); - runServerAndWait(*Index, ServerAddress, IndexPath); + runServerAndWait(Index, ServerAddress, IndexPath); HotReloadThread.join(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits