Skip to content

Commit 8839024

Browse files
committed
Migrate loadFingerprint onto ModuleDecl and Friends
1 parent 912ed27 commit 8839024

File tree

13 files changed

+32
-27
lines changed

13 files changed

+32
-27
lines changed

include/swift/AST/FileUnit.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ class FileUnit : public DeclContext {
110110
const ModuleDecl *importedModule,
111111
SmallSetVector<Identifier, 4> &spiGroups) const {};
112112

113+
virtual Optional<Fingerprint>
114+
loadFingerprint(const IterableDeclContext *IDC) const { return None; }
115+
113116
protected:
114117
/// Look up an operator declaration. Do not call directly, use
115118
/// \c DirectOperatorLookupRequest instead.

include/swift/AST/LazyResolver.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ class alignas(void*) LazyMemberLoader {
8484
loadNamedMembers(const IterableDeclContext *IDC, DeclBaseName N,
8585
uint64_t contextData) = 0;
8686

87-
/// Returns the fingerprint associated with the given iterable decl context,
88-
/// or \c None if no such fingerprint is available.
89-
virtual Optional<Fingerprint>
90-
loadFingerprint(const IterableDeclContext *IDC) = 0;
91-
9287
/// Populates the given vector with all conformances for \p D.
9388
///
9489
/// The implementation should \em not call setConformances on \p D.

include/swift/AST/Module.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ class ModuleDecl : public DeclContext, public TypeDecl {
572572
ObjCSelector selector,
573573
SmallVectorImpl<AbstractFunctionDecl *> &results) const;
574574

575+
Optional<Fingerprint>
576+
loadFingerprint(const IterableDeclContext *IDC) const;
577+
575578
/// Find all SPI names imported from \p importedModule by this module,
576579
/// collecting the identifiers in \p spiGroups.
577580
void lookupImportedSPIGroups(

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ class SerializedASTFile final : public LoadedFile {
373373
ObjCSelector selector,
374374
SmallVectorImpl<AbstractFunctionDecl *> &results) const override;
375375

376+
Optional<Fingerprint>
377+
loadFingerprint(const IterableDeclContext *IDC) const override;
378+
376379
virtual void
377380
lookupImportedSPIGroups(
378381
const ModuleDecl *importedModule,

lib/AST/DeclContext.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,13 +1013,6 @@ IterableDeclContext::castDeclToIterableDeclContext(const Decl *D) {
10131013

10141014
Optional<Fingerprint> IterableDeclContext::getBodyFingerprint() const {
10151015
auto &ctx = getASTContext();
1016-
// If this decl comes from a serialized module, grab its fingerprint from
1017-
// the file.
1018-
if (!getAsGenericContext()->getParentSourceFile()) {
1019-
auto ci = ctx.getOrCreateLazyIterableContextData(this,
1020-
/*lazyLoader=*/nullptr);
1021-
return ci->loader->loadFingerprint(this);
1022-
}
10231016
auto mutableThis = const_cast<IterableDeclContext *>(this);
10241017
return evaluateOrDefault(ctx.evaluator, ParseMembersRequest{mutableThis},
10251018
FingerprintAndMembers())

lib/AST/FrontendSourceFileDepGraphFactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ ModuleDepGraphFactory::ModuleDepGraphFactory(const ModuleDecl *Mod,
507507
bool emitDot)
508508
: AbstractSourceFileDepGraphFactory(Mod->getASTContext().hadError(),
509509
Mod->getNameStr(),
510-
Fingerprint(std::string{Fingerprint::DIGEST_LENGTH, '0'}),
510+
Fingerprint("00000000000000000000000000000000"),
511511
emitDot,
512512
Mod->getASTContext().Diags),
513513
Mod(Mod) {}

lib/AST/Module.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,15 @@ void ModuleDecl::lookupObjCMethods(
680680
FORWARD(lookupObjCMethods, (selector, results));
681681
}
682682

683+
Optional<Fingerprint>
684+
ModuleDecl::loadFingerprint(const IterableDeclContext *IDC) const {
685+
for (auto file : getFiles()) {
686+
if (auto FP = file->loadFingerprint(IDC))
687+
return FP;
688+
}
689+
return None;
690+
}
691+
683692
void ModuleDecl::lookupImportedSPIGroups(
684693
const ModuleDecl *importedModule,
685694
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,12 +3831,6 @@ void ClangImporter::Implementation::lookupAllObjCMembers(
38313831
}
38323832
}
38333833

3834-
Optional<Fingerprint>
3835-
ClangImporter::Implementation::loadFingerprint(const IterableDeclContext *) {
3836-
// Clang decls are not fingerprinted in Swift.
3837-
return None;
3838-
}
3839-
38403834
TinyPtrVector<ValueDecl *>
38413835
ClangImporter::Implementation::loadNamedMembers(
38423836
const IterableDeclContext *IDC, DeclBaseName N, uint64_t contextData) {

lib/ClangImporter/ImporterImpl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,9 +1247,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
12471247
loadNamedMembers(const IterableDeclContext *IDC, DeclBaseName N,
12481248
uint64_t contextData) override;
12491249

1250-
virtual Optional<Fingerprint>
1251-
loadFingerprint(const IterableDeclContext *IDC) override;
1252-
12531250
private:
12541251
void
12551252
loadAllMembersOfObjcContainer(Decl *D,

lib/Parse/ParseRequests.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ ParseMembersRequest::evaluate(Evaluator &evaluator,
6262
}
6363
}
6464

65-
return FingerprintAndMembers{None, ctx.AllocateCopy(members)};
65+
Optional<Fingerprint> fp = None;
66+
if (!idc->getDecl()->isImplicit()) {
67+
fp = idc->getDecl()->getModuleContext()->loadFingerprint(idc);
68+
}
69+
return FingerprintAndMembers{fp, ctx.AllocateCopy(members)};
6670
}
6771

6872
unsigned bufferID = *sf->getBufferID();

0 commit comments

Comments
 (0)