[TBDGen] Match TAPI's truncation behavior for dylib versions

TAPI and the linker truncate individual version components to 255 if
they overflow, because the linker packs 3 version components into a
32-bit int. Make sure we use the same parsing routines as TAPI.

Fixes rdar://57043178
This commit is contained in:
Harlan Haskins
2019-11-11 12:01:31 -08:00
parent da51a0eebf
commit 3745dcc3e4
6 changed files with 93 additions and 29 deletions

View File

@@ -961,16 +961,11 @@ static bool ParseTBDGenArgs(TBDGenOptions &Opts, ArgList &Args,
Opts.IsInstallAPI = Args.hasArg(OPT_tbd_is_installapi);
if (const Arg *A = Args.getLastArg(OPT_tbd_compatibility_version)) {
if (auto vers = version::Version::parseVersionString(
A->getValue(), SourceLoc(), &Diags)) {
Opts.CompatibilityVersion = *vers;
}
Opts.CompatibilityVersion = A->getValue();
}
if (const Arg *A = Args.getLastArg(OPT_tbd_current_version)) {
if (auto vers = version::Version::parseVersionString(
A->getValue(), SourceLoc(), &Diags)) {
Opts.CurrentVersion = *vers;
}
Opts.CurrentVersion = A->getValue();
}
return false;
}