Skip to content

Commit fa89b07

Browse files
committed
Revert "Unconditionally Record Type Body Fingerprints"
This reverts commit cdd54f1.
1 parent d378e70 commit fa89b07

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

include/swift/AST/DeclContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,8 @@ class IterableDeclContext {
881881
/// available.
882882
Optional<Fingerprint> getBodyFingerprint() const;
883883

884+
bool areTokensHashedForThisBodyInsteadOfInterfaceHash() const;
885+
884886
private:
885887
/// Add a member to the list for iteration purposes, but do not notify the
886888
/// subclass that we have done so.

lib/AST/DeclContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,11 @@ Optional<Fingerprint> IterableDeclContext::getBodyFingerprint() const {
10321032
.fingerprint;
10331033
}
10341034

1035+
bool IterableDeclContext::areTokensHashedForThisBodyInsteadOfInterfaceHash()
1036+
const {
1037+
return true;
1038+
}
1039+
10351040
/// Return the DeclContext to compare when checking private access in
10361041
/// Swift 4 mode. The context returned is the type declaration if the context
10371042
/// and the type declaration are in the same file, otherwise it is the types

lib/Parse/ParseDecl.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4751,9 +4751,12 @@ Parser::parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc, Diag<> ErrorDiag,
47514751

47524752
// If we're hashing the type body separately, record the curly braces but
47534753
// nothing inside for the interface hash.
4754-
llvm::SaveAndRestore<Optional<llvm::MD5>> MemberHashingScope{CurrentTokenHash, llvm::MD5()};
4755-
recordTokenHash("{");
4756-
recordTokenHash("}");
4754+
Optional<llvm::SaveAndRestore<Optional<llvm::MD5>>> MemberHashingScope;
4755+
if (IDC->areTokensHashedForThisBodyInsteadOfInterfaceHash()) {
4756+
recordTokenHash("{");
4757+
recordTokenHash("}");
4758+
MemberHashingScope.emplace(CurrentTokenHash, llvm::MD5());
4759+
}
47574760

47584761
std::vector<Decl *> decls;
47594762
ParserStatus Status;
@@ -4785,7 +4788,8 @@ Parser::parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc, Diag<> ErrorDiag,
47854788
hadError = true;
47864789

47874790
llvm::MD5::MD5Result result;
4788-
CurrentTokenHash->final(result);
4791+
auto declListHash = MemberHashingScope ? *CurrentTokenHash : llvm::MD5();
4792+
declListHash.final(result);
47894793
return std::make_pair(decls, Fingerprint{std::move(result)});
47904794
}
47914795

0 commit comments

Comments
 (0)