Skip to content

Commit 4f387e3

Browse files
committed
[SILOpt] Use getEffectiveAccess instead of getFormalAccess.
Since this code has an isAvailableExternally check, this probably makes no difference, but it's still more correct: SIL-level code should always use a declaration's effective access.
1 parent 8887175 commit 4f387e3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/SILOptimizer/IPO/GlobalOpt.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,14 @@ static bool canBeChangedExternally(SILGlobalVariable *SILG) {
740740
// Use access specifiers from the declarations,
741741
// if possible.
742742
if (auto *Decl = SILG->getDecl()) {
743-
auto Access = Decl->getFormalAccess();
744-
if (Access == Accessibility::Private)
743+
switch (Decl->getEffectiveAccess()) {
744+
case Accessibility::Private:
745745
return false;
746-
if (Access == Accessibility::Internal &&
747-
SILG->getModule().isWholeModule())
748-
return false;
749-
return true;
746+
case Accessibility::Internal:
747+
return !SILG->getModule().isWholeModule();
748+
case Accessibility::Public:
749+
return true;
750+
}
750751
}
751752

752753
if (SILG->getLinkage() == SILLinkage::Private)

0 commit comments

Comments
 (0)