Skip to content

Commit f2c27df

Browse files
committed
Sema: Remove pruneMissingWitnesses()
1 parent 7c4708f commit f2c27df

File tree

1 file changed

+0
-101
lines changed

1 file changed

+0
-101
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,103 +3640,6 @@ static bool shouldRecordMissingWitness(
36403640
return true;
36413641
}
36423642

3643-
/// Prune the set of missing witnesses for the given conformance, eliminating
3644-
/// any requirements that do not actually need to satisfied.
3645-
static ArrayRef<ASTContext::MissingWitness> pruneMissingWitnesses(
3646-
ProtocolDecl *proto,
3647-
NormalProtocolConformance *conformance,
3648-
ArrayRef<ASTContext::MissingWitness> missingWitnesses,
3649-
SmallVectorImpl<ASTContext::MissingWitness> &scratch) {
3650-
if (missingWitnesses.empty()) {
3651-
return missingWitnesses;
3652-
}
3653-
3654-
ObjCRequirementMap map = getObjCRequirementMap(proto);
3655-
3656-
// Consider each of the missing witnesses to remove any that should not
3657-
// longer be considered "missing".
3658-
llvm::SmallDenseSet<ObjCMethodKey> alreadyReportedAsMissing;
3659-
bool removedAny = false;
3660-
for (unsigned missingWitnessIdx : indices(missingWitnesses)) {
3661-
const auto &missingWitness = missingWitnesses[missingWitnessIdx];
3662-
3663-
// Local function to skip this particular witness.
3664-
auto skipWitness = [&] {
3665-
if (removedAny) {
3666-
return;
3667-
}
3668-
3669-
// This is the first witness we skipped. Copy all of the earlier
3670-
// missing witnesses over.
3671-
scratch.clear();
3672-
scratch.append(
3673-
missingWitnesses.begin(),
3674-
missingWitnesses.begin() + missingWitnessIdx);
3675-
removedAny = true;
3676-
};
3677-
3678-
// Local function to add this particular witness.
3679-
auto addWitness = [&] {
3680-
if (removedAny)
3681-
scratch.push_back(missingWitness);
3682-
};
3683-
3684-
// We only care about functions.
3685-
if (!isa<AbstractFunctionDecl>(missingWitness.requirement)) {
3686-
addWitness();
3687-
continue;
3688-
}
3689-
3690-
// For an @objc protocol defined in Objective-C, the Clang importer might
3691-
// have imported the same underlying Objective-C declaration as more than
3692-
// one Swift declaration. Only one of those requirements should be witnessed
3693-
// so if the requirement sibling is witnessed then this requirement is not
3694-
// missing.
3695-
3696-
// Prune requirements that come from other protocols - we don't want to
3697-
// attempt to diagnose those here since we won't be able to find their
3698-
// siblings.
3699-
if (proto != missingWitness.requirement->getDeclContext()->getAsDecl()) {
3700-
skipWitness();
3701-
continue;
3702-
}
3703-
3704-
if (!proto->isObjC()) {
3705-
addWitness();
3706-
continue;
3707-
}
3708-
3709-
auto fnRequirement = cast<AbstractFunctionDecl>(missingWitness.requirement);
3710-
auto key = getObjCMethodKey(fnRequirement);
3711-
3712-
if (getObjCRequirementSibling(
3713-
proto, fnRequirement, map,
3714-
[conformance](AbstractFunctionDecl *candidate) {
3715-
return static_cast<bool>(conformance->getWitness(candidate));
3716-
})) {
3717-
skipWitness();
3718-
continue;
3719-
}
3720-
3721-
// If we have already reported a function with this selector as missing,
3722-
// don't do it again.
3723-
if (alreadyReportedAsMissing.count(key)) {
3724-
skipWitness();
3725-
continue;
3726-
}
3727-
3728-
// There is really a missing requirement for this witness.
3729-
alreadyReportedAsMissing.insert(key);
3730-
addWitness();
3731-
}
3732-
3733-
if (removedAny) {
3734-
return scratch;
3735-
}
3736-
3737-
return missingWitnesses;
3738-
}
3739-
37403643
static void diagnoseProtocolStubFixit(
37413644
NormalProtocolConformance *Conf,
37423645
llvm::SmallVector<ASTContext::MissingWitness, 4> MissingWitnesses) {
@@ -3853,10 +3756,6 @@ bool ConformanceChecker::
38533756
diagnoseMissingWitnesses(MissingWitnessDiagnosisKind Kind, bool Delayed) {
38543757
auto LocalMissing = getLocalMissingWitness();
38553758

3856-
SmallVector<ASTContext::MissingWitness, 4> MissingWitnessScratch;
3857-
LocalMissing = pruneMissingWitnesses(
3858-
Proto, Conformance, LocalMissing, MissingWitnessScratch);
3859-
38603759
// If this conformance has nothing to complain, return.
38613760
if (LocalMissing.empty())
38623761
return false;

0 commit comments

Comments
 (0)