[PATCH] D44575: [clangd][nfc] Give name to a magic constant

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 16 12:27:15 PDT 2018

jkorous-apple created this revision.
jkorous-apple added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, ioeric, ilya-biryukov.

Since I was reading this code I decided I might just as well polish it a little. It is just preliminary commit for a bug-fix.

  rCTE Clang Tools Extra



Index: clangd/index/Index.h
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -54,16 +54,18 @@
+  static constexpr unsigned HashByteLength = 20;
   friend llvm::hash_code hash_value(const SymbolID &ID) {
     // We already have a good hash, just return the first bytes.
-    static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+    static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than SHA1!");
     return *reinterpret_cast<const size_t *>(ID.HashValue.data());
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
                                        const SymbolID &ID);
   friend void operator>>(llvm::StringRef Str, SymbolID &ID);
-  std::array<uint8_t, 20> HashValue;
+  std::array<uint8_t, HashByteLength> HashValue;
 // Write SymbolID into the given stream. SymbolID is encoded as a 40-bytes

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44575.138745.patch
Type: text/x-patch
Size: 943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180316/232e773f/attachment.bin>

More information about the cfe-commits mailing list