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.
This commit is contained in:
Allan Shortlidge
2022-10-26 19:06:36 -07:00
parent e2a41d126a
commit 0d37f52fe0
7 changed files with 12 additions and 17 deletions

View File

@@ -6908,6 +6908,11 @@ public:
/// 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;

View File

@@ -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;

View File

@@ -125,7 +125,7 @@ public:
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);
@@ -134,7 +134,7 @@ public:
}
void visitConstructorDecl(ConstructorDecl *cd) {
if (SILDeclRef::requiresNewWitnessTableEntry(cd)) {
if (cd->requiresNewWitnessTableEntry()) {
asDerived().addMethod(SILDeclRef(cd, SILDeclRef::Kind::Allocator));
addAutoDiffDerivativeMethodsIfRequired(cd, SILDeclRef::Kind::Allocator);
}
@@ -146,7 +146,7 @@ public:
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);

View File

@@ -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)

View File

@@ -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>
@@ -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;
}

View File

@@ -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 {

View File

@@ -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));
@@ -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));