Replace llvm::MD5 with StableHasher

This commit is contained in:
Robert Widmann
2021-01-05 15:17:55 -08:00
parent f5cb08e3d1
commit 73ac8d3531
11 changed files with 53 additions and 42 deletions

View File

@@ -1092,22 +1092,21 @@ Fingerprint SourceFile::getInterfaceHash() const {
assert(hasInterfaceHash() && "Interface hash not enabled");
auto &eval = getASTContext().evaluator;
auto *mutableThis = const_cast<SourceFile *>(this);
auto md5 = *evaluateOrDefault(eval, ParseSourceFileRequest{mutableThis}, {})
.InterfaceHash;
llvm::MD5::MD5Result result;
md5.final(result);
return Fingerprint{std::move(result)};
Optional<StableHasher> interfaceHasher =
evaluateOrDefault(eval, ParseSourceFileRequest{mutableThis}, {})
.InterfaceHasher;
return Fingerprint{StableHasher{interfaceHasher.getValue()}.finalize()};
}
Fingerprint SourceFile::getInterfaceHashIncludingTypeMembers() const {
/// FIXME: Gross. Hashing multiple "hash" values.
llvm::MD5 hash;
hash.update(getInterfaceHash().getRawValue());
auto hash = StableHasher::defaultHasher();
hash.combine(getInterfaceHash());
std::function<void(IterableDeclContext *)> hashTypeBodyFingerprints =
[&](IterableDeclContext *IDC) {
if (auto fp = IDC->getBodyFingerprint())
hash.update(fp->getRawValue());
hash.combine(*fp);
for (auto *member : IDC->getParsedMembers())
if (auto *childIDC = dyn_cast<IterableDeclContext>(member))
hashTypeBodyFingerprints(childIDC);
@@ -1118,9 +1117,7 @@ Fingerprint SourceFile::getInterfaceHashIncludingTypeMembers() const {
hashTypeBodyFingerprints(IDC);
}
llvm::MD5::MD5Result result;
hash.final(result);
return Fingerprint{std::move(result)};
return Fingerprint{std::move(hash)};
}
syntax::SourceFileSyntax SourceFile::getSyntaxRoot() const {