Skip to content

Commit 1f9347b

Browse files
author
David Ungar
authored
Merge pull request swiftlang#30148 from davidungar/extension-fingerprint-fix-2-29
[Incremental] Don't fingerprint extension bodies
2 parents ff1398e + 7203249 commit 1f9347b

File tree

11 files changed

+136
-6
lines changed

11 files changed

+136
-6
lines changed

include/swift/AST/DeclContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ class IterableDeclContext {
814814
/// available.
815815
Optional<std::string> getBodyFingerprint() const;
816816

817-
bool areDependenciesUsingTokenHashesForTypeBodies() const;
817+
bool areTokensHashedForThisBodyInsteadOfInterfaceHash() const;
818818

819819
private:
820820
/// Add a member to the list for iteration purposes, but do not notify the

lib/AST/DeclContext.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,13 @@ Optional<std::string> IterableDeclContext::getBodyFingerprint() const {
918918
.fingerprint;
919919
}
920920

921-
bool IterableDeclContext::areDependenciesUsingTokenHashesForTypeBodies() const {
921+
bool IterableDeclContext::areTokensHashedForThisBodyInsteadOfInterfaceHash()
922+
const {
923+
// Do not keep separate hashes for extension bodies because the dependencies
924+
// can miss the addition of a member in an extension because there is nothing
925+
// corresponding to the fingerprinted nominal dependency node.
926+
if (isa<ExtensionDecl>(this))
927+
return false;
922928
return getASTContext().LangOpts.EnableTypeFingerprints;
923929
}
924930

lib/AST/FrontendSourceFileDepGraphFactory.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,7 @@ FrontendSourceFileDepGraphFactory::getInterfaceHash(SourceFile *SF) {
721721
return interfaceHash.str().str();
722722
}
723723

724-
/// At present, only nominals, protocols, and extensions have (body)
725-
/// fingerprints
724+
/// At present, only \c NominalTypeDecls have (body) fingerprints
726725
Optional<std::string> FrontendSourceFileDepGraphFactory::getFingerprintIfAny(
727726
std::pair<const NominalTypeDecl *, const ValueDecl *>) {
728727
return None;

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4517,13 +4517,13 @@ Parser::parseDeclList(SourceLoc LBLoc, SourceLoc &RBLoc, Diag<> ErrorDiag,
45174517
bool &hadError) {
45184518

45194519
// Record the curly braces but nothing inside.
4520-
if (IDC->areDependenciesUsingTokenHashesForTypeBodies()) {
4520+
if (IDC->areTokensHashedForThisBodyInsteadOfInterfaceHash()) {
45214521
recordTokenHash("{");
45224522
recordTokenHash("}");
45234523
}
45244524
llvm::MD5 tokenHashForThisDeclList;
45254525
llvm::SaveAndRestore<NullablePtr<llvm::MD5>> T(
4526-
CurrentTokenHash, IDC->areDependenciesUsingTokenHashesForTypeBodies()
4526+
CurrentTokenHash, IDC->areTokensHashedForThisBodyInsteadOfInterfaceHash()
45274527
? &tokenHashForThisDeclList
45284528
: CurrentTokenHash);
45294529

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct A {
2+
}
3+
struct B {
4+
}
5+
extension A {
6+
var x: Int {17}
7+
}
8+
extension B {
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
struct A {
2+
}
3+
struct B {
4+
}
5+
extension A {
6+
}
7+
extension B {
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"main.swift": {
3+
"object": "./main.o",
4+
"swift-dependencies": "./main.swiftdeps"
5+
},
6+
"definesAB.swift": {
7+
"object": "./definesAB.o",
8+
"swift-dependencies": "./definesAB.swiftdeps"
9+
},
10+
"usesA.swift": {
11+
"object": "./usesA.o",
12+
"swift-dependencies": "./usesA.swiftdeps"
13+
},
14+
"usesB.swift": {
15+
"object": "./usesB.o",
16+
"swift-dependencies": "./usesB.swiftdeps"
17+
},
18+
"": {
19+
"swift-dependencies": "./main~buildrecord.swiftdeps"
20+
}
21+
}
22+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let a = A()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let b = B()

0 commit comments

Comments
 (0)