Skip to content

[NFC] Pull addAllDefinedDeclsOfAGivenType into its Base Class #34581

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 1 commit into from
Nov 6, 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
13 changes: 13 additions & 0 deletions include/swift/AST/AbstractSourceFileDepGraphFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ class AbstractSourceFileDepGraphFactory {
virtual void addAllUsedDecls() = 0;

protected:
/// Given an array of Decls or pairs of them in \p declsOrPairs
/// create node pairs for context and name
template <NodeKind kind, typename ContentsT>
void addAllDefinedDeclsOfAGivenType(std::vector<ContentsT> &contentsVec) {
for (const auto &declOrPair : contentsVec) {
Optional<std::string> fp =
AbstractSourceFileDepGraphFactory::getFingerprintIfAny(declOrPair);
addADefinedDecl(
DependencyKey::createForProvidedEntityInterface<kind>(declOrPair),
fp ? StringRef(fp.getValue()) : Optional<StringRef>());
}
}

/// Add an pair of interface, implementation nodes to the graph, which
/// represent some \c Decl defined in this source file. \param key the
/// interface key of the pair
Expand Down
28 changes: 0 additions & 28 deletions lib/AST/FrontendSourceFileDepGraphFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,20 +408,6 @@ void FrontendSourceFileDepGraphFactory::addAllDefinedDecls() {
declFinder.classMembers);
}

/// Given an array of Decls or pairs of them in \p declsOrPairs
/// create node pairs for context and name
template <NodeKind kind, typename ContentsT>
void FrontendSourceFileDepGraphFactory::addAllDefinedDeclsOfAGivenType(
std::vector<ContentsT> &contentsVec) {
for (const auto &declOrPair : contentsVec) {
Optional<std::string> fp =
AbstractSourceFileDepGraphFactory::getFingerprintIfAny(declOrPair);
addADefinedDecl(
DependencyKey::createForProvidedEntityInterface<kind>(declOrPair),
fp ? StringRef(fp.getValue()) : Optional<StringRef>());
}
}

//==============================================================================
// MARK: FrontendSourceFileDepGraphFactory - adding collections of used Decls
//==============================================================================
Expand Down Expand Up @@ -565,17 +551,3 @@ void ModuleDepGraphFactory::addAllDefinedDecls() {
addAllDefinedDeclsOfAGivenType<NodeKind::dynamicLookup>(
declFinder.classMembers);
}

/// Given an array of Decls or pairs of them in \p declsOrPairs
/// create node pairs for context and name
template <NodeKind kind, typename ContentsT>
void ModuleDepGraphFactory::addAllDefinedDeclsOfAGivenType(
std::vector<ContentsT> &contentsVec) {
for (const auto &declOrPair : contentsVec) {
Optional<std::string> fp =
AbstractSourceFileDepGraphFactory::getFingerprintIfAny(declOrPair);
addADefinedDecl(
DependencyKey::createForProvidedEntityInterface<kind>(declOrPair),
fp ? StringRef(fp.getValue()) : Optional<StringRef>());
}
}
10 changes: 0 additions & 10 deletions lib/AST/FrontendSourceFileDepGraphFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ class FrontendSourceFileDepGraphFactory

void addAllDefinedDecls() override;
void addAllUsedDecls() override;

/// Given an array of Decls or pairs of them in \p declsOrPairs
/// create node pairs for context and name
template <NodeKind kind, typename ContentsT>
void addAllDefinedDeclsOfAGivenType(std::vector<ContentsT> &contentsVec);
};

class ModuleDepGraphFactory : public AbstractSourceFileDepGraphFactory {
Expand All @@ -57,11 +52,6 @@ class ModuleDepGraphFactory : public AbstractSourceFileDepGraphFactory {
private:
void addAllDefinedDecls() override;
void addAllUsedDecls() override {}

/// Given an array of Decls or pairs of them in \p declsOrPairs
/// create node pairs for context and name
template <NodeKind kind, typename ContentsT>
void addAllDefinedDeclsOfAGivenType(std::vector<ContentsT> &contentsVec);
};

} // namespace fine_grained_dependencies
Expand Down