@@ -390,6 +390,13 @@ struct ASTContext::Implementation {
390
390
// / -> Builtin.Int1
391
391
FuncDecl *IsOSVersionAtLeastDecl = nullptr ;
392
392
393
+ // / func _stdlib_isOSVersionAtLeast_AEIC(
394
+ // / Builtin.Word,
395
+ // / Builtin.Word,
396
+ // / Builtin.word)
397
+ // / -> Builtin.Int1
398
+ FuncDecl *IsOSVersionAtLeastAEICDecl = nullptr ;
399
+
393
400
// / func _stdlib_isVariantOSVersionAtLeast(
394
401
// / Builtin.Word,
395
402
// / Builtin.Word,
@@ -1828,6 +1835,18 @@ ConstructorDecl *ASTContext::getMakeUTF8StringDecl() const {
1828
1835
}
1829
1836
1830
1837
FuncDecl *ASTContext::getIsOSVersionAtLeastDecl () const {
1838
+ // On iOS, the compiler should emit calls to the @_alwaysEmitIntoClient
1839
+ // variant of _stdlib_isOSVersionAtLeast because availability checks must
1840
+ // have the correct platform ID embedded in them in order for the binary to
1841
+ // be able to run correctly on other platforms (e.g. macOS).
1842
+ //
1843
+ // FIXME: This exception should be temporary. The @_alwaysEmitIntoClient
1844
+ // variant should be used consistently on all platforms in the future.
1845
+ if (LangOpts.Target .getOS () == llvm::Triple::IOS) {
1846
+ if (auto decl = getIsOSVersionAtLeastAEICDecl ())
1847
+ return decl;
1848
+ }
1849
+
1831
1850
if (getImpl ().IsOSVersionAtLeastDecl )
1832
1851
return getImpl ().IsOSVersionAtLeastDecl ;
1833
1852
@@ -1861,6 +1880,18 @@ FuncDecl *ASTContext::getIsOSVersionAtLeastDecl() const {
1861
1880
return decl;
1862
1881
}
1863
1882
1883
+ FuncDecl *ASTContext::getIsOSVersionAtLeastAEICDecl () const {
1884
+ if (getImpl ().IsOSVersionAtLeastAEICDecl )
1885
+ return getImpl ().IsOSVersionAtLeastAEICDecl ;
1886
+
1887
+ auto decl = findLibraryIntrinsic (*this , " _stdlib_isOSVersionAtLeast_AEIC" );
1888
+ if (!decl)
1889
+ return nullptr ;
1890
+
1891
+ getImpl ().IsOSVersionAtLeastAEICDecl = decl;
1892
+ return decl;
1893
+ }
1894
+
1864
1895
FuncDecl *ASTContext::getIsVariantOSVersionAtLeastDecl () const {
1865
1896
if (getImpl ().IsVariantOSVersionAtLeastDecl )
1866
1897
return getImpl ().IsVariantOSVersionAtLeastDecl ;
0 commit comments