Skip to content

APIDigester: Break cycle between Frontend and APIDigester targets #61758

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
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
5 changes: 5 additions & 0 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6908,6 +6908,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// vtable.
bool needsNewVTableEntry() const;

/// True if the decl is a method which introduces a new witness table entry.
bool requiresNewWitnessTableEntry() const {
return getOverriddenDecls().empty();
}

public:
/// Retrieve the source range of the function body.
SourceRange getBodySourceRange() const;
Expand Down
3 changes: 0 additions & 3 deletions include/swift/SIL/SILDeclRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,6 @@ struct SILDeclRef {
/// table entry.
bool requiresNewWitnessTableEntry() const;

/// True if the decl is a method which introduces a new witness table entry.
static bool requiresNewWitnessTableEntry(AbstractFunctionDecl *func);

/// Return a SILDeclRef to the declaration overridden by this one, or
/// a null SILDeclRef if there is no override.
SILDeclRef getOverridden() const;
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SIL/SILWitnessVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {

void visitAbstractStorageDecl(AbstractStorageDecl *sd) {
sd->visitOpaqueAccessors([&](AccessorDecl *accessor) {
if (SILDeclRef::requiresNewWitnessTableEntry(accessor)) {
if (accessor->requiresNewWitnessTableEntry()) {
asDerived().addMethod(SILDeclRef(accessor, SILDeclRef::Kind::Func));
addAutoDiffDerivativeMethodsIfRequired(accessor,
SILDeclRef::Kind::Func);
Expand All @@ -134,7 +134,7 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
}

void visitConstructorDecl(ConstructorDecl *cd) {
if (SILDeclRef::requiresNewWitnessTableEntry(cd)) {
if (cd->requiresNewWitnessTableEntry()) {
asDerived().addMethod(SILDeclRef(cd, SILDeclRef::Kind::Allocator));
addAutoDiffDerivativeMethodsIfRequired(cd, SILDeclRef::Kind::Allocator);
}
Expand All @@ -146,7 +146,7 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {

void visitFuncDecl(FuncDecl *func) {
assert(!isa<AccessorDecl>(func));
if (SILDeclRef::requiresNewWitnessTableEntry(func)) {
if (func->requiresNewWitnessTableEntry()) {
asDerived().addMethod(SILDeclRef(func, SILDeclRef::Kind::Func));
addAutoDiffDerivativeMethodsIfRequired(func, SILDeclRef::Kind::Func);
addDistributedWitnessMethodsIfRequired(func, SILDeclRef::Kind::Func);
Expand Down
2 changes: 0 additions & 2 deletions lib/APIDigester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ add_swift_host_library(swiftAPIDigester STATIC
ModuleDiagsConsumer.cpp)

target_link_libraries(swiftAPIDigester PRIVATE
swiftFrontend
swiftSIL
swiftIDE)

set_swift_llvm_is_available(swiftAPIDigester)
3 changes: 1 addition & 2 deletions lib/APIDigester/ModuleAnalyzerNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "swift/AST/ASTMangler.h"
#include "swift/Basic/Defer.h"
#include "swift/Sema/IDETypeChecking.h"
#include "swift/SIL/SILDeclRef.h"
#include <swift/APIDigester/ModuleAnalyzerNodes.h>
#include <algorithm>

Expand Down Expand Up @@ -1491,7 +1490,7 @@ static bool isProtocolRequirement(ValueDecl *VD) {

static bool requireWitnessTableEntry(ValueDecl *VD) {
if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD)) {
return SILDeclRef::requiresNewWitnessTableEntry(FD);
return FD->requiresNewWitnessTableEntry();
}
return false;
}
Expand Down
6 changes: 1 addition & 5 deletions lib/SIL/IR/SILDeclRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,11 +1233,7 @@ bool SILDeclRef::requiresNewVTableEntry() const {
}

bool SILDeclRef::requiresNewWitnessTableEntry() const {
return requiresNewWitnessTableEntry(cast<AbstractFunctionDecl>(getDecl()));
}

bool SILDeclRef::requiresNewWitnessTableEntry(AbstractFunctionDecl *func) {
return func->getOverriddenDecls().empty();
return cast<AbstractFunctionDecl>(getDecl())->requiresNewWitnessTableEntry();
}

SILDeclRef SILDeclRef::getOverridden() const {
Expand Down
4 changes: 2 additions & 2 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2864,7 +2864,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
// entry.
if (isa<ProtocolDecl>(property->getDeclContext())) {
auto accessor = getRepresentativeAccessorForKeyPath(property);
if (!SILDeclRef::requiresNewWitnessTableEntry(accessor)) {
if (!accessor->requiresNewWitnessTableEntry()) {
// Find the getter that does have a witness table entry.
auto wtableAccessor =
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(accessor));
Expand Down Expand Up @@ -3027,7 +3027,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
// entry.
if (isa<ProtocolDecl>(property->getDeclContext())) {
auto setter = property->getOpaqueAccessor(AccessorKind::Set);
if (!SILDeclRef::requiresNewWitnessTableEntry(setter)) {
if (!setter->requiresNewWitnessTableEntry()) {
// Find the setter that does have a witness table entry.
auto wtableSetter =
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(setter));
Expand Down