Skip to content

Commit a8c699b

Browse files
committed
---
yaml --- r: 346699 b: refs/heads/master c: 25b9421 h: refs/heads/master i: 346697: c50f030 346695: 3eabf18
1 parent d979d7b commit a8c699b

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f29a23a918be9ec89697116b74070faabd963c15
2+
refs/heads/master: 25b9421d4396373356246df83c7a6b9b3cc5f87e
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/AST/PlatformKind.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,43 @@ Optional<PlatformKind> swift::platformFromString(StringRef Name) {
5656
.Default(Optional<PlatformKind>());
5757
}
5858

59-
bool swift::isPlatformActive(PlatformKind Platform, LangOptions &LangOpts) {
59+
static bool isPlatformActiveForTarget(PlatformKind Platform,
60+
const llvm::Triple &Target,
61+
bool EnableAppExtensionRestrictions) {
6062
if (Platform == PlatformKind::none)
6163
return true;
6264

6365
if (Platform == PlatformKind::OSXApplicationExtension ||
6466
Platform == PlatformKind::iOSApplicationExtension)
65-
if (!LangOpts.EnableAppExtensionRestrictions)
67+
if (!EnableAppExtensionRestrictions)
6668
return false;
6769

6870
// FIXME: This is an awful way to get the current OS.
6971
switch (Platform) {
7072
case PlatformKind::OSX:
7173
case PlatformKind::OSXApplicationExtension:
72-
return LangOpts.Target.isMacOSX();
74+
return Target.isMacOSX();
7375
case PlatformKind::iOS:
7476
case PlatformKind::iOSApplicationExtension:
75-
return LangOpts.Target.isiOS() && !LangOpts.Target.isTvOS();
77+
return Target.isiOS() && !Target.isTvOS();
7678
case PlatformKind::tvOS:
7779
case PlatformKind::tvOSApplicationExtension:
78-
return LangOpts.Target.isTvOS();
80+
return Target.isTvOS();
7981
case PlatformKind::watchOS:
8082
case PlatformKind::watchOSApplicationExtension:
81-
return LangOpts.Target.isWatchOS();
83+
return Target.isWatchOS();
8284
case PlatformKind::none:
8385
llvm_unreachable("handled above");
8486
}
8587
llvm_unreachable("bad PlatformKind");
8688
}
8789

90+
bool swift::isPlatformActive(PlatformKind Platform, LangOptions &LangOpts) {
91+
llvm::Triple TT = LangOpts.Target;
92+
return isPlatformActiveForTarget(Platform, TT,
93+
LangOpts.EnableAppExtensionRestrictions);
94+
}
95+
8896
PlatformKind swift::targetPlatform(LangOptions &LangOpts) {
8997
if (LangOpts.Target.isMacOSX()) {
9098
return (LangOpts.EnableAppExtensionRestrictions

trunk/lib/SILGen/SILGenDecl.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,25 +1194,38 @@ void SILGenFunction::visitVarDecl(VarDecl *D) {
11941194
// We handle emitting the variable storage when we see the pattern binding.
11951195
}
11961196

1197-
/// Emit a check that returns 1 if the running OS version is in
1198-
/// the specified version range and 0 otherwise. The returned SILValue
1199-
/// (which has type Builtin.Int1) represents the result of this check.
1200-
SILValue SILGenFunction::emitOSVersionRangeCheck(SILLocation loc,
1201-
const VersionRange &range) {
1202-
// Emit constants for the checked version range.
1203-
llvm::VersionTuple Vers = range.getLowerEndpoint();
1197+
/// Emit literals for the major, minor, and subminor components of the version
1198+
/// and return a tuple of SILValues for them.
1199+
static std::tuple<SILValue, SILValue, SILValue>
1200+
emitVersionLiterals(SILLocation loc, SILGenBuilder &B, ASTContext &ctx,
1201+
llvm::VersionTuple Vers) {
12041202
unsigned major = Vers.getMajor();
12051203
unsigned minor =
12061204
(Vers.getMinor().hasValue() ? Vers.getMinor().getValue() : 0);
12071205
unsigned subminor =
12081206
(Vers.getSubminor().hasValue() ? Vers.getSubminor().getValue() : 0);
12091207

1210-
SILType wordType = SILType::getBuiltinWordType(getASTContext());
1208+
SILType wordType = SILType::getBuiltinWordType(ctx);
12111209

12121210
SILValue majorValue = B.createIntegerLiteral(loc, wordType, major);
12131211
SILValue minorValue = B.createIntegerLiteral(loc, wordType, minor);
12141212
SILValue subminorValue = B.createIntegerLiteral(loc, wordType, subminor);
12151213

1214+
return std::make_tuple(majorValue, minorValue, subminorValue);
1215+
}
1216+
1217+
/// Emit a check that returns 1 if the running OS version is in
1218+
/// the specified version range and 0 otherwise. The returned SILValue
1219+
/// (which has type Builtin.Int1) represents the result of this check.
1220+
SILValue SILGenFunction::emitOSVersionRangeCheck(SILLocation loc,
1221+
const VersionRange &range) {
1222+
// Emit constants for the checked version range.
1223+
SILValue majorValue;
1224+
SILValue minorValue;
1225+
SILValue subminorValue;
1226+
std::tie(majorValue, minorValue, subminorValue) =
1227+
emitVersionLiterals(loc, B, getASTContext(), range.getLowerEndpoint());
1228+
12161229
// Emit call to _stdlib_isOSVersionAtLeast(major, minor, patch)
12171230
FuncDecl *versionQueryDecl =
12181231
getASTContext().getIsOSVersionAtLeastDecl();

0 commit comments

Comments
 (0)