@@ -1194,25 +1194,38 @@ void SILGenFunction::visitVarDecl(VarDecl *D) {
1194
1194
// We handle emitting the variable storage when we see the pattern binding.
1195
1195
}
1196
1196
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) {
1204
1202
unsigned major = Vers.getMajor ();
1205
1203
unsigned minor =
1206
1204
(Vers.getMinor ().hasValue () ? Vers.getMinor ().getValue () : 0 );
1207
1205
unsigned subminor =
1208
1206
(Vers.getSubminor ().hasValue () ? Vers.getSubminor ().getValue () : 0 );
1209
1207
1210
- SILType wordType = SILType::getBuiltinWordType (getASTContext () );
1208
+ SILType wordType = SILType::getBuiltinWordType (ctx );
1211
1209
1212
1210
SILValue majorValue = B.createIntegerLiteral (loc, wordType, major);
1213
1211
SILValue minorValue = B.createIntegerLiteral (loc, wordType, minor);
1214
1212
SILValue subminorValue = B.createIntegerLiteral (loc, wordType, subminor);
1215
1213
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
+
1216
1229
// Emit call to _stdlib_isOSVersionAtLeast(major, minor, patch)
1217
1230
FuncDecl *versionQueryDecl =
1218
1231
getASTContext ().getIsOSVersionAtLeastDecl ();
0 commit comments