Skip to content

Commit 839a410

Browse files
authored
Merge pull request #9140 from bnbarham/index-rehash
[Index] Convert to hashing to `HashBuilder` with BLAKE3
2 parents 9814cd7 + 4daaa11 commit 839a410

8 files changed

+346
-397
lines changed

clang/include/clang/Index/IndexRecordWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class IndexRecordWriter {
7575
/// \returns Success if we should continue writing this record, AlreadyExists
7676
/// if the record file has already been written, or Failure if there was an
7777
/// error, in which case \p Error will be set.
78-
Result beginRecord(StringRef Filename, llvm::hash_code RecordHash,
78+
Result beginRecord(StringRef Filename, uint64_t RecordHash,
7979
std::string &Error, std::string *RecordFile = nullptr);
8080

8181
/// Finish writing the record file.

clang/lib/Index/ClangIndexRecordWriter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ StringRef ClangIndexRecordWriter::getUSRNonCached(const IdentifierInfo *Name,
6363

6464
ClangIndexRecordWriter::ClangIndexRecordWriter(ASTContext &Ctx,
6565
RecordingOptions Opts)
66-
: Impl(Opts.DataDirPath), Ctx(Ctx), RecordOpts(std::move(Opts)),
67-
Hasher(Ctx) {
66+
: Impl(Opts.DataDirPath), Ctx(Ctx), RecordOpts(std::move(Opts)) {
6867
if (Opts.RecordSymbolCodeGenName)
6968
ASTNameGen.reset(new ASTNameGenerator(Ctx));
7069
}
@@ -76,7 +75,9 @@ bool ClangIndexRecordWriter::writeRecord(StringRef Filename,
7675
std::string &Error,
7776
std::string *OutRecordFile) {
7877

79-
auto RecordHash = Hasher.hashRecord(IdxRecord);
78+
std::array<uint8_t, 8> RecordHashArr = index::hashRecord(IdxRecord, Ctx);
79+
uint64_t RecordHash = 0;
80+
std::memcpy(&RecordHash, RecordHashArr.data(), RecordHashArr.size());
8081

8182
switch (Impl.beginRecord(Filename, RecordHash, Error, OutRecordFile)) {
8283
case IndexRecordWriter::Result::Success:

clang/lib/Index/ClangIndexRecordWriter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class ClangIndexRecordWriter {
3333
std::unique_ptr<ASTNameGenerator> ASTNameGen;
3434
llvm::BumpPtrAllocator Allocator;
3535
llvm::DenseMap<const void *, StringRef> USRByDecl;
36-
IndexRecordHasher Hasher;
3736

3837
public:
3938
ClangIndexRecordWriter(ASTContext &Ctx, RecordingOptions Opts);

0 commit comments

Comments
 (0)