ArcsinX created this revision. Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman. Herald added a project: clang. ArcsinX requested review of this revision. Herald added subscribers: MaskRay, ilya-biryukov.
There is not reason to check `std::make_unique<...>(..)` return value, but `clangd::clang::loadIndex()` returns `nullptr` if an index file could not be loaded (e.g. incorrect version). Repository: rG LLVM Github Monorepo 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,13 +357,12 @@ 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; } + auto Index = std::make_unique<clang::clangd::SwapIndex>(std::move(SymIndex)); std::thread HotReloadThread([&Index, &Status, &FS]() { llvm::vfs::Status LastStatus = *Status;
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,13 +357,12 @@ 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; } + auto Index = std::make_unique<clang::clangd::SwapIndex>(std::move(SymIndex)); std::thread HotReloadThread([&Index, &Status, &FS]() { llvm::vfs::Status LastStatus = *Status;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits