mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -6908,6 +6908,11 @@ public:
|
|||||||
/// vtable.
|
/// vtable.
|
||||||
bool needsNewVTableEntry() const;
|
bool needsNewVTableEntry() const;
|
||||||
|
|
||||||
|
/// True if the decl is a method which introduces a new witness table entry.
|
||||||
|
bool requiresNewWitnessTableEntry() const {
|
||||||
|
return getOverriddenDecls().empty();
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Retrieve the source range of the function body.
|
/// Retrieve the source range of the function body.
|
||||||
SourceRange getBodySourceRange() const;
|
SourceRange getBodySourceRange() const;
|
||||||
|
|||||||
@@ -510,9 +510,6 @@ struct SILDeclRef {
|
|||||||
/// table entry.
|
/// table entry.
|
||||||
bool requiresNewWitnessTableEntry() const;
|
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
|
/// Return a SILDeclRef to the declaration overridden by this one, or
|
||||||
/// a null SILDeclRef if there is no override.
|
/// a null SILDeclRef if there is no override.
|
||||||
SILDeclRef getOverridden() const;
|
SILDeclRef getOverridden() const;
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
|
|
||||||
void visitAbstractStorageDecl(AbstractStorageDecl *sd) {
|
void visitAbstractStorageDecl(AbstractStorageDecl *sd) {
|
||||||
sd->visitOpaqueAccessors([&](AccessorDecl *accessor) {
|
sd->visitOpaqueAccessors([&](AccessorDecl *accessor) {
|
||||||
if (SILDeclRef::requiresNewWitnessTableEntry(accessor)) {
|
if (accessor->requiresNewWitnessTableEntry()) {
|
||||||
asDerived().addMethod(SILDeclRef(accessor, SILDeclRef::Kind::Func));
|
asDerived().addMethod(SILDeclRef(accessor, SILDeclRef::Kind::Func));
|
||||||
addAutoDiffDerivativeMethodsIfRequired(accessor,
|
addAutoDiffDerivativeMethodsIfRequired(accessor,
|
||||||
SILDeclRef::Kind::Func);
|
SILDeclRef::Kind::Func);
|
||||||
@@ -134,7 +134,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void visitConstructorDecl(ConstructorDecl *cd) {
|
void visitConstructorDecl(ConstructorDecl *cd) {
|
||||||
if (SILDeclRef::requiresNewWitnessTableEntry(cd)) {
|
if (cd->requiresNewWitnessTableEntry()) {
|
||||||
asDerived().addMethod(SILDeclRef(cd, SILDeclRef::Kind::Allocator));
|
asDerived().addMethod(SILDeclRef(cd, SILDeclRef::Kind::Allocator));
|
||||||
addAutoDiffDerivativeMethodsIfRequired(cd, SILDeclRef::Kind::Allocator);
|
addAutoDiffDerivativeMethodsIfRequired(cd, SILDeclRef::Kind::Allocator);
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ public:
|
|||||||
|
|
||||||
void visitFuncDecl(FuncDecl *func) {
|
void visitFuncDecl(FuncDecl *func) {
|
||||||
assert(!isa<AccessorDecl>(func));
|
assert(!isa<AccessorDecl>(func));
|
||||||
if (SILDeclRef::requiresNewWitnessTableEntry(func)) {
|
if (func->requiresNewWitnessTableEntry()) {
|
||||||
asDerived().addMethod(SILDeclRef(func, SILDeclRef::Kind::Func));
|
asDerived().addMethod(SILDeclRef(func, SILDeclRef::Kind::Func));
|
||||||
addAutoDiffDerivativeMethodsIfRequired(func, SILDeclRef::Kind::Func);
|
addAutoDiffDerivativeMethodsIfRequired(func, SILDeclRef::Kind::Func);
|
||||||
addDistributedWitnessMethodsIfRequired(func, SILDeclRef::Kind::Func);
|
addDistributedWitnessMethodsIfRequired(func, SILDeclRef::Kind::Func);
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ add_swift_host_library(swiftAPIDigester STATIC
|
|||||||
ModuleDiagsConsumer.cpp)
|
ModuleDiagsConsumer.cpp)
|
||||||
|
|
||||||
target_link_libraries(swiftAPIDigester PRIVATE
|
target_link_libraries(swiftAPIDigester PRIVATE
|
||||||
swiftFrontend
|
|
||||||
swiftSIL
|
|
||||||
swiftIDE)
|
swiftIDE)
|
||||||
|
|
||||||
set_swift_llvm_is_available(swiftAPIDigester)
|
set_swift_llvm_is_available(swiftAPIDigester)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "swift/AST/ASTMangler.h"
|
#include "swift/AST/ASTMangler.h"
|
||||||
#include "swift/Basic/Defer.h"
|
#include "swift/Basic/Defer.h"
|
||||||
#include "swift/Sema/IDETypeChecking.h"
|
#include "swift/Sema/IDETypeChecking.h"
|
||||||
#include "swift/SIL/SILDeclRef.h"
|
|
||||||
#include <swift/APIDigester/ModuleAnalyzerNodes.h>
|
#include <swift/APIDigester/ModuleAnalyzerNodes.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -1491,7 +1490,7 @@ static bool isProtocolRequirement(ValueDecl *VD) {
|
|||||||
|
|
||||||
static bool requireWitnessTableEntry(ValueDecl *VD) {
|
static bool requireWitnessTableEntry(ValueDecl *VD) {
|
||||||
if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD)) {
|
if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD)) {
|
||||||
return SILDeclRef::requiresNewWitnessTableEntry(FD);
|
return FD->requiresNewWitnessTableEntry();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1233,11 +1233,7 @@ bool SILDeclRef::requiresNewVTableEntry() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SILDeclRef::requiresNewWitnessTableEntry() const {
|
bool SILDeclRef::requiresNewWitnessTableEntry() const {
|
||||||
return requiresNewWitnessTableEntry(cast<AbstractFunctionDecl>(getDecl()));
|
return cast<AbstractFunctionDecl>(getDecl())->requiresNewWitnessTableEntry();
|
||||||
}
|
|
||||||
|
|
||||||
bool SILDeclRef::requiresNewWitnessTableEntry(AbstractFunctionDecl *func) {
|
|
||||||
return func->getOverriddenDecls().empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SILDeclRef SILDeclRef::getOverridden() const {
|
SILDeclRef SILDeclRef::getOverridden() const {
|
||||||
|
|||||||
@@ -2864,7 +2864,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
|
|||||||
// entry.
|
// entry.
|
||||||
if (isa<ProtocolDecl>(property->getDeclContext())) {
|
if (isa<ProtocolDecl>(property->getDeclContext())) {
|
||||||
auto accessor = getRepresentativeAccessorForKeyPath(property);
|
auto accessor = getRepresentativeAccessorForKeyPath(property);
|
||||||
if (!SILDeclRef::requiresNewWitnessTableEntry(accessor)) {
|
if (!accessor->requiresNewWitnessTableEntry()) {
|
||||||
// Find the getter that does have a witness table entry.
|
// Find the getter that does have a witness table entry.
|
||||||
auto wtableAccessor =
|
auto wtableAccessor =
|
||||||
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(accessor));
|
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(accessor));
|
||||||
@@ -3027,7 +3027,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
|
|||||||
// entry.
|
// entry.
|
||||||
if (isa<ProtocolDecl>(property->getDeclContext())) {
|
if (isa<ProtocolDecl>(property->getDeclContext())) {
|
||||||
auto setter = property->getOpaqueAccessor(AccessorKind::Set);
|
auto setter = property->getOpaqueAccessor(AccessorKind::Set);
|
||||||
if (!SILDeclRef::requiresNewWitnessTableEntry(setter)) {
|
if (!setter->requiresNewWitnessTableEntry()) {
|
||||||
// Find the setter that does have a witness table entry.
|
// Find the setter that does have a witness table entry.
|
||||||
auto wtableSetter =
|
auto wtableSetter =
|
||||||
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(setter));
|
cast<AccessorDecl>(SILDeclRef::getOverriddenWitnessTableEntry(setter));
|
||||||
|
|||||||
Reference in New Issue
Block a user