Skip to content

Commit 546bd6c

Browse files
authored
Merge pull request #13929 from slavapestov/is-less-visible-than-be-gone
SIL: Remove isLessVisibleThan()
2 parents 5a020ba + f8ceae8 commit 546bd6c

File tree

2 files changed

+8
-34
lines changed

2 files changed

+8
-34
lines changed

include/swift/SIL/SILLinkage.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -203,33 +203,6 @@ inline bool hasPrivateVisibility(SILLinkage linkage) {
203203
llvm_unreachable("Unhandled SILLinkage in switch.");
204204
}
205205

206-
/// Returns true if l1 is less visible than l2.
207-
inline bool isLessVisibleThan(SILLinkage l1, SILLinkage l2) {
208-
if (l1 == SILLinkage::PublicExternal)
209-
l1 = SILLinkage::Public;
210-
else if (l1 == SILLinkage::HiddenExternal)
211-
l1 = SILLinkage::Hidden;
212-
else if (l1 == SILLinkage::Shared)
213-
l1 = SILLinkage::Public;
214-
else if (l1 == SILLinkage::SharedExternal)
215-
l1 = SILLinkage::Public;
216-
else if (l1 == SILLinkage::PrivateExternal)
217-
l1 = SILLinkage::Private;
218-
219-
if (l2 == SILLinkage::PublicExternal)
220-
l2 = SILLinkage::Public;
221-
else if (l2 == SILLinkage::HiddenExternal)
222-
l2 = SILLinkage::Hidden;
223-
else if (l2 == SILLinkage::Shared)
224-
l2 = SILLinkage::Public;
225-
else if (l2 == SILLinkage::SharedExternal)
226-
l2 = SILLinkage::Public;
227-
else if (l2 == SILLinkage::PrivateExternal)
228-
l2 = SILLinkage::Private;
229-
230-
return unsigned(l1) > unsigned(l2);
231-
}
232-
233206
inline SILLinkage effectiveLinkageForClassMember(SILLinkage linkage,
234207
SubclassScope scope) {
235208
switch (scope) {

lib/SIL/SILVerifier.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4537,9 +4537,7 @@ void SILWitnessTable::verify(const SILModule &M) const {
45374537
// If a SILWitnessTable is going to be serialized, it must only
45384538
// reference public or serializable functions.
45394539
if (isSerialized()) {
4540-
assert((!isLessVisibleThan(F->getLinkage(), getLinkage()) ||
4541-
(F->isSerialized() &&
4542-
hasSharedVisibility(F->getLinkage()))) &&
4540+
assert(F->hasValidLinkageForFragileRef() &&
45434541
"Fragile witness tables should not reference "
45444542
"less visible functions.");
45454543
}
@@ -4566,15 +4564,18 @@ void SILDefaultWitnessTable::verify(const SILModule &M) const {
45664564
continue;
45674565

45684566
SILFunction *F = E.getWitness();
4569-
// FIXME
4570-
#if 0
4571-
assert(!isLessVisibleThan(F->getLinkage(), getLinkage()) &&
4567+
4568+
#if 0
4569+
// FIXME: For now, all default witnesses are private.
4570+
assert(F->hasValidLinkageForFragileRef() &&
45724571
"Default witness tables should not reference "
45734572
"less visible functions.");
4574-
#endif
4573+
#endif
4574+
45754575
assert(F->getLoweredFunctionType()->getRepresentation() ==
45764576
SILFunctionTypeRepresentation::WitnessMethod &&
45774577
"Default witnesses must have witness_method representation.");
4578+
45784579
auto *witnessSelfProtocol = F->getLoweredFunctionType()
45794580
->getDefaultWitnessMethodProtocol();
45804581
assert(witnessSelfProtocol == getProtocol() &&

0 commit comments

Comments
 (0)