Skip to content

Commit c8255d6

Browse files
author
David Ungar
authored
Merge pull request #36133 from davidungar/module-print-2
[NFC; Incremental] Rename BasicSourceFileInfo.InterfaceHash
2 parents 26aa91e + cbd92e6 commit c8255d6

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

include/swift/AST/RawComment.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ struct BasicDeclLocs {
9898

9999
struct BasicSourceFileInfo {
100100
StringRef FilePath;
101-
Fingerprint InterfaceHash = Fingerprint::ZERO();
101+
/// Used for completion; factors in hashes from type-bodies in order to be sensitive to changes in
102+
/// the intefaces of top-level type members.
103+
Fingerprint InterfaceHashIncludingTypeMembers = Fingerprint::ZERO();
102104
llvm::sys::TimePoint<> LastModified = {};
103105
uint64_t FileSize = 0;
104106

lib/AST/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ Fingerprint ModuleDecl::getFingerprint() const {
15531553
StableHasher hasher = StableHasher::defaultHasher();
15541554
SmallVector<Fingerprint, 16> FPs;
15551555
collectBasicSourceFileInfo([&](const BasicSourceFileInfo &bsfi) {
1556-
FPs.emplace_back(bsfi.InterfaceHash);
1556+
FPs.emplace_back(bsfi.InterfaceHashIncludingTypeMembers);
15571557
});
15581558

15591559
// Sort the fingerprints lexicographically so we have a stable hash despite

lib/AST/RawComment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ bool BasicSourceFileInfo::populate(const SourceFile *SF) {
262262
FileSize = stat->getSize();
263263

264264
if (SF->hasInterfaceHash()) {
265-
InterfaceHash = SF->getInterfaceHashIncludingTypeMembers();
265+
InterfaceHashIncludingTypeMembers = SF->getInterfaceHashIncludingTypeMembers();
266266
} else {
267267
// FIXME: Parse the file with EnableInterfaceHash option.
268-
InterfaceHash = Fingerprint::ZERO();
268+
InterfaceHashIncludingTypeMembers = Fingerprint::ZERO();
269269
}
270270

271271
return false;

lib/Serialization/ModuleFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ void ModuleFile::collectBasicSourceFileInfo(
974974
while (Cursor < End) {
975975
// FilePath (byte offset in 'SourceLocsTextData').
976976
auto fileID = endian::readNext<uint32_t, little, unaligned>(Cursor);
977-
// InterfaceHash (fixed length string).
977+
// InterfaceHashIncludingTypeMembers (fixed length string).
978978
auto fpStr = StringRef{reinterpret_cast<const char *>(Cursor),
979979
Fingerprint::DIGEST_LENGTH};
980980
Cursor += Fingerprint::DIGEST_LENGTH;
@@ -991,7 +991,7 @@ void ModuleFile::collectBasicSourceFileInfo(
991991
BasicSourceFileInfo info;
992992
info.FilePath = filePath;
993993
if (auto fingerprint = Fingerprint::fromString(fpStr))
994-
info.InterfaceHash = fingerprint.getValue();
994+
info.InterfaceHashIncludingTypeMembers = fingerprint.getValue();
995995
else {
996996
llvm::errs() << "Unconvertable fingerprint '" << fpStr << "'\n";
997997
abort();

lib/Serialization/SerializeDoc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ static void emitFileListRecord(llvm::BitstreamWriter &Out,
803803
return;
804804

805805
auto fileID = FWriter.getTextOffset(absolutePath);
806-
auto fingerprintStr = info.InterfaceHash.getRawValue();
806+
auto fingerprintStr = info.InterfaceHashIncludingTypeMembers.getRawValue();
807807
auto timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>(
808808
info.LastModified.time_since_epoch())
809809
.count();
@@ -812,7 +812,7 @@ static void emitFileListRecord(llvm::BitstreamWriter &Out,
812812
endian::Writer writer(out, little);
813813
// FilePath.
814814
writer.write<uint32_t>(fileID);
815-
// InterfaceHash (fixed length string).
815+
// InterfaceHashIncludingTypeMembers (fixed length string).
816816
assert(fingerprintStr.size() == Fingerprint::DIGEST_LENGTH);
817817
out << fingerprintStr;
818818
// LastModified (nanoseconds since epoch).

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,7 @@ static void printModuleMetadata(ModuleDecl *MD) {
25182518
});
25192519
MD->collectBasicSourceFileInfo([&](const BasicSourceFileInfo &info) {
25202520
OS << "filepath=" << info.FilePath << "; ";
2521-
OS << "hash=" << info.InterfaceHash.getRawValue() << "; ";
2521+
OS << "hash=" << info.InterfaceHashIncludingTypeMembers.getRawValue() << "; ";
25222522
OS << "mtime=" << info.LastModified << "; ";
25232523
OS << "size=" << info.FileSize;
25242524
OS << "\n";

0 commit comments

Comments
 (0)