@@ -58,18 +58,37 @@ Optional<PlatformKind> swift::platformFromString(StringRef Name) {
58
58
.Default (Optional<PlatformKind>());
59
59
}
60
60
61
+ static bool isApplicationExtensionPlatform (PlatformKind Platform) {
62
+ switch (Platform) {
63
+ case PlatformKind::macOSApplicationExtension:
64
+ case PlatformKind::iOSApplicationExtension:
65
+ case PlatformKind::macCatalystApplicationExtension:
66
+ case PlatformKind::tvOSApplicationExtension:
67
+ case PlatformKind::watchOSApplicationExtension:
68
+ return true ;
69
+ case PlatformKind::macOS:
70
+ case PlatformKind::iOS:
71
+ case PlatformKind::macCatalyst:
72
+ case PlatformKind::tvOS:
73
+ case PlatformKind::watchOS:
74
+ case PlatformKind::OpenBSD:
75
+ case PlatformKind::Windows:
76
+ case PlatformKind::none:
77
+ return false ;
78
+ }
79
+ llvm_unreachable (" bad PlatformKind" );
80
+ }
81
+
61
82
static bool isPlatformActiveForTarget (PlatformKind Platform,
62
83
const llvm::Triple &Target,
63
84
bool EnableAppExtensionRestrictions) {
64
85
if (Platform == PlatformKind::none)
65
86
return true ;
66
-
67
- if (Platform == PlatformKind::macOSApplicationExtension ||
68
- Platform == PlatformKind::iOSApplicationExtension ||
69
- Platform == PlatformKind::macCatalystApplicationExtension)
70
- if (!EnableAppExtensionRestrictions)
71
- return false ;
72
-
87
+
88
+ if (!EnableAppExtensionRestrictions &&
89
+ isApplicationExtensionPlatform (Platform))
90
+ return false ;
91
+
73
92
// FIXME: This is an awful way to get the current OS.
74
93
switch (Platform) {
75
94
case PlatformKind::macOS:
0 commit comments