[PATCH] D90397: [clangd] Value initialize SymbolIDs
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 29 08:06:16 PDT 2020
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
We were default initializing SymbolIDs before, which would leave
indeterminate values in underlying std::array.
This patch updates the underlying data initalization to be value-init and adds a
way to check for validness of a SymbolID.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90397
Files:
clang-tools-extra/clangd/index/SymbolID.h
Index: clang-tools-extra/clangd/index/SymbolID.h
===================================================================
--- clang-tools-extra/clangd/index/SymbolID.h
+++ clang-tools-extra/clangd/index/SymbolID.h
@@ -15,6 +15,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include <array>
+#include <cstdint>
#include <string>
namespace clang {
@@ -53,8 +54,10 @@
std::string str() const;
static llvm::Expected<SymbolID> fromStr(llvm::StringRef);
+ bool isValid() const { return HashValue != std::array<uint8_t, RawSize>{}; }
+
private:
- std::array<uint8_t, RawSize> HashValue;
+ std::array<uint8_t, RawSize> HashValue{};
};
llvm::hash_code hash_value(const SymbolID &ID);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90397.301625.patch
Type: text/x-patch
Size: 722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201029/87cb9bc1/attachment.bin>
More information about the cfe-commits
mailing list