@@ -1801,42 +1801,35 @@ void swift::replaceLoadSequence(SILInstruction *inst, SILValue value) {
1801
1801
bool swift::calleesAreStaticallyKnowable (SILModule &module , SILDeclRef decl) {
1802
1802
if (decl.isForeign )
1803
1803
return false ;
1804
-
1805
- if (decl.isEnumElement ()) {
1806
- return calleesAreStaticallyKnowable (module ,
1807
- cast<EnumElementDecl>(decl.getDecl ()));
1808
- }
1809
-
1810
- auto *afd = decl.getAbstractFunctionDecl ();
1811
- assert (afd && " Expected abstract function decl!" );
1812
- return calleesAreStaticallyKnowable (module , afd);
1804
+ return calleesAreStaticallyKnowable (module , decl.getDecl ());
1813
1805
}
1814
1806
1815
1807
// / Are the callees that could be called through Decl statically
1816
1808
// / knowable based on the Decl and the compilation mode?
1817
- bool swift::calleesAreStaticallyKnowable (SILModule &module ,
1818
- AbstractFunctionDecl *afd) {
1809
+ bool swift::calleesAreStaticallyKnowable (SILModule &module , ValueDecl *vd) {
1810
+ assert (isa<AbstractFunctionDecl>(vd) || isa<EnumElementDecl>(vd));
1811
+
1819
1812
// Only handle members defined within the SILModule's associated context.
1820
- if (!afd ->isChildContextOf (module .getAssociatedContext ()))
1813
+ if (!cast<DeclContext>(vd) ->isChildContextOf (module .getAssociatedContext ()))
1821
1814
return false ;
1822
1815
1823
- if (afd ->isDynamic ()) {
1816
+ if (vd ->isDynamic ()) {
1824
1817
return false ;
1825
1818
}
1826
1819
1827
- if (!afd ->hasAccess ())
1820
+ if (!vd ->hasAccess ())
1828
1821
return false ;
1829
1822
1830
1823
// Only consider 'private' members, unless we are in whole-module compilation.
1831
- switch (afd ->getEffectiveAccess ()) {
1824
+ switch (vd ->getEffectiveAccess ()) {
1832
1825
case AccessLevel::Open:
1833
1826
return false ;
1834
1827
case AccessLevel::Public:
1835
- if (isa<ConstructorDecl>(afd )) {
1828
+ if (isa<ConstructorDecl>(vd )) {
1836
1829
// Constructors are special: a derived class in another module can
1837
1830
// "override" a constructor if its class is "open", although the
1838
1831
// constructor itself is not open.
1839
- auto *nd = afd ->getDeclContext ()->getSelfNominalTypeDecl ();
1832
+ auto *nd = vd ->getDeclContext ()->getSelfNominalTypeDecl ();
1840
1833
if (nd->getEffectiveAccess () == AccessLevel::Open)
1841
1834
return false ;
1842
1835
}
@@ -1851,37 +1844,6 @@ bool swift::calleesAreStaticallyKnowable(SILModule &module,
1851
1844
llvm_unreachable (" Unhandled access level in switch." );
1852
1845
}
1853
1846
1854
- // / Are the callees that could be called through Decl statically
1855
- // / knowable based on the Decl and the compilation mode?
1856
- // FIXME: Merge this with calleesAreStaticallyKnowable above
1857
- bool swift::calleesAreStaticallyKnowable (SILModule &module ,
1858
- EnumElementDecl *eed) {
1859
- // Only handle members defined within the SILModule's associated context.
1860
- if (!eed->isChildContextOf (module .getAssociatedContext ()))
1861
- return false ;
1862
-
1863
- if (eed->isDynamic ()) {
1864
- return false ;
1865
- }
1866
-
1867
- if (!eed->hasAccess ())
1868
- return false ;
1869
-
1870
- // Only consider 'private' members, unless we are in whole-module compilation.
1871
- switch (eed->getEffectiveAccess ()) {
1872
- case AccessLevel::Open:
1873
- return false ;
1874
- case AccessLevel::Public:
1875
- case AccessLevel::Internal:
1876
- return module .isWholeModule ();
1877
- case AccessLevel::FilePrivate:
1878
- case AccessLevel::Private:
1879
- return true ;
1880
- }
1881
-
1882
- llvm_unreachable (" Unhandled access level in switch." );
1883
- }
1884
-
1885
1847
Optional<FindLocalApplySitesResult>
1886
1848
swift::findLocalApplySites (FunctionRefBaseInst *fri) {
1887
1849
SmallVector<Operand *, 32 > worklist (fri->use_begin (), fri->use_end ());
0 commit comments