mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Derive a Fingerprint from a Module's BasicSourceFileInfo
This commit is contained in:
@@ -1549,6 +1549,25 @@ void ModuleDecl::collectBasicSourceFileInfo(
|
||||
}
|
||||
}
|
||||
|
||||
Fingerprint ModuleDecl::getFingerprint() const {
|
||||
StableHasher hasher = StableHasher::defaultHasher();
|
||||
SmallVector<Fingerprint, 16> FPs;
|
||||
collectBasicSourceFileInfo([&](const BasicSourceFileInfo &bsfi) {
|
||||
FPs.emplace_back(bsfi.InterfaceHash);
|
||||
});
|
||||
|
||||
// Sort the fingerprints lexicographically so we have a stable hash despite
|
||||
// an unstable ordering of files across rebuilds.
|
||||
// FIXME: If we used a commutative hash combine (say, if we could take an
|
||||
// XOR here) we could avoid this sort.
|
||||
std::sort(FPs.begin(), FPs.end(), std::less<Fingerprint>());
|
||||
for (const auto &FP : FPs) {
|
||||
hasher.combine(FP);
|
||||
}
|
||||
|
||||
return Fingerprint{std::move(hasher)};
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Cross-Import Overlays
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user