[PATCH] D91049: [clangd][remote] Check an index file correctly
Aleksandr Platonov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 8 23:59:20 PST 2020
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91049.303759.patch
Type: text/x-patch
Size: 778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201109/a4a09d98/attachment.bin>
More information about the cfe-commits
mailing list