Skip to content

Unconditionally Record Type Body Fingerprints #34700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/swift/AST/DeclContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,6 @@ class IterableDeclContext {
/// available.
Optional<std::string> getBodyFingerprint() const;

bool areTokensHashedForThisBodyInsteadOfInterfaceHash() const;

private:
/// Add a member to the list for iteration purposes, but do not notify the
/// subclass that we have done so.
Expand Down
10 changes: 0 additions & 10 deletions lib/AST/DeclContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,16 +1022,6 @@ Optional<std::string> IterableDeclContext::getBodyFingerprint() const {
.fingerprint;
}

bool IterableDeclContext::areTokensHashedForThisBodyInsteadOfInterfaceHash()
const {
// Do not keep separate hashes for extension bodies because the dependencies
// can miss the addition of a member in an extension because there is nothing
// corresponding to the fingerprinted nominal dependency node.
if (isa<ExtensionDecl>(this))
return false;
return true;
}

/// Return the DeclContext to compare when checking private access in
/// Swift 4 mode. The context returned is the type declaration if the context
/// and the type declaration are in the same file, otherwise it is the types
Expand Down
12 changes: 4 additions & 8 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4765,12 +4765,9 @@ Parser::parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc, Diag<> ErrorDiag,

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

std::vector<Decl *> decls;
ParserStatus Status;
Expand Down Expand Up @@ -4802,8 +4799,7 @@ Parser::parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc, Diag<> ErrorDiag,
hadError = true;

llvm::MD5::MD5Result result;
auto declListHash = MemberHashingScope ? *CurrentTokenHash : llvm::MD5();
declListHash.final(result);
CurrentTokenHash->final(result);
llvm::SmallString<32> tokenHashString;
llvm::MD5::stringifyResult(result, tokenHashString);
return std::make_pair(decls, tokenHashString.str().str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ struct A {
struct B {
}
extension A {
var x: Int {17}
init(_ x: String = "") {}
}
extension B {
}