summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clangd/SourceCode.cpp9
-rw-r--r--clang-tools-extra/clangd/SourceCode.h3
-rw-r--r--clang-tools-extra/clangd/index/Background.cpp1
-rw-r--r--clang-tools-extra/clangd/index/Background.h1
-rw-r--r--clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp7
-rw-r--r--clang-tools-extra/clangd/index/Serialization.cpp2
-rw-r--r--clang-tools-extra/clangd/unittests/SerializationTests.cpp5
7 files changed, 11 insertions, 17 deletions
diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp
index 9fcaed45519..5c715ba8df7 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -25,6 +25,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/xxhash.h"
#include <algorithm>
namespace clang {
@@ -376,7 +377,13 @@ bool isRangeConsecutive(const Range &Left, const Range &Right) {
}
FileDigest digest(llvm::StringRef Content) {
- return llvm::SHA1::hash({(const uint8_t *)Content.data(), Content.size()});
+ uint64_t Hash{llvm::xxHash64(Content)};
+ FileDigest Result;
+ for (unsigned I = 0; I < Result.size(); ++I) {
+ Result[I] = uint8_t(Hash);
+ Hash >>= 8;
+ }
+ return Result;
}
llvm::Optional<FileDigest> digestFile(const SourceManager &SM, FileID FID) {
diff --git a/clang-tools-extra/clangd/SourceCode.h b/clang-tools-extra/clangd/SourceCode.h
index efa33f63b35..9532a318032 100644
--- a/clang-tools-extra/clangd/SourceCode.h
+++ b/clang-tools-extra/clangd/SourceCode.h
@@ -22,7 +22,6 @@
#include "clang/Tooling/Core/Replacement.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/SHA1.h"
namespace clang {
class SourceManager;
@@ -32,7 +31,7 @@ namespace clangd {
// We tend to generate digests for source codes in a lot of different places.
// This represents the type for those digests to prevent us hard coding details
// of hashing function at every place that needs to store this information.
-using FileDigest = decltype(llvm::SHA1::hash({}));
+using FileDigest = std::array<uint8_t, 8>;
FileDigest digest(StringRef Content);
Optional<FileDigest> digestFile(const SourceManager &SM, FileID FID);
diff --git a/clang-tools-extra/clangd/index/Background.cpp b/clang-tools-extra/clangd/index/Background.cpp
index 7c89d1a1b6b..7f25241632e 100644
--- a/clang-tools-extra/clangd/index/Background.cpp
+++ b/clang-tools-extra/clangd/index/Background.cpp
@@ -32,7 +32,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Error.h"
-#include "llvm/Support/SHA1.h"
#include "llvm/Support/Threading.h"
#include <atomic>
diff --git a/clang-tools-extra/clangd/index/Background.h b/clang-tools-extra/clangd/index/Background.h
index e3d833e801e..a8f53c97cfd 100644
--- a/clang-tools-extra/clangd/index/Background.h
+++ b/clang-tools-extra/clangd/index/Background.h
@@ -19,7 +19,6 @@
#include "index/Serialization.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/SHA1.h"
#include "llvm/Support/Threading.h"
#include <atomic>
#include <condition_variable>
diff --git a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
index 42db1dc5d48..80246b9ceea 100644
--- a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -13,18 +13,11 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/SHA1.h"
namespace clang {
namespace clangd {
namespace {
-using FileDigest = decltype(llvm::SHA1::hash({}));
-
-static FileDigest digest(StringRef Content) {
- return llvm::SHA1::hash({(const uint8_t *)Content.data(), Content.size()});
-}
-
std::string getShardPathFromFilePath(llvm::StringRef ShardRoot,
llvm::StringRef FilePath) {
llvm::SmallString<128> ShardRootSS(ShardRoot);
diff --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp
index 5b3c7cf943e..188a5cc1862 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -444,7 +444,7 @@ readCompileCommand(Reader CmdReader, llvm::ArrayRef<llvm::StringRef> Strings) {
// The current versioning scheme is simple - non-current versions are rejected.
// If you make a breaking change, bump this version number to invalidate stored
// data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 11;
+constexpr static uint32_t Version = 12;
llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data) {
auto RIFF = riff::readFile(Data);
diff --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index b76ea8243fc..4abb6f3e430 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -10,7 +10,6 @@
#include "index/Index.h"
#include "index/Serialization.h"
#include "clang/Tooling/CompilationDatabase.h"
-#include "llvm/Support/SHA1.h"
#include "llvm/Support/ScopedPrinter.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -208,9 +207,7 @@ TEST(SerializationTest, SrcsTest) {
std::string TestContent("TestContent");
IncludeGraphNode IGN;
- IGN.Digest =
- llvm::SHA1::hash({reinterpret_cast<const uint8_t *>(TestContent.data()),
- TestContent.size()});
+ IGN.Digest = digest(TestContent);
IGN.DirectIncludes = {"inc1", "inc2"};
IGN.URI = "URI";
IGN.Flags |= IncludeGraphNode::SourceFlag::IsTU;
OpenPOWER on IntegriCloud