ModuleInterface: sanitize long version numbers when collecting user versions from textual interface files

Some Swift module versions are beyond the scope of llvm::VersionTuple(), thus we need to sanitize the most
trivial bits so that we can handle most cases in versioned canImport query.
This commit is contained in:
Xi Ge
2021-09-22 22:29:16 -07:00
parent dac3e2b23e
commit c12ccde384
2 changed files with 5 additions and 1 deletions

View File

@@ -1067,6 +1067,10 @@ swift::extractUserModuleVersionFromInterface(StringRef moduleInterfacePath) {
// Check the version number specified via -user-module-version.
StringRef current(args[I]), next(args[I + 1]);
if (current == "-user-module-version") {
// Sanitize versions that are too long
while(next.count('.') > 3) {
next = next.rsplit('.').first;
}
result.tryParse(next);
break;
}