@@ -56,35 +56,43 @@ Optional<PlatformKind> swift::platformFromString(StringRef Name) {
56
56
.Default (Optional<PlatformKind>());
57
57
}
58
58
59
- bool swift::isPlatformActive (PlatformKind Platform, LangOptions &LangOpts) {
59
+ static bool isPlatformActiveForTarget (PlatformKind Platform,
60
+ const llvm::Triple &Target,
61
+ bool EnableAppExtensionRestrictions) {
60
62
if (Platform == PlatformKind::none)
61
63
return true ;
62
64
63
65
if (Platform == PlatformKind::OSXApplicationExtension ||
64
66
Platform == PlatformKind::iOSApplicationExtension)
65
- if (!LangOpts. EnableAppExtensionRestrictions )
67
+ if (!EnableAppExtensionRestrictions)
66
68
return false ;
67
69
68
70
// FIXME: This is an awful way to get the current OS.
69
71
switch (Platform) {
70
72
case PlatformKind::OSX:
71
73
case PlatformKind::OSXApplicationExtension:
72
- return LangOpts. Target .isMacOSX ();
74
+ return Target.isMacOSX ();
73
75
case PlatformKind::iOS:
74
76
case PlatformKind::iOSApplicationExtension:
75
- return LangOpts. Target .isiOS () && !LangOpts. Target .isTvOS ();
77
+ return Target.isiOS () && !Target.isTvOS ();
76
78
case PlatformKind::tvOS:
77
79
case PlatformKind::tvOSApplicationExtension:
78
- return LangOpts. Target .isTvOS ();
80
+ return Target.isTvOS ();
79
81
case PlatformKind::watchOS:
80
82
case PlatformKind::watchOSApplicationExtension:
81
- return LangOpts. Target .isWatchOS ();
83
+ return Target.isWatchOS ();
82
84
case PlatformKind::none:
83
85
llvm_unreachable (" handled above" );
84
86
}
85
87
llvm_unreachable (" bad PlatformKind" );
86
88
}
87
89
90
+ bool swift::isPlatformActive (PlatformKind Platform, LangOptions &LangOpts) {
91
+ llvm::Triple TT = LangOpts.Target ;
92
+ return isPlatformActiveForTarget (Platform, TT,
93
+ LangOpts.EnableAppExtensionRestrictions );
94
+ }
95
+
88
96
PlatformKind swift::targetPlatform (LangOptions &LangOpts) {
89
97
if (LangOpts.Target .isMacOSX ()) {
90
98
return (LangOpts.EnableAppExtensionRestrictions
0 commit comments