Skip to content

Commit 0d37f52

Browse files
committed
APIDigester: Break cycle between Frontend and APIDigester targets.
Also push a utility that was previously on `SILDeclRef` down to AST so that the SIL dependency can be removed entirely from APIDigester.
1 parent e2a41d1 commit 0d37f52

File tree

7 files changed

+12
-17
lines changed

7 files changed

+12
-17
lines changed

include/swift/AST/Decl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6908,6 +6908,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
69086908
/// vtable.
69096909
bool needsNewVTableEntry() const;
69106910

6911+
/// True if the decl is a method which introduces a new witness table entry.
6912+
bool requiresNewWitnessTableEntry() const {
6913+
return getOverriddenDecls().empty();
6914+
}
6915+
69116916
public:
69126917
/// Retrieve the source range of the function body.
69136918
SourceRange getBodySourceRange() const;

include/swift/SIL/SILDeclRef.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,6 @@ struct SILDeclRef {
510510
/// table entry.
511511
bool requiresNewWitnessTableEntry() const;
512512

513-
/// True if the decl is a method which introduces a new witness table entry.
514-
static bool requiresNewWitnessTableEntry(AbstractFunctionDecl *func);
515-
516513
/// Return a SILDeclRef to the declaration overridden by this one, or
517514
/// a null SILDeclRef if there is no override.
518515
SILDeclRef getOverridden() const;

include/swift/SIL/SILWitnessVisitor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
125125

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

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

147147
void visitFuncDecl(FuncDecl *func) {
148148
assert(!isa<AccessorDecl>(func));
149-
if (SILDeclRef::requiresNewWitnessTableEntry(func)) {
149+
if (func->requiresNewWitnessTableEntry()) {
150150
asDerived().addMethod(SILDeclRef(func, SILDeclRef::Kind::Func));
151151
addAutoDiffDerivativeMethodsIfRequired(func, SILDeclRef::Kind::Func);
152152
addDistributedWitnessMethodsIfRequired(func, SILDeclRef::Kind::Func);

lib/APIDigester/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ add_swift_host_library(swiftAPIDigester STATIC
55
ModuleDiagsConsumer.cpp)
66

77
target_link_libraries(swiftAPIDigester PRIVATE
8-
swiftFrontend
9-
swiftSIL
108
swiftIDE)
119

1210
set_swift_llvm_is_available(swiftAPIDigester)

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "swift/AST/ASTMangler.h"
33
#include "swift/Basic/Defer.h"
44
#include "swift/Sema/IDETypeChecking.h"
5-
#include "swift/SIL/SILDeclRef.h"
65
#include <swift/APIDigester/ModuleAnalyzerNodes.h>
76
#include <algorithm>
87

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

14921491
static bool requireWitnessTableEntry(ValueDecl *VD) {
14931492
if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD)) {
1494-
return SILDeclRef::requiresNewWitnessTableEntry(FD);
1493+
return FD->requiresNewWitnessTableEntry();
14951494
}
14961495
return false;
14971496
}

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,11 +1233,7 @@ bool SILDeclRef::requiresNewVTableEntry() const {
12331233
}
12341234

12351235
bool SILDeclRef::requiresNewWitnessTableEntry() const {
1236-
return requiresNewWitnessTableEntry(cast<AbstractFunctionDecl>(getDecl()));
1237-
}
1238-
1239-
bool SILDeclRef::requiresNewWitnessTableEntry(AbstractFunctionDecl *func) {
1240-
return func->getOverriddenDecls().empty();
1236+
return cast<AbstractFunctionDecl>(getDecl())->requiresNewWitnessTableEntry();
12411237
}
12421238

12431239
SILDeclRef SILDeclRef::getOverridden() const {

lib/SILGen/SILGenExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
28642864
// entry.
28652865
if (isa<ProtocolDecl>(property->getDeclContext())) {
28662866
auto accessor = getRepresentativeAccessorForKeyPath(property);
2867-
if (!SILDeclRef::requiresNewWitnessTableEntry(accessor)) {
2867+
if (!accessor->requiresNewWitnessTableEntry()) {
28682868
// Find the getter that does have a witness table entry.
28692869
auto wtableAccessor =
28702870
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(accessor));
@@ -3027,7 +3027,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
30273027
// entry.
30283028
if (isa<ProtocolDecl>(property->getDeclContext())) {
30293029
auto setter = property->getOpaqueAccessor(AccessorKind::Set);
3030-
if (!SILDeclRef::requiresNewWitnessTableEntry(setter)) {
3030+
if (!setter->requiresNewWitnessTableEntry()) {
30313031
// Find the setter that does have a witness table entry.
30323032
auto wtableSetter =
30333033
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(setter));

0 commit comments

Comments
 (0)