Skip to content

Commit 634435d

Browse files
committed
[gardening] Clean up SILWitnessTable::verify before I touch it.
I just renamed a few variables and eliminated a bunch of unnecessary indentation. Just to make it easier to review the actual functional change.
1 parent e25c664 commit 634435d

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7659,31 +7659,35 @@ void SILVTable::verify(const SILModule &M) const {
76597659
}
76607660

76617661
/// Verify that a witness table follows invariants.
7662-
void SILWitnessTable::verify(const SILModule &M) const {
7663-
if (!verificationEnabled(M))
7662+
void SILWitnessTable::verify(const SILModule &mod) const {
7663+
if (!verificationEnabled(mod))
76647664
return;
76657665

76667666
if (isDeclaration())
76677667
assert(getEntries().empty() &&
76687668
"A witness table declaration should not have any entries.");
76697669

7670-
for (const Entry &E : getEntries())
7671-
if (E.getKind() == SILWitnessTable::WitnessKind::Method) {
7672-
SILFunction *F = E.getMethodWitness().Witness;
7673-
if (F) {
7674-
// If a SILWitnessTable is going to be serialized, it must only
7675-
// reference public or serializable functions.
7676-
if (isAnySerialized()) {
7677-
assert(F->hasValidLinkageForFragileRef(getSerializedKind()) &&
7678-
"Fragile witness tables should not reference "
7679-
"less visible functions.");
7680-
}
7670+
for (const Entry &entry : getEntries()) {
7671+
if (entry.getKind() != SILWitnessTable::WitnessKind::Method)
7672+
continue;
76817673

7682-
assert(F->getLoweredFunctionType()->getRepresentation() ==
7683-
SILFunctionTypeRepresentation::WitnessMethod &&
7684-
"Witnesses must have witness_method representation.");
7685-
}
7674+
auto *witnessFunction = entry.getMethodWitness().Witness;
7675+
if (!witnessFunction)
7676+
continue;
7677+
7678+
// If a SILWitnessTable is going to be serialized, it must only
7679+
// reference public or serializable functions.
7680+
if (isAnySerialized()) {
7681+
assert(
7682+
witnessFunction->hasValidLinkageForFragileRef(getSerializedKind()) &&
7683+
"Fragile witness tables should not reference "
7684+
"less visible functions.");
76867685
}
7686+
7687+
assert(witnessFunction->getLoweredFunctionType()->getRepresentation() ==
7688+
SILFunctionTypeRepresentation::WitnessMethod &&
7689+
"Witnesses must have witness_method representation.");
7690+
}
76877691
}
76887692

76897693
/// Verify that a default witness table follows invariants.

0 commit comments

Comments
 (0)