From ca9e5dc71481b7e514d322804d86a8328f857d3a Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Mon, 19 Nov 2018 18:06:29 +0000 Subject: [clangd] Store source file hash in IndexFile{In,Out} Summary: Puts the digest of the source file that generated the index into serialized index and stores them back on load, if exists. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54693 llvm-svn: 347235 --- clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp') diff --git a/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp b/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp index 6746e800ea1..39f4040f09d 100644 --- a/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp +++ b/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp @@ -121,8 +121,10 @@ TEST(BackgroundIndexTest, ShardStorageWriteTest) { void f_b(); class A_CC {}; )cpp"; - FS.Files[testPath("root/A.cc")] = - "#include \"A.h\"\nvoid g() { (void)common; }"; + std::string A_CC = "#include \"A.h\"\nvoid g() { (void)common; }"; + FS.Files[testPath("root/A.cc")] = A_CC; + auto Digest = llvm::SHA1::hash( + {reinterpret_cast(A_CC.data()), A_CC.size()}); llvm::StringMap Storage; size_t CacheHits = 0; @@ -156,6 +158,7 @@ TEST(BackgroundIndexTest, ShardStorageWriteTest) { EXPECT_NE(ShardSource, nullptr); EXPECT_THAT(*ShardSource->Symbols, UnorderedElementsAre()); EXPECT_THAT(*ShardSource->Refs, RefsAre({FileURI("unittest:///root/A.cc")})); + EXPECT_EQ(*ShardSource->Digest, Digest); } } // namespace clangd -- cgit v1.2.3