@@ -1201,11 +1201,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
1201
1201
A->getAsString (Args), A->getValue ());
1202
1202
}
1203
1203
}
1204
-
1205
- // Autolink runtime compatibility libraries, if asked to.
1206
- if (!Args.hasArg (options::OPT_disable_autolinking_runtime_compatibility)) {
1204
+
1205
+ auto getRuntimeCompatVersion = [&] () -> Optional<llvm::VersionTuple> {
1207
1206
Optional<llvm::VersionTuple> runtimeCompatibilityVersion;
1208
-
1209
1207
if (auto versionArg = Args.getLastArg (
1210
1208
options::OPT_runtime_compatibility_version)) {
1211
1209
auto version = StringRef (versionArg->getValue ());
@@ -1221,31 +1219,18 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
1221
1219
runtimeCompatibilityVersion =
1222
1220
getSwiftRuntimeCompatibilityVersionForTarget (Triple);
1223
1221
}
1224
-
1225
- Opts.AutolinkRuntimeCompatibilityLibraryVersion =
1226
- runtimeCompatibilityVersion;
1222
+ return runtimeCompatibilityVersion;
1223
+ };
1224
+
1225
+ // Autolink runtime compatibility libraries, if asked to.
1226
+ if (!Args.hasArg (options::OPT_disable_autolinking_runtime_compatibility)) {
1227
+ Opts.AutolinkRuntimeCompatibilityLibraryVersion = getRuntimeCompatVersion ();
1227
1228
}
1228
1229
1229
1230
if (!Args.hasArg (options::
1230
1231
OPT_disable_autolinking_runtime_compatibility_dynamic_replacements)) {
1231
- Optional<llvm::VersionTuple> runtimeCompatibilityVersion;
1232
- if (auto versionArg =
1233
- Args.getLastArg (options::OPT_runtime_compatibility_version)) {
1234
- auto version = StringRef (versionArg->getValue ());
1235
- if (version.equals (" none" )) {
1236
- runtimeCompatibilityVersion = None;
1237
- } else if (version.equals (" 5.0" )) {
1238
- runtimeCompatibilityVersion = llvm::VersionTuple (5 , 0 );
1239
- } else {
1240
- Diags.diagnose (SourceLoc (), diag::error_invalid_arg_value,
1241
- versionArg->getAsString (Args), version);
1242
- }
1243
- } else {
1244
- runtimeCompatibilityVersion =
1245
- getSwiftRuntimeCompatibilityVersionForTarget (Triple);
1246
- }
1247
1232
Opts.AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion =
1248
- runtimeCompatibilityVersion ;
1233
+ getRuntimeCompatVersion () ;
1249
1234
}
1250
1235
return false ;
1251
1236
}
0 commit comments