Skip to content

Commit 9398153

Browse files
committed
[Parse] Preserve original member hashing behaviour
A previous commit inadvertently changed the logic such that the member hash of an extension body would be set to a partial interface hash. Luckily this shouldn't have caused any behavioural change as the interface hash itself would have been left unaffected. This commit makes sure we preserve the original behaviour where if we don't have the body tokens hashed separately, we give the body hash a default constructed MD5. Noticed by inspection.
1 parent 7b9ccb7 commit 9398153

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4471,11 +4471,11 @@ Parser::parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc, Diag<> ErrorDiag,
44714471

44724472
// If we're hashing the type body separately, record the curly braces but
44734473
// nothing inside for the interface hash.
4474-
Optional<llvm::SaveAndRestore<Optional<llvm::MD5>>> S;
4474+
Optional<llvm::SaveAndRestore<Optional<llvm::MD5>>> MemberHashingScope;
44754475
if (IDC->areTokensHashedForThisBodyInsteadOfInterfaceHash()) {
44764476
recordTokenHash("{");
44774477
recordTokenHash("}");
4478-
S.emplace(CurrentTokenHash, llvm::MD5());
4478+
MemberHashingScope.emplace(CurrentTokenHash, llvm::MD5());
44794479
}
44804480

44814481
std::vector<Decl *> decls;
@@ -4511,8 +4511,8 @@ Parser::parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc, Diag<> ErrorDiag,
45114511
return std::make_pair(decls, None);
45124512

45134513
llvm::MD5::MD5Result result;
4514-
auto tokenHashForThisDeclList = CurrentTokenHash.getValueOr(llvm::MD5());
4515-
tokenHashForThisDeclList.final(result);
4514+
auto declListHash = MemberHashingScope ? *CurrentTokenHash : llvm::MD5();
4515+
declListHash.final(result);
45164516
llvm::SmallString<32> tokenHashString;
45174517
llvm::MD5::stringifyResult(result, tokenHashString);
45184518
return std::make_pair(decls, tokenHashString.str().str());

0 commit comments

Comments
 (0)