[clang] 40d5eea - Revert "Use VersionTuple for parsing versions in Triple. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible."

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 30 09:36:43 PST 2021


Author: Nikita Popov
Date: 2021-11-30T18:36:32+01:00
New Revision: 40d5eeac6cd89a2360c3ba997cbaa816abca828c

URL: https://github.com/llvm/llvm-project/commit/40d5eeac6cd89a2360c3ba997cbaa816abca828c
DIFF: https://github.com/llvm/llvm-project/commit/40d5eeac6cd89a2360c3ba997cbaa816abca828c.diff

LOG: Revert "Use VersionTuple for parsing versions in Triple. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible."

This reverts commit 1e8286467036d8ef1a972de723f805a4981b2692.

llvm/test/Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll fails
with assertion failure:

llc: /home/nikic/llvm-project/llvm/include/llvm/ADT/Optional.h:196: T& llvm::optional_detail::OptionalStorage<T, true>::getValue() & [with T = unsigned int]: Assertion `hasVal' failed.
...
 #8 0x00005633843af5cb llvm::MCStreamer::emitVersionForTarget(llvm::Triple const&, llvm::VersionTuple const&)
 #9 0x0000563383b47f14 llvm::AsmPrinter::doInitialization(llvm::Module&)

Added: 
    

Modified: 
    clang/lib/ARCMigrate/ARCMT.cpp
    clang/lib/Basic/Targets/OSTargets.cpp
    clang/lib/Basic/Targets/OSTargets.h
    clang/lib/Basic/Targets/X86.h
    clang/lib/Driver/ToolChains/Darwin.cpp
    clang/lib/Driver/ToolChains/Linux.cpp
    clang/lib/Driver/ToolChains/MSVC.cpp
    clang/lib/Driver/ToolChains/NetBSD.cpp
    clang/test/Sema/attr-availability-android.c
    clang/test/Sema/attr-availability.c
    clang/test/Sema/availability-guard-format.mm
    clang/test/SemaObjC/attr-availability.m
    clang/test/SemaObjC/property-deprecated-warning.m
    clang/test/SemaObjC/unguarded-availability-maccatalyst.m
    clang/test/SemaObjC/unguarded-availability.m
    llvm/include/llvm/ADT/Triple.h
    llvm/lib/Analysis/TargetLibraryInfo.cpp
    llvm/lib/MC/MCStreamer.cpp
    llvm/lib/Support/Triple.cpp
    llvm/lib/Target/AArch64/AArch64Subtarget.cpp
    llvm/lib/Target/AArch64/AArch64Subtarget.h
    llvm/lib/Target/X86/X86Subtarget.h
    llvm/unittests/ADT/TripleTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index 68ee7c59270e0..4851c434d7652 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -162,7 +162,9 @@ static bool HasARCRuntime(CompilerInvocation &origCI) {
     return triple.getOSMajorVersion() >= 11;
 
   if (triple.getOS() == llvm::Triple::MacOSX) {
-    return triple.getOSVersion() >= VersionTuple(10, 7);
+    unsigned Major, Minor, Micro;
+    triple.getOSVersion(Major, Minor, Micro);
+    return Major > 10 || (Major == 10 && Minor >= 7);
   }
 
   return false;

diff  --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp
index a17c2238f05d5..4d9a462b51366 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -48,12 +48,12 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
     Builder.defineMacro("_REENTRANT");
 
   // Get the platform type and version number from the triple.
-  VersionTuple OsVersion;
+  unsigned Maj, Min, Rev;
   if (Triple.isMacOSX()) {
-    Triple.getMacOSXVersion(OsVersion);
+    Triple.getMacOSXVersion(Maj, Min, Rev);
     PlatformName = "macos";
   } else {
-    OsVersion = Triple.getOSVersion();
+    Triple.getOSVersion(Maj, Min, Rev);
     PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());
     if (PlatformName == "ios" && Triple.isMacCatalystEnvironment())
       PlatformName = "maccatalyst";
@@ -63,29 +63,29 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
   // generating code for Win32 ABI. No need to emit
   // __ENVIRONMENT_XX_OS_VERSION_MIN_REQUIRED__.
   if (PlatformName == "win32") {
-    PlatformMinVersion = OsVersion;
+    PlatformMinVersion = VersionTuple(Maj, Min, Rev);
     return;
   }
 
   // Set the appropriate OS version define.
   if (Triple.isiOS()) {
-    assert(OsVersion < VersionTuple(100) && "Invalid version!");
+    assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!");
     char Str[7];
-    if (OsVersion.getMajor() < 10) {
-      Str[0] = '0' + OsVersion.getMajor();
-      Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
-      Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
-      Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
-      Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+    if (Maj < 10) {
+      Str[0] = '0' + Maj;
+      Str[1] = '0' + (Min / 10);
+      Str[2] = '0' + (Min % 10);
+      Str[3] = '0' + (Rev / 10);
+      Str[4] = '0' + (Rev % 10);
       Str[5] = '\0';
     } else {
       // Handle versions >= 10.
-      Str[0] = '0' + (OsVersion.getMajor() / 10);
-      Str[1] = '0' + (OsVersion.getMajor() % 10);
-      Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
-      Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
-      Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
-      Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+      Str[0] = '0' + (Maj / 10);
+      Str[1] = '0' + (Maj % 10);
+      Str[2] = '0' + (Min / 10);
+      Str[3] = '0' + (Min % 10);
+      Str[4] = '0' + (Rev / 10);
+      Str[5] = '0' + (Rev % 10);
       Str[6] = '\0';
     }
     if (Triple.isTvOS())
@@ -95,13 +95,13 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
                           Str);
 
   } else if (Triple.isWatchOS()) {
-    assert(OsVersion < VersionTuple(10) && "Invalid version!");
+    assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!");
     char Str[6];
-    Str[0] = '0' + OsVersion.getMajor();
-    Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
-    Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
-    Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
-    Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+    Str[0] = '0' + Maj;
+    Str[1] = '0' + (Min / 10);
+    Str[2] = '0' + (Min % 10);
+    Str[3] = '0' + (Rev / 10);
+    Str[4] = '0' + (Rev % 10);
     Str[5] = '\0';
     Builder.defineMacro("__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__", Str);
   } else if (Triple.isMacOSX()) {
@@ -109,22 +109,22 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
     // define (because we only get a single digit for the minor and micro
     // revision numbers). So, we limit them to the maximum representable
     // version.
-    assert(OsVersion < VersionTuple(100) && "Invalid version!");
+    assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!");
     char Str[7];
-    if (OsVersion < VersionTuple(10, 10)) {
-      Str[0] = '0' + (OsVersion.getMajor() / 10);
-      Str[1] = '0' + (OsVersion.getMajor() % 10);
-      Str[2] = '0' + std::min(OsVersion.getMinor().getValueOr(0), 9U);
-      Str[3] = '0' + std::min(OsVersion.getSubminor().getValueOr(0), 9U);
+    if (Maj < 10 || (Maj == 10 && Min < 10)) {
+      Str[0] = '0' + (Maj / 10);
+      Str[1] = '0' + (Maj % 10);
+      Str[2] = '0' + std::min(Min, 9U);
+      Str[3] = '0' + std::min(Rev, 9U);
       Str[4] = '\0';
     } else {
       // Handle versions > 10.9.
-      Str[0] = '0' + (OsVersion.getMajor() / 10);
-      Str[1] = '0' + (OsVersion.getMajor() % 10);
-      Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
-      Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
-      Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
-      Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+      Str[0] = '0' + (Maj / 10);
+      Str[1] = '0' + (Maj % 10);
+      Str[2] = '0' + (Min / 10);
+      Str[3] = '0' + (Min % 10);
+      Str[4] = '0' + (Rev / 10);
+      Str[5] = '0' + (Rev % 10);
       Str[6] = '\0';
     }
     Builder.defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", Str);
@@ -134,7 +134,7 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
   if (Triple.isOSDarwin())
     Builder.defineMacro("__MACH__");
 
-  PlatformMinVersion = OsVersion;
+  PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 
 static void addMinGWDefines(const llvm::Triple &Triple, const LangOptions &Opts,

diff  --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 3c1830d5f8e89..7fbe2cbc56538 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -148,7 +148,9 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public OSTargetInfo<Target> {
       return 64;
     }
 
-    if (T.getOSVersion() < MinVersion)
+    unsigned Major, Minor, Micro;
+    T.getOSVersion(Major, Minor, Micro);
+    if (llvm::VersionTuple(Major, Minor, Micro) < MinVersion)
       return 64;
     return OSTargetInfo<Target>::getExnObjectAlignment();
   }
@@ -292,7 +294,7 @@ class LLVM_LIBRARY_VISIBILITY HaikuTargetInfo : public OSTargetInfo<Target> {
     Builder.defineMacro("__HAIKU__");
     Builder.defineMacro("__ELF__");
     DefineStd(Builder, "unix", Opts);
-    if (this->HasFloat128)
+    if (this->HasFloat128) 
       Builder.defineMacro("__FLOAT128__");
   }
 
@@ -374,9 +376,10 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo<Target> {
     Builder.defineMacro("__ELF__");
     if (Triple.isAndroid()) {
       Builder.defineMacro("__ANDROID__", "1");
+      unsigned Maj, Min, Rev;
+      Triple.getEnvironmentVersion(Maj, Min, Rev);
       this->PlatformName = "android";
-      this->PlatformMinVersion = Triple.getEnvironmentVersion();
-      const unsigned Maj = this->PlatformMinVersion.getMajor();
+      this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
       if (Maj) {
         Builder.defineMacro("__ANDROID_MIN_SDK_VERSION__", Twine(Maj));
         // This historical but ambiguous name for the minSdkVersion macro. Keep
@@ -690,32 +693,23 @@ class AIXTargetInfo : public OSTargetInfo<Target> {
     if (Opts.EnableAIXExtendedAltivecABI)
       Builder.defineMacro("__EXTABI__");
 
-    VersionTuple OsVersion = Triple.getOSVersion();
+    unsigned Major, Minor, Micro;
+    Triple.getOSVersion(Major, Minor, Micro);
 
     // Define AIX OS-Version Macros.
     // Includes logic for legacy versions of AIX; no specific intent to support.
-    if (OsVersion >= VersionTuple(3, 2))
-      Builder.defineMacro("_AIX32");
-    if (OsVersion >= VersionTuple(4, 1))
-      Builder.defineMacro("_AIX41");
-    if (OsVersion >= VersionTuple(4, 3))
-      Builder.defineMacro("_AIX43");
-    if (OsVersion >= VersionTuple(5, 0))
-      Builder.defineMacro("_AIX50");
-    if (OsVersion >= VersionTuple(5, 1))
-      Builder.defineMacro("_AIX51");
-    if (OsVersion >= VersionTuple(5, 2))
-      Builder.defineMacro("_AIX52");
-    if (OsVersion >= VersionTuple(5, 3))
-      Builder.defineMacro("_AIX53");
-    if (OsVersion >= VersionTuple(6, 1))
-      Builder.defineMacro("_AIX61");
-    if (OsVersion >= VersionTuple(7, 1))
-      Builder.defineMacro("_AIX71");
-    if (OsVersion >= VersionTuple(7, 2))
-      Builder.defineMacro("_AIX72");
-    if (OsVersion >= VersionTuple(7, 3))
-      Builder.defineMacro("_AIX73");
+    std::pair<int, int> OsVersion = {Major, Minor};
+    if (OsVersion >= std::make_pair(3, 2)) Builder.defineMacro("_AIX32");
+    if (OsVersion >= std::make_pair(4, 1)) Builder.defineMacro("_AIX41");
+    if (OsVersion >= std::make_pair(4, 3)) Builder.defineMacro("_AIX43");
+    if (OsVersion >= std::make_pair(5, 0)) Builder.defineMacro("_AIX50");
+    if (OsVersion >= std::make_pair(5, 1)) Builder.defineMacro("_AIX51");
+    if (OsVersion >= std::make_pair(5, 2)) Builder.defineMacro("_AIX52");
+    if (OsVersion >= std::make_pair(5, 3)) Builder.defineMacro("_AIX53");
+    if (OsVersion >= std::make_pair(6, 1)) Builder.defineMacro("_AIX61");
+    if (OsVersion >= std::make_pair(7, 1)) Builder.defineMacro("_AIX71");
+    if (OsVersion >= std::make_pair(7, 2)) Builder.defineMacro("_AIX72");
+    if (OsVersion >= std::make_pair(7, 3)) Builder.defineMacro("_AIX73");
 
     // FIXME: Do not define _LONG_LONG when -fno-long-long is specified.
     Builder.defineMacro("_LONG_LONG");

diff  --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 8626e44ce6e59..b9b2ac79815b0 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -472,9 +472,10 @@ class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo
       : NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
 
   unsigned getFloatEvalMethod() const override {
-    VersionTuple OsVersion = getTriple().getOSVersion();
+    unsigned Major, Minor, Micro;
+    getTriple().getOSVersion(Major, Minor, Micro);
     // New NetBSD uses the default rounding mode.
-    if (OsVersion >= VersionTuple(6, 99, 26) || OsVersion.getMajor() == 0)
+    if (Major >= 7 || (Major == 6 && Minor == 99 && Micro >= 26) || Major == 0)
       return X86_32TargetInfo::getFloatEvalMethod();
     // NetBSD before 6.99.26 defaults to "double" rounding.
     return 1;

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 25c0adf9ec0c2..06d3edc70e45f 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1412,8 +1412,8 @@ static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) {
   llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
   if (!SystemTriple.isMacOSX())
     return std::string(MacOSSDKVersion);
-  VersionTuple SystemVersion;
-  SystemTriple.getMacOSXVersion(SystemVersion);
+  SystemTriple.getMacOSXVersion(Major, Minor, Micro);
+  VersionTuple SystemVersion(Major, Minor, Micro);
   bool HadExtra;
   if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro,
                                  HadExtra))
@@ -1554,10 +1554,12 @@ struct DarwinPlatform {
                    const Optional<DarwinSDKInfo> &SDKInfo) {
     DarwinPlatform Result(TargetArg, getPlatformFromOS(TT.getOS()), OSVersion,
                           A);
-    VersionTuple OsVersion = TT.getOSVersion();
-    if (OsVersion.getMajor() == 0)
+    unsigned Major, Minor, Micro;
+    TT.getOSVersion(Major, Minor, Micro);
+    if (Major == 0)
       Result.HasOSVersion = false;
-    Result.setEnvironment(TT.getEnvironment(), OsVersion, SDKInfo);
+    Result.setEnvironment(TT.getEnvironment(),
+                          VersionTuple(Major, Minor, Micro), SDKInfo);
     return Result;
   }
   static DarwinPlatform
@@ -1803,7 +1805,7 @@ inferDeploymentTargetFromSDK(DerivedArgList &Args,
 
 std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
                          const Driver &TheDriver) {
-  VersionTuple OsVersion;
+  unsigned Major, Minor, Micro;
   llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
   switch (OS) {
   case llvm::Triple::Darwin:
@@ -1812,22 +1814,24 @@ std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
     // macos, use the host triple to infer OS version.
     if (Triple.isMacOSX() && SystemTriple.isMacOSX() &&
         !Triple.getOSMajorVersion())
-      SystemTriple.getMacOSXVersion(OsVersion);
-    else if (!Triple.getMacOSXVersion(OsVersion))
+      SystemTriple.getMacOSXVersion(Major, Minor, Micro);
+    else if (!Triple.getMacOSXVersion(Major, Minor, Micro))
       TheDriver.Diag(diag::err_drv_invalid_darwin_version)
           << Triple.getOSName();
     break;
   case llvm::Triple::IOS:
     if (Triple.isMacCatalystEnvironment() && !Triple.getOSMajorVersion()) {
-      OsVersion = VersionTuple(13, 1);
+      Major = 13;
+      Minor = 1;
+      Micro = 0;
     } else
-      OsVersion = Triple.getiOSVersion();
+      Triple.getiOSVersion(Major, Minor, Micro);
     break;
   case llvm::Triple::TvOS:
-    OsVersion = Triple.getOSVersion();
+    Triple.getOSVersion(Major, Minor, Micro);
     break;
   case llvm::Triple::WatchOS:
-    OsVersion = Triple.getWatchOSVersion();
+    Triple.getWatchOSVersion(Major, Minor, Micro);
     break;
   default:
     llvm_unreachable("Unexpected OS type");
@@ -1835,9 +1839,7 @@ std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
   }
 
   std::string OSVersion;
-  llvm::raw_string_ostream(OSVersion)
-      << OsVersion.getMajor() << '.' << OsVersion.getMinor().getValueOr(0)
-      << '.' << OsVersion.getSubminor().getValueOr(0);
+  llvm::raw_string_ostream(OSVersion) << Major << '.' << Minor << '.' << Micro;
   return OSVersion;
 }
 
@@ -1907,13 +1909,15 @@ getDeploymentTargetFromMTargetOSArg(DerivedArgList &Args,
     return None;
   }
 
-  VersionTuple Version = TT.getOSVersion();
-  if (!Version.getMajor()) {
+  unsigned Major, Minor, Micro;
+  TT.getOSVersion(Major, Minor, Micro);
+  if (!Major) {
     TheDriver.Diag(diag::err_drv_invalid_version_number)
         << A->getAsString(Args);
     return None;
   }
-  return DarwinPlatform::createFromMTargetOS(TT.getOS(), Version,
+  return DarwinPlatform::createFromMTargetOS(TT.getOS(),
+                                             VersionTuple(Major, Minor, Micro),
                                              TT.getEnvironment(), A, SDKInfo);
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 7494c2129211e..198774506e5e5 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -277,11 +277,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
     // Android sysroots contain a library directory for each supported OS
     // version as well as some unversioned libraries in the usual multiarch
     // directory.
-    addPathIfExists(
-        D,
-        SysRoot + "/usr/lib/" + MultiarchTriple + "/" +
-            llvm::to_string(Triple.getEnvironmentVersion().getMajor()),
-        Paths);
+    unsigned Major;
+    unsigned Minor;
+    unsigned Micro;
+    Triple.getEnvironmentVersion(Major, Minor, Micro);
+    addPathIfExists(D,
+                    SysRoot + "/usr/lib/" + MultiarchTriple + "/" +
+                        llvm::to_string(Major),
+                    Paths);
   }
 
   addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index 66e9d8ab525ac..792b0a51fea09 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1194,6 +1194,14 @@ bool MSVCToolChain::getUniversalCRTLibraryPath(const ArgList &Args,
   return true;
 }
 
+static VersionTuple getMSVCVersionFromTriple(const llvm::Triple &Triple) {
+  unsigned Major, Minor, Micro;
+  Triple.getEnvironmentVersion(Major, Minor, Micro);
+  if (Major || Minor || Micro)
+    return VersionTuple(Major, Minor, Micro);
+  return VersionTuple();
+}
+
 static VersionTuple getMSVCVersionFromExe(const std::string &BinDir) {
   VersionTuple Version;
 #ifdef _WIN32
@@ -1366,7 +1374,7 @@ VersionTuple MSVCToolChain::computeMSVCVersion(const Driver *D,
   bool IsWindowsMSVC = getTriple().isWindowsMSVCEnvironment();
   VersionTuple MSVT = ToolChain::computeMSVCVersion(D, Args);
   if (MSVT.empty())
-    MSVT = getTriple().getEnvironmentVersion();
+    MSVT = getMSVCVersionFromTriple(getTriple());
   if (MSVT.empty() && IsWindowsMSVC)
     MSVT = getMSVCVersionFromExe(getSubDirectoryPath(SubDirectoryType::Bin));
   if (MSVT.empty() &&

diff  --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 37b1fc5215ff5..7571398b7cc61 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -270,9 +270,10 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(Args.MakeArgString(ToolChain.getCompilerRTPath()));
   }
 
-  VersionTuple OsVersion = Triple.getOSVersion();
+  unsigned Major, Minor, Micro;
+  Triple.getOSVersion(Major, Minor, Micro);
   bool useLibgcc = true;
-  if (OsVersion >= VersionTuple(7) || OsVersion.getMajor() == 0) {
+  if (Major >= 7 || Major == 0) {
     switch (ToolChain.getArch()) {
     case llvm::Triple::aarch64:
     case llvm::Triple::aarch64_be:
@@ -408,8 +409,9 @@ Tool *NetBSD::buildAssembler() const {
 Tool *NetBSD::buildLinker() const { return new tools::netbsd::Linker(*this); }
 
 ToolChain::CXXStdlibType NetBSD::GetDefaultCXXStdlibType() const {
-  VersionTuple OsVersion = getTriple().getOSVersion();
-  if (OsVersion >= VersionTuple(7) || OsVersion.getMajor() == 0) {
+  unsigned Major, Minor, Micro;
+  getTriple().getOSVersion(Major, Minor, Micro);
+  if (Major >= 7 || Major == 0) {
     switch (getArch()) {
     case llvm::Triple::aarch64:
     case llvm::Triple::aarch64_be:
@@ -503,13 +505,14 @@ void NetBSD::addClangTargetOptions(const ArgList &DriverArgs,
   if (SanArgs.hasAnySanitizer())
     CC1Args.push_back("-D_REENTRANT");
 
-  VersionTuple OsVersion = getTriple().getOSVersion();
+  unsigned Major, Minor, Micro;
+  getTriple().getOSVersion(Major, Minor, Micro);
   bool UseInitArrayDefault =
-      OsVersion >= VersionTuple(9) || OsVersion.getMajor() == 0 ||
-      getTriple().getArch() == llvm::Triple::aarch64 ||
-      getTriple().getArch() == llvm::Triple::aarch64_be ||
-      getTriple().getArch() == llvm::Triple::arm ||
-      getTriple().getArch() == llvm::Triple::armeb;
+    Major >= 9 || Major == 0 ||
+    getTriple().getArch() == llvm::Triple::aarch64 ||
+    getTriple().getArch() == llvm::Triple::aarch64_be ||
+    getTriple().getArch() == llvm::Triple::arm ||
+    getTriple().getArch() == llvm::Triple::armeb;
 
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
                           options::OPT_fno_use_init_array, UseInitArrayDefault))

diff  --git a/clang/test/Sema/attr-availability-android.c b/clang/test/Sema/attr-availability-android.c
index 39638bc38c4a7..f38f71fbc7834 100644
--- a/clang/test/Sema/attr-availability-android.c
+++ b/clang/test/Sema/attr-availability-android.c
@@ -5,7 +5,7 @@ void f0(int) __attribute__((availability(android,introduced=14,deprecated=19)));
 void f1(int) __attribute__((availability(android,introduced=16)));
 void f2(int) __attribute__((availability(android,introduced=14,deprecated=16))); // expected-note {{'f2' has been explicitly marked deprecated here}}
 #ifdef WARN_PARTIAL
-// expected-note-re at +2 {{'f3' has been marked as being introduced in Android 19 here, but the deployment target is Android 16{{$}}}}
+// expected-note-re at +2 {{'f3' has been marked as being introduced in Android 19 here, but the deployment target is Android 16.0.0{{$}}}}
 #endif
 void f3(int) __attribute__((availability(android,introduced=19)));
 void f4(int) __attribute__((availability(android,introduced=9,deprecated=11,obsoleted=16), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}}

diff  --git a/clang/test/Sema/attr-availability.c b/clang/test/Sema/attr-availability.c
index b34d3d6b531b1..dbdf6593c3f7e 100644
--- a/clang/test/Sema/attr-availability.c
+++ b/clang/test/Sema/attr-availability.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
 // RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
-//
+// 
 
 void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}}
 void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0)));  // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
@@ -9,20 +9,20 @@ void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
 void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}}
 
 // rdar://10095131
-extern void
+extern void 
 ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' has been explicitly marked deprecated here}}
 
 extern void
 ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{'ATSFontGetPostScriptName' has been explicitly marked unavailable here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note at +3 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +3 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 extern void
 PartiallyAvailable() __attribute__((availability(macosx,introduced=10.8)));
 
 #ifdef WARN_PARTIAL
-// expected-note at +2 2 {{'PartialEnum' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +2 2 {{'PartialEnum' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 enum __attribute__((availability(macosx,introduced=10.8))) PartialEnum {
   kPartialEnumConstant,
@@ -41,7 +41,7 @@ void test_10095131() {
 #ifdef WARN_PARTIAL
 // FIXME: This note should point to the declaration with the availability
 // attribute.
-// expected-note at +2 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +2 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 extern void PartiallyAvailable() ;
 void with_redeclaration() {

diff  --git a/clang/test/Sema/availability-guard-format.mm b/clang/test/Sema/availability-guard-format.mm
index e5967d1082b9b..0e158c4173c2c 100644
--- a/clang/test/Sema/availability-guard-format.mm
+++ b/clang/test/Sema/availability-guard-format.mm
@@ -3,7 +3,7 @@
 // Testing that even for source code using '_' as a delimiter in availability version tuple '.' is actually used in diagnostic output as a delimiter.
 
 @interface foo
-- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); // expected-note {{'method_bar' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.11}}
+- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); // expected-note {{'method_bar' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.11.0}}
 @end
 
 int main() {

diff  --git a/clang/test/SemaObjC/attr-availability.m b/clang/test/SemaObjC/attr-availability.m
index e3f7a38f5889b..cb896150574ee 100644
--- a/clang/test/SemaObjC/attr-availability.m
+++ b/clang/test/SemaObjC/attr-availability.m
@@ -5,7 +5,7 @@ @protocol P
 - (void)proto_method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 2 {{'proto_method' has been explicitly marked deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note at +2 2 {{'partial_proto_method' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +2 2 {{'partial_proto_method' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 - (void)partial_proto_method __attribute__((availability(macosx,introduced=10.8)));
 @end
@@ -13,7 +13,7 @@ - (void)partial_proto_method __attribute__((availability(macosx,introduced=10.8)
 @interface A <P>
 - (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{'method' has been explicitly marked deprecated here}}
 #if defined(WARN_PARTIAL)
-// expected-note at +2 2 {{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +2 2 {{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 - (void)partialMethod __attribute__((availability(macosx,introduced=10.8)));
 
@@ -137,8 +137,8 @@ + (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8)));
 
 @interface PartialI <PartialProt>
 #ifdef WARN_PARTIAL
-// expected-note at +3{{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
-// expected-note at +3{{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +3{{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
+// expected-note at +3{{'partialMethod' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 - (void)partialMethod __attribute__((availability(macosx,introduced=10.8)));
 + (void)partialMethod __attribute__((availability(macosx,introduced=10.8)));
@@ -147,12 +147,12 @@ + (void)partialMethod __attribute__((availability(macosx,introduced=10.8)));
 @interface PartialI ()
 - (void)ipartialMethod1 __attribute__((availability(macosx,introduced=10.8)));
 #if defined(WARN_PARTIAL)
-// expected-note at +2 {{'ipartialMethod2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +2 {{'ipartialMethod2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 - (void)ipartialMethod2 __attribute__((availability(macosx,introduced=10.8)));
 + (void)ipartialMethod1 __attribute__((availability(macosx,introduced=10.8)));
 #if defined(WARN_PARTIAL)
-// expected-note at +2 {{'ipartialMethod2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +2 {{'ipartialMethod2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 + (void)ipartialMethod2 __attribute__((availability(macosx,introduced=10.8)));
 @end
@@ -190,7 +190,7 @@ void partialfun(PartialI* a) {
 }
 
 #if defined(WARN_PARTIAL)
-// expected-note at +2 2 {{'PartialI2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+// expected-note at +2 2 {{'PartialI2' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
 #endif
 __attribute__((availability(macosx, introduced = 10.8))) @interface PartialI2
 @end
@@ -222,7 +222,7 @@ void partialinter2(PartialI2* p) {
 void use_myEnum() {
   // expected-error at +2 {{'MyEnum' is unavailable: not available}}
   // expected-error at +1 {{MyEnum_Blah' is unavailable: not available}}
-  MyEnum e = MyEnum_Blah;
+  MyEnum e = MyEnum_Blah; 
 }
 
 // Test that the availability of (optional) protocol methods is not
@@ -313,8 +313,8 @@ -(void)method {
 #if defined(WARN_PARTIAL)
 
 int fn_10_5() __attribute__((availability(macosx, introduced=10.5)));
-int fn_10_7() __attribute__((availability(macosx, introduced=10.7))); // expected-note{{'fn_10_7' has been marked as being introduced in macOS 10.7 here, but the deployment target is macOS 10.5}}
-int fn_10_8() __attribute__((availability(macosx, introduced=10.8))) { // expected-note{{'fn_10_8' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}}
+int fn_10_7() __attribute__((availability(macosx, introduced=10.7))); // expected-note{{'fn_10_7' has been marked as being introduced in macOS 10.7 here, but the deployment target is macOS 10.5.0}}
+int fn_10_8() __attribute__((availability(macosx, introduced=10.8))) { // expected-note{{'fn_10_8' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5.0}}
   return fn_10_7();
 }
 

diff  --git a/clang/test/SemaObjC/property-deprecated-warning.m b/clang/test/SemaObjC/property-deprecated-warning.m
index 45e098baa891d..a1e971118b2c7 100644
--- a/clang/test/SemaObjC/property-deprecated-warning.m
+++ b/clang/test/SemaObjC/property-deprecated-warning.m
@@ -9,7 +9,7 @@ @protocol P
 @property(nonatomic,assign) id ptarget __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'ptarget' is declared deprecated here}} expected-note {{'ptarget' has been explicitly marked deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note at +2 {{'partialPtarget' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
+// expected-note at +2 {{'partialPtarget' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}}
 #endif
 @property(nonatomic,assign) id partialPtarget __attribute__((availability(ios,introduced=5.0)));
 @end
@@ -24,7 +24,7 @@ @interface UITableViewCell<P1>
 @property(nonatomic,assign) id target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'target' is declared deprecated here}} expected-note {{'setTarget:' has been explicitly marked deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note at +2 {{'setPartialTarget:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
+// expected-note at +2 {{'setPartialTarget:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}}
 #endif
 @property(nonatomic,assign) id partialTarget __attribute__((availability(ios,introduced=5.0)));
 @end
@@ -40,8 +40,8 @@ @interface UITableViewCell(UIDeprecated)
                                                                                     // expected-note 2 {{'setDep_target:' has been explicitly marked deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note at +3 2 {{'partial_dep_target' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
-// expected-note at +2 2 {{'setPartial_dep_target:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
+// expected-note at +3 2 {{'partial_dep_target' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}}
+// expected-note at +2 2 {{'setPartial_dep_target:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}}
 #endif
 @property(nonatomic,assign) id partial_dep_target  __attribute__((availability(ios,introduced=5.0)));
 @end
@@ -54,7 +54,7 @@ - (void) Meth {
   [self setTarget: (id)0]; // no-warning
   [self setDep_target: [self dep_target]]; // expected-warning {{'dep_target' is deprecated: first deprecated in iOS 3.0}} \
                                            // expected-warning {{'setDep_target:' is deprecated: first deprecated in iOS 3.0}}
-
+					   
   [self setPtarget: (id)0]; // no-warning
   [self setPartialTarget: (id)0]; // no-warning
 #if defined(WARN_PARTIAL)
@@ -101,12 +101,12 @@ @interface CustomAccessorNames
 @property(setter=setNewDelegate:,assign) id delegate __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'setNewDelegate:' has been explicitly marked deprecated here}} expected-note {{property 'delegate' is declared deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note at +2 {{'partialIsEnabled' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
+// expected-note at +2 {{'partialIsEnabled' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}}
 #endif
 @property(getter=partialIsEnabled,assign) BOOL partialEnabled __attribute__((availability(ios,introduced=5.0)));
 
 #if defined(WARN_PARTIAL)
-// expected-note at +2 {{'partialSetNewDelegate:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0}}
+// expected-note at +2 {{'partialSetNewDelegate:' has been marked as being introduced in iOS 5.0 here, but the deployment target is iOS 3.0.0}}
 #endif
 @property(setter=partialSetNewDelegate:,assign) id partialDelegate __attribute__((availability(ios,introduced=5.0)));
 @end

diff  --git a/clang/test/SemaObjC/unguarded-availability-maccatalyst.m b/clang/test/SemaObjC/unguarded-availability-maccatalyst.m
index 9d05a2ba99e55..590304dda505b 100644
--- a/clang/test/SemaObjC/unguarded-availability-maccatalyst.m
+++ b/clang/test/SemaObjC/unguarded-availability-maccatalyst.m
@@ -15,7 +15,7 @@
 void currentlyAvailable() AVAILABLE_CURRENT;
 void willBeAvailabile() AVAILABLE_NEXT;
 #ifndef NO_WARNING
-// expected-note at -2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
+// expected-note at -2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
 #endif
 
 
@@ -23,7 +23,7 @@
 
 } Record AVAILABLE_NEXT;
 #ifndef NO_WARNING
-// expected-note at -2 {{'Record' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
+// expected-note at -2 {{'Record' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
 #endif
 
 AVAILABLE_PREV
@@ -56,7 +56,7 @@ void test() {
 void currentlyAvailableIOS() __attribute__((availability(ios, introduced = 14)));
 void willBeAvailabileIOS() __attribute__((availability(ios, introduced = 14.1)));
 #ifndef NO_WARNING
-// expected-note at -2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
+// expected-note at -2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
 #endif
 
 void testIOSAvailabilityAlsoWorks() {
@@ -77,7 +77,7 @@ void testIOSAvailabilityAlsoWorks() {
 
 } Record2 __attribute__((availability(ios, introduced = 14.1)));
 #ifndef NO_WARNING
-// expected-note at -2 {{'Record2' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
+// expected-note at -2 {{'Record2' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14.0.0}}
 #endif
 
 __attribute__((availability(ios, introduced = 10)))

diff  --git a/clang/test/SemaObjC/unguarded-availability.m b/clang/test/SemaObjC/unguarded-availability.m
index dffad1dbe0f0f..0ee57301c3f54 100644
--- a/clang/test/SemaObjC/unguarded-availability.m
+++ b/clang/test/SemaObjC/unguarded-availability.m
@@ -5,14 +5,14 @@
 #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11)))
 #define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12)))
 
-typedef int AVAILABLE_10_12 new_int; // expected-note + {{'new_int' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+typedef int AVAILABLE_10_12 new_int; // expected-note + {{'new_int' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 
-int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9}}
+int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9.0}}
 
 #ifdef OBJCPP
-// expected-note at +2 6 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+// expected-note at +2 6 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 #endif
-int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 
 int func_10_0() AVAILABLE_10_0;
 
@@ -61,11 +61,11 @@ void star_case() {
   }
 }
 
-typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9}}
+typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9.0}}
 #ifdef OBJCPP
-// expected-note at +2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+// expected-note at +2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 #endif
-typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 
 void use_typedef() {
   int_10_11 x; // expected-warning{{'int_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'int_10_11' in an @available check to silence this warning}}
@@ -106,10 +106,10 @@ int protected_scope() {
 
 struct S {
   int m1;
-  int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+  int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 
   struct Nested {
-    int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{'nested_member' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+    int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{'nested_member' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
   } n;
 };
 
@@ -147,9 +147,9 @@ void test_blocks() {
 
 AVAILABLE_10_12
 __attribute__((objc_root_class))
- at interface InterWithProp // expected-note 2 {{'InterWithProp' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+ at interface InterWithProp // expected-note 2 {{'InterWithProp' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 @property(class) int x;
-+ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{'setX:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
++ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{'setX:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 @end
 void test_property(void) {
   int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}}
@@ -158,7 +158,7 @@ void test_property(void) {
 
 __attribute__((objc_root_class))
 @interface Subscriptable
-- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{'objectAtIndexedSubscript:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{'objectAtIndexedSubscript:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 @end
 
 void test_at(Subscriptable *x) {
@@ -204,7 +204,7 @@ int instantiate_template() {
 }
 
 template <class>
-int with_availability_attr() AVAILABLE_10_11 { // expected-note 2 {{'with_availability_attr<int>' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9}}
+int with_availability_attr() AVAILABLE_10_11 { // expected-note 2 {{'with_availability_attr<int>' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.9.0}}
   return 0;
 }
 
@@ -282,9 +282,9 @@ void f() {
 };
 
 #ifdef OBJCPP
-static constexpr int AVAILABLE_10_12 SomeConstexprValue = 2; // expected-note{{'SomeConstexprValue' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+static constexpr int AVAILABLE_10_12 SomeConstexprValue = 2; // expected-note{{'SomeConstexprValue' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 typedef enum { // expected-note{{annotate anonymous enum with an availability attribute}}
-  SomeValue = SomeConstexprValue // expected-warning{{'SomeConstexprValue' is only available on macOS 10.12 or newer}}
+  SomeValue = SomeConstexprValue // expected-warning{{'SomeConstexprValue' is only available on macOS 10.12 or newer}} 
 } SomeEnum;
 #endif
 
@@ -297,7 +297,7 @@ @interface Proper // expected-note{{annotate 'Proper' with an availability attri
 @end
 
 void with_local_struct() {
-  struct local {
+  struct local { 
     new_int x; // expected-warning{{'new_int' is only available}} expected-note{{enclose 'new_int' in an @available check}}
   };
   if (@available(macos 10.12, *)) {
@@ -311,7 +311,7 @@ void with_local_struct() {
 // Avoid the warning on protocol requirements.
 
 AVAILABLE_10_12
- at protocol NewProtocol // expected-note {{'NewProtocol' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+ at protocol NewProtocol // expected-note {{'NewProtocol' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 @end
 
 @protocol ProtocolWithNewProtocolRequirement <NewProtocol> // expected-note {{annotate 'ProtocolWithNewProtocolRequirement' with an availability attribute to silence}}
@@ -334,7 +334,7 @@ @interface BaseClass (CategoryWithNewProtocolRequirement) <NewProtocol>
 typedef enum {
   AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // expected-note 3 {{marked deprecated here}}
   AK_Cat __attribute__((availability(macos, introduced=10.4))),
-  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{'AK_CyborgCat' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9}}
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{'AK_CyborgCat' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.9.0}}
 } Animals;
 
 void switchAnimals(Animals a) {

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 5dbd4f16bfd5d..2fd3047acbfd8 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -10,7 +10,6 @@
 #define LLVM_ADT_TRIPLE_H
 
 #include "llvm/ADT/Twine.h"
-#include "llvm/Support/VersionTuple.h"
 
 // Some system headers or GCC predefined macros conflict with identifiers in
 // this file.  Undefine them here.
@@ -20,6 +19,8 @@
 
 namespace llvm {
 
+class VersionTuple;
+
 /// Triple - Helper class for working with autoconf configuration names. For
 /// historical reasons, we also call these 'triples' (they used to contain
 /// exactly three fields).
@@ -331,7 +332,10 @@ class Triple {
   /// triple, if present.
   ///
   /// For example, "fooos1.2.3" would return (1, 2, 3).
-  VersionTuple getEnvironmentVersion() const;
+  ///
+  /// If an entry is not defined, it will be returned as 0.
+  void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
+                             unsigned &Micro) const;
 
   /// Get the object format for this triple.
   ObjectFormatType getObjectFormat() const { return ObjectFormat; }
@@ -340,25 +344,34 @@ class Triple {
   /// present.
   ///
   /// For example, "fooos1.2.3" would return (1, 2, 3).
-  VersionTuple getOSVersion() const;
+  ///
+  /// If an entry is not defined, it will be returned as 0.
+  void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const;
 
   /// Return just the major version number, this is specialized because it is a
   /// common query.
-  unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
+  unsigned getOSMajorVersion() const {
+    unsigned Maj, Min, Micro;
+    getOSVersion(Maj, Min, Micro);
+    return Maj;
+  }
 
   /// Parse the version number as with getOSVersion and then translate generic
   /// "darwin" versions to the corresponding OS X versions.  This may also be
   /// called with IOS triples but the OS X version number is just set to a
   /// constant 10.4.0 in that case.  Returns true if successful.
-  bool getMacOSXVersion(VersionTuple &Version) const;
+  bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
+                        unsigned &Micro) const;
 
   /// Parse the version number as with getOSVersion.  This should only be called
   /// with IOS or generic triples.
-  VersionTuple getiOSVersion() const;
+  void getiOSVersion(unsigned &Major, unsigned &Minor,
+                     unsigned &Micro) const;
 
   /// Parse the version number as with getOSVersion.  This should only be called
   /// with WatchOS or generic triples.
-  VersionTuple getWatchOSVersion() const;
+  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
+                         unsigned &Micro) const;
 
   /// @}
   /// @name Direct Component Access
@@ -415,17 +428,23 @@ class Triple {
   /// the target triple.
   bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
                      unsigned Micro = 0) const {
-    if (Minor == 0) {
-      return getOSVersion() < VersionTuple(Major);
-    }
-    if (Micro == 0) {
-      return getOSVersion() < VersionTuple(Major, Minor);
-    }
-    return getOSVersion() < VersionTuple(Major, Minor, Micro);
+    unsigned LHS[3];
+    getOSVersion(LHS[0], LHS[1], LHS[2]);
+
+    if (LHS[0] != Major)
+      return LHS[0] < Major;
+    if (LHS[1] != Minor)
+      return LHS[1] < Minor;
+    if (LHS[2] != Micro)
+      return LHS[2] < Micro;
+
+    return false;
   }
 
   bool isOSVersionLT(const Triple &Other) const {
-    return getOSVersion() < Other.getOSVersion();
+    unsigned RHS[3];
+    Other.getOSVersion(RHS[0], RHS[1], RHS[2]);
+    return isOSVersionLT(RHS[0], RHS[1], RHS[2]);
   }
 
   /// Comparison function for checking OS X version compatibility, which handles
@@ -659,13 +678,14 @@ class Triple {
   bool isAndroidVersionLT(unsigned Major) const {
     assert(isAndroid() && "Not an Android triple!");
 
-    VersionTuple Version = getEnvironmentVersion();
+    unsigned Env[3];
+    getEnvironmentVersion(Env[0], Env[1], Env[2]);
 
     // 64-bit targets did not exist before API level 21 (Lollipop).
-    if (isArch64Bit() && Version.getMajor() < 21)
-      return VersionTuple(21) < VersionTuple(Major);
+    if (isArch64Bit() && Env[0] < 21)
+      Env[0] = 21;
 
-    return Version < VersionTuple(Major);
+    return Env[0] < Major;
   }
 
   /// Tests whether the environment is musl-libc

diff  --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 603fd4edecf8f..616ebc8f32655 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -230,8 +230,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
     // e.g., x86_64-pc-windows-msvc18.
     bool hasPartialC99 = true;
     if (T.isKnownWindowsMSVCEnvironment()) {
-      VersionTuple Version = T.getEnvironmentVersion();
-      hasPartialC99 = (Version.getMajor() == 0 || Version.getMajor() >= 19);
+      unsigned Major, Minor, Micro;
+      T.getEnvironmentVersion(Major, Minor, Micro);
+      hasPartialC99 = (Major == 0 || Major >= 19);
     }
 
     // Latest targets support C89 math functions, in part.

diff  --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 65d519be0e273..f4e64b42c817b 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1316,25 +1316,27 @@ void MCStreamer::emitVersionForTarget(const Triple &Target,
   if (Target.getOSMajorVersion() == 0)
     return;
 
-  VersionTuple Version;
+  unsigned Major = 0;
+  unsigned Minor = 0;
+  unsigned Update = 0;
   switch (Target.getOS()) {
   case Triple::MacOSX:
   case Triple::Darwin:
-    Target.getMacOSXVersion(Version);
+    Target.getMacOSXVersion(Major, Minor, Update);
     break;
   case Triple::IOS:
   case Triple::TvOS:
-    Version = Target.getiOSVersion();
+    Target.getiOSVersion(Major, Minor, Update);
     break;
   case Triple::WatchOS:
-    Version = Target.getWatchOSVersion();
+    Target.getWatchOSVersion(Major, Minor, Update);
     break;
   default:
     llvm_unreachable("unexpected OS type");
   }
-  assert(Version.getMajor() != 0 && "A non-zero major version is expected");
-  auto LinkedTargetVersion =
-      targetVersionOrMinimumSupportedOSVersion(Target, Version);
+  assert(Major != 0 && "A non-zero major version is expected");
+  auto LinkedTargetVersion = targetVersionOrMinimumSupportedOSVersion(
+      Target, VersionTuple(Major, Minor, Update));
   auto BuildVersionOSVersion = getMachoBuildVersionSupportedOS(Target);
   if (BuildVersionOSVersion.empty() ||
       LinkedTargetVersion >= BuildVersionOSVersion)

diff  --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 1b063f6c42146..b9a92e280576d 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -1091,22 +1091,53 @@ StringRef Triple::getOSAndEnvironmentName() const {
   return Tmp.split('-').second;                      // Strip second component
 }
 
-static VersionTuple parseVersionFromName(StringRef Name) {
-  VersionTuple Version;
-  Version.tryParse(Name);
-  return Version.withoutBuild();
+static unsigned EatNumber(StringRef &Str) {
+  assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
+  unsigned Result = 0;
+
+  do {
+    // Consume the leading digit.
+    Result = Result*10 + (Str[0] - '0');
+
+    // Eat the digit.
+    Str = Str.substr(1);
+  } while (!Str.empty() && isDigit(Str[0]));
+
+  return Result;
 }
 
-VersionTuple Triple::getEnvironmentVersion() const {
+static void parseVersionFromName(StringRef Name, unsigned &Major,
+                                 unsigned &Minor, unsigned &Micro) {
+  // Any unset version defaults to 0.
+  Major = Minor = Micro = 0;
+
+  // Parse up to three components.
+  unsigned *Components[3] = {&Major, &Minor, &Micro};
+  for (unsigned i = 0; i != 3; ++i) {
+    if (Name.empty() || Name[0] < '0' || Name[0] > '9')
+      break;
+
+    // Consume the leading number.
+    *Components[i] = EatNumber(Name);
+
+    // Consume the separator, if present.
+    if (Name.startswith("."))
+      Name = Name.substr(1);
+  }
+}
+
+void Triple::getEnvironmentVersion(unsigned &Major, unsigned &Minor,
+                                   unsigned &Micro) const {
   StringRef EnvironmentName = getEnvironmentName();
   StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
   if (EnvironmentName.startswith(EnvironmentTypeName))
     EnvironmentName = EnvironmentName.substr(EnvironmentTypeName.size());
 
-  return parseVersionFromName(EnvironmentName);
+  parseVersionFromName(EnvironmentName, Major, Minor, Micro);
 }
 
-VersionTuple Triple::getOSVersion() const {
+void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
+                          unsigned &Micro) const {
   StringRef OSName = getOSName();
   // Assume that the OS portion of the triple starts with the canonical name.
   StringRef OSTypeName = getOSTypeName(getOS());
@@ -1115,36 +1146,40 @@ VersionTuple Triple::getOSVersion() const {
   else if (getOS() == MacOSX)
     OSName.consume_front("macos");
 
-  return parseVersionFromName(OSName);
+  parseVersionFromName(OSName, Major, Minor, Micro);
 }
 
-bool Triple::getMacOSXVersion(VersionTuple &Version) const {
-  Version = getOSVersion();
+bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
+                              unsigned &Micro) const {
+  getOSVersion(Major, Minor, Micro);
 
   switch (getOS()) {
   default: llvm_unreachable("unexpected OS for Darwin triple");
   case Darwin:
     // Default to darwin8, i.e., MacOSX 10.4.
-    if (Version.getMajor() == 0)
-      Version = VersionTuple(8);
+    if (Major == 0)
+      Major = 8;
     // Darwin version numbers are skewed from OS X versions.
-    if (Version.getMajor() < 4) {
+    if (Major < 4)
       return false;
-    }
-    if (Version.getMajor() <= 19) {
-      Version = VersionTuple(10, Version.getMajor() - 4);
+    if (Major <= 19) {
+      Micro = 0;
+      Minor = Major - 4;
+      Major = 10;
     } else {
+      Micro = 0;
+      Minor = 0;
       // darwin20+ corresponds to macOS 11+.
-      Version = VersionTuple(11 + Version.getMajor() - 20);
+      Major = 11 + Major - 20;
     }
     break;
   case MacOSX:
     // Default to 10.4.
-    if (Version.getMajor() == 0) {
-      Version = VersionTuple(10, 4);
-    } else if (Version.getMajor() < 10) {
+    if (Major == 0) {
+      Major = 10;
+      Minor = 4;
+    } else if (Major < 10)
       return false;
-    }
     break;
   case IOS:
   case TvOS:
@@ -1153,13 +1188,16 @@ bool Triple::getMacOSXVersion(VersionTuple &Version) const {
     // the clang driver combines OS X and IOS support into a common Darwin
     // toolchain that wants to know the OS X version number even when targeting
     // IOS.
-    Version = VersionTuple(10, 4);
+    Major = 10;
+    Minor = 4;
+    Micro = 0;
     break;
   }
   return true;
 }
 
-VersionTuple Triple::getiOSVersion() const {
+void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
+                           unsigned &Micro) const {
   switch (getOS()) {
   default: llvm_unreachable("unexpected OS for Darwin triple");
   case Darwin:
@@ -1168,21 +1206,24 @@ VersionTuple Triple::getiOSVersion() const {
     // the clang driver combines OS X and IOS support into a common Darwin
     // toolchain that wants to know the iOS version number even when targeting
     // OS X.
-    return VersionTuple(5);
+    Major = 5;
+    Minor = 0;
+    Micro = 0;
+    break;
   case IOS:
-  case TvOS: {
-    VersionTuple Version = getOSVersion();
+  case TvOS:
+    getOSVersion(Major, Minor, Micro);
     // Default to 5.0 (or 7.0 for arm64).
-    if (Version.getMajor() == 0)
-      return (getArch() == aarch64) ? VersionTuple(7) : VersionTuple(5);
-    return Version;
-  }
+    if (Major == 0)
+      Major = (getArch() == aarch64) ? 7 : 5;
+    break;
   case WatchOS:
     llvm_unreachable("conflicting triple info");
   }
 }
 
-VersionTuple Triple::getWatchOSVersion() const {
+void Triple::getWatchOSVersion(unsigned &Major, unsigned &Minor,
+                               unsigned &Micro) const {
   switch (getOS()) {
   default: llvm_unreachable("unexpected OS for Darwin triple");
   case Darwin:
@@ -1191,13 +1232,15 @@ VersionTuple Triple::getWatchOSVersion() const {
     // the clang driver combines OS X and IOS support into a common Darwin
     // toolchain that wants to know the iOS version number even when targeting
     // OS X.
-    return VersionTuple(2);
-  case WatchOS: {
-    VersionTuple Version = getOSVersion();
-    if (Version.getMajor() == 0)
-      return VersionTuple(2);
-    return Version;
-  }
+    Major = 2;
+    Minor = 0;
+    Micro = 0;
+    break;
+  case WatchOS:
+    getOSVersion(Major, Minor, Micro);
+    if (Major == 0)
+      Major = 2;
+    break;
   case IOS:
     llvm_unreachable("conflicting triple info");
   }

diff  --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
index f7d3dd0bc2225..d782d6352cbe9 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -346,7 +346,9 @@ bool AArch64Subtarget::supportsAddressTopByteIgnored() const {
     return false;
 
   if (TargetTriple.isiOS()) {
-    return TargetTriple.getiOSVersion() >= VersionTuple(8);
+    unsigned Major, Minor, Micro;
+    TargetTriple.getiOSVersion(Major, Minor, Micro);
+    return Major >= 8;
   }
 
   return false;

diff  --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h b/llvm/lib/Target/AArch64/AArch64Subtarget.h
index cbc5f03280e51..19db774ccd7bd 100644
--- a/llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -632,7 +632,8 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
     // extended frames should be flagged as present.
     const Triple &TT = getTargetTriple();
 
-    unsigned Major = TT.getOSVersion().getMajor();
+    unsigned Major, Minor, Micro;
+    TT.getOSVersion(Major, Minor, Micro);
     switch(TT.getOS()) {
     default:
       return false;

diff  --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h
index 5d773f0c57dfb..9da54dc2e9b7a 100644
--- a/llvm/lib/Target/X86/X86Subtarget.h
+++ b/llvm/lib/Target/X86/X86Subtarget.h
@@ -958,7 +958,8 @@ class X86Subtarget final : public X86GenSubtargetInfo {
     // extended frames should be flagged as present.
     const Triple &TT = getTargetTriple();
 
-    unsigned Major = TT.getOSVersion().getMajor();
+    unsigned Major, Minor, Micro;
+    TT.getOSVersion(Major, Minor, Micro);
     switch(TT.getOS()) {
     default:
       return false;

diff  --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp
index 4853dfc13558b..a6a79ed5a39e9 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -117,18 +117,6 @@ TEST(TripleTest, ParsedIDs) {
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::MuslX32, T.getEnvironment());
 
-  T = Triple("arm-unknown-linux-android16");
-  EXPECT_EQ(Triple::arm, T.getArch());
-  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
-  EXPECT_EQ(Triple::Linux, T.getOS());
-  EXPECT_EQ(Triple::Android, T.getEnvironment());
-
-  T = Triple("aarch64-unknown-linux-android21");
-  EXPECT_EQ(Triple::aarch64, T.getArch());
-  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
-  EXPECT_EQ(Triple::Linux, T.getOS());
-  EXPECT_EQ(Triple::Android, T.getEnvironment());
-
   // PS4 has two spellings for the vendor.
   T = Triple("x86_64-scei-ps4");
   EXPECT_EQ(Triple::x86_64, T.getArch());
@@ -1273,7 +1261,7 @@ TEST(TripleTest, EndianArchVariants) {
 
 TEST(TripleTest, getOSVersion) {
   Triple T;
-  VersionTuple Version;
+  unsigned Major, Minor, Micro;
 
   T = Triple("i386-apple-darwin9");
   EXPECT_TRUE(T.isMacOSX());
@@ -1281,10 +1269,14 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(10, 5), Version);
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(5), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)5, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)5, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("x86_64-apple-darwin9");
   EXPECT_TRUE(T.isMacOSX());
@@ -1292,10 +1284,14 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(10, 5), Version);
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(5), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)5, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)5, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("x86_64-apple-macosx");
   EXPECT_TRUE(T.isMacOSX());
@@ -1303,10 +1299,14 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(10, 4), Version);
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(5), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)4, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)5, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("x86_64-apple-macosx10.7");
   EXPECT_TRUE(T.isMacOSX());
@@ -1314,10 +1314,14 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(10, 7), Version);
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(5), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)7, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)5, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("x86_64-apple-macos11.0");
   EXPECT_TRUE(T.isMacOSX());
@@ -1325,8 +1329,10 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(11, 0), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)11, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("arm64-apple-macosx11.5.8");
   EXPECT_TRUE(T.isMacOSX());
@@ -1334,26 +1340,34 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(11, 5, 8), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)11, Major);
+  EXPECT_EQ((unsigned)5, Minor);
+  EXPECT_EQ((unsigned)8, Micro);
 
   // 10.16 forms a valid triple, even though it's not
   // a version of a macOS.
   T = Triple("x86_64-apple-macos10.16");
   EXPECT_TRUE(T.isMacOSX());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(10, 16), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)16, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("x86_64-apple-darwin20");
   EXPECT_TRUE(T.isMacOSX());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(11), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)11, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   // For darwin triples on macOS 11, only compare the major version.
   T = Triple("x86_64-apple-darwin20.2");
   EXPECT_TRUE(T.isMacOSX());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(11), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)11, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("armv7-apple-ios");
   EXPECT_FALSE(T.isMacOSX());
@@ -1361,10 +1375,14 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(10, 4), Version);
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(5), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)4, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)5, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
 
   T = Triple("armv7-apple-ios7.0");
   EXPECT_FALSE(T.isMacOSX());
@@ -1372,45 +1390,36 @@ TEST(TripleTest, getOSVersion) {
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
   EXPECT_FALSE(T.isArch64Bit());
-  T.getMacOSXVersion(Version);
-  EXPECT_EQ(VersionTuple(10, 4), Version);
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(7, 0), Version);
+  T.getMacOSXVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)4, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)7, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
   EXPECT_FALSE(T.isSimulatorEnvironment());
 
   T = Triple("x86_64-apple-ios10.3-simulator");
   EXPECT_TRUE(T.isiOS());
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(10, 3), Version);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)10, Major);
+  EXPECT_EQ((unsigned)3, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
   EXPECT_TRUE(T.isSimulatorEnvironment());
   EXPECT_FALSE(T.isMacCatalystEnvironment());
 
   T = Triple("x86_64-apple-ios13.0-macabi");
   EXPECT_TRUE(T.isiOS());
-  Version = T.getiOSVersion();
-  EXPECT_EQ(VersionTuple(13, 0), Version);
+  T.getiOSVersion(Major, Minor, Micro);
+  EXPECT_EQ((unsigned)13, Major);
+  EXPECT_EQ((unsigned)0, Minor);
+  EXPECT_EQ((unsigned)0, Micro);
   EXPECT_TRUE(T.getEnvironment() == Triple::MacABI);
   EXPECT_TRUE(T.isMacCatalystEnvironment());
   EXPECT_FALSE(T.isSimulatorEnvironment());
 }
 
-TEST(TripleTest, getEnvironmentVersion) {
-  Triple T;
-  VersionTuple Version;
-
-  T = Triple("arm-unknown-linux-android16");
-  EXPECT_TRUE(T.isAndroid());
-  Version = T.getEnvironmentVersion();
-  EXPECT_EQ(VersionTuple(16), Version);
-  EXPECT_EQ(Triple::Android, T.getEnvironment());
-
-  T = Triple("aarch64-unknown-linux-android21");
-  EXPECT_TRUE(T.isAndroid());
-  Version = T.getEnvironmentVersion();
-  EXPECT_EQ(VersionTuple(21), Version);
-  EXPECT_EQ(Triple::Android, T.getEnvironment());
-}
-
 TEST(TripleTest, isMacOSVersionLT) {
   Triple T = Triple("x86_64-apple-macos11");
   EXPECT_TRUE(T.isMacOSXVersionLT(11, 1, 0));
@@ -1557,15 +1566,6 @@ TEST(TripleTest, NormalizeWindows) {
   EXPECT_TRUE(Triple("x86_64-pc-win32").isWindowsMSVCEnvironment());
 }
 
-TEST(TripleTest, NormalizeAndroid) {
-  EXPECT_EQ("arm-unknown-linux-android16",
-            Triple::normalize("arm-linux-androideabi16"));
-  EXPECT_EQ("armv7a-unknown-linux-android",
-            Triple::normalize("armv7a-linux-androideabi"));
-  EXPECT_EQ("aarch64-unknown-linux-android21",
-            Triple::normalize("aarch64-linux-android21"));
-}
-
 TEST(TripleTest, getARMCPUForArch) {
   // Platform specific defaults.
   {


        


More information about the cfe-commits mailing list