Skip to content

Commit f2c61d8

Browse files
author
David Ungar
committed
Bug fixes for type fingerprints
1 parent 44a6475 commit f2c61d8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/AST/FineGrainedDependenciesSourceFileDepGraphConstructor.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,10 @@ class SourceFileDepGraphConstructor {
680680
for (const auto &contextNameFingerprint : contextNameFingerprints) {
681681
auto p = g.findExistingNodePairOrCreateAndAddIfNew(
682682
kind, contextNameFingerprint);
683-
// When we don't have a fingerprint yet, must rebuild every provider when
684-
// interfaceHash changes. So when interface (i.e. interface hash) of
685-
// sourceFile changes, every provides is dirty. And since we don't know
686-
// what happened, dirtyness might affect the interface.
687-
if (!p.getInterface()->getFingerprint().hasValue())
688-
g.addArc(g.getSourceFileNodePair().getInterface(), p.getInterface());
683+
// Since the current type fingerprints only include tokens in the body,
684+
// when the interface hash changes, it is possible that the type in the
685+
// file has changed.
686+
g.addArc(g.getSourceFileNodePair().getInterface(), p.getInterface());
689687
}
690688
}
691689

@@ -809,8 +807,15 @@ bool swift::fine_grained_dependencies::emitReferenceDependencies(
809807
// that may have been there. No error handling -- this is just a nicety, it
810808
// doesn't matter if it fails.
811809
llvm::sys::fs::rename(outputPath, outputPath + "~");
810+
// Since, when fingerprints are enabled,
811+
// the parser diverts token hashing into per-body fingerprints
812+
// before it can know if a difference is in a private type,
813+
// in order to be able to test the changed fingerprints
814+
// we force the inclusion of private declarations when fingerprints
815+
// are enabled.
812816
const bool includeIntrafileDeps =
813-
SF->getASTContext().LangOpts.FineGrainedDependenciesIncludeIntrafileOnes;
817+
SF->getASTContext().LangOpts.FineGrainedDependenciesIncludeIntrafileOnes ||
818+
SF->getASTContext().LangOpts.EnableTypeFingerprints;
814819
const bool hadCompilationError = SF->getASTContext().hadError();
815820
auto gc = SourceFileDepGraphConstructor::forSourceFile(
816821
SF, depTracker, outputPath, includeIntrafileDeps, hadCompilationError);

0 commit comments

Comments
 (0)