Use VersionTuple to manage macosx versions in the driver. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152504 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index a457223..1eb7c9c 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -182,14 +182,10 @@
   if (!isTargetInitialized())
     return Triple.getTriple();
 
-  unsigned Version[3];
-  getTargetVersion(Version);
-
   SmallString<16> Str;
-  llvm::raw_svector_ostream(Str)
-    << (isTargetIPhoneOS() ? "ios" : "macosx")
-    << Version[0] << "." << Version[1] << "." << Version[2];
-  Triple.setOSName(Str.str());
+  Str += isTargetIPhoneOS() ? "ios" : "macosx";
+  Str += getTargetVersion().getAsString();
+  Triple.setOSName(Str);
 
   return Triple.getTriple();
 }
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index e894105..6665803 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -13,6 +13,7 @@
 #include "clang/Driver/Action.h"
 #include "clang/Driver/ToolChain.h"
 
+#include "clang/Basic/VersionTuple.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Compiler.h"
 
@@ -198,7 +199,7 @@
   mutable bool TargetIsIPhoneOSSimulator;
 
   /// The OS version we are targeting.
-  mutable unsigned TargetVersion[3];
+  mutable VersionTuple TargetVersion;
 
   /// The default macosx-version-min of this tool chain; empty until
   /// initialized.
@@ -230,17 +231,14 @@
     // change. This will go away when we move away from argument translation.
     if (TargetInitialized && TargetIsIPhoneOS == IsIPhoneOS &&
         TargetIsIPhoneOSSimulator == IsIOSSim &&
-        TargetVersion[0] == Major && TargetVersion[1] == Minor &&
-        TargetVersion[2] == Micro)
+        TargetVersion == VersionTuple(Major, Minor, Micro))
       return;
 
     assert(!TargetInitialized && "Target already initialized!");
     TargetInitialized = true;
     TargetIsIPhoneOS = IsIPhoneOS;
     TargetIsIPhoneOSSimulator = IsIOSSim;
-    TargetVersion[0] = Major;
-    TargetVersion[1] = Minor;
-    TargetVersion[2] = Micro;
+    TargetVersion = VersionTuple(Major, Minor, Micro);
   }
 
   bool isTargetIPhoneOS() const {
@@ -261,11 +259,9 @@
 
   bool isTargetInitialized() const { return TargetInitialized; }
 
-  void getTargetVersion(unsigned (&Res)[3]) const {
+  VersionTuple getTargetVersion() const {
     assert(TargetInitialized && "Target not initialized!");
-    Res[0] = TargetVersion[0];
-    Res[1] = TargetVersion[1];
-    Res[2] = TargetVersion[2];
+    return TargetVersion;
   }
 
   /// getDarwinArchName - Get the "Darwin" arch name for a particular compiler
@@ -273,24 +269,14 @@
   /// distinct architectures.
   StringRef getDarwinArchName(const ArgList &Args) const;
 
-  static bool isVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
-    for (unsigned i=0; i < 3; ++i) {
-      if (A[i] > B[i]) return false;
-      if (A[i] < B[i]) return true;
-    }
-    return false;
-  }
-
   bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
     assert(isTargetIPhoneOS() && "Unexpected call for OS X target!");
-    unsigned B[3] = { V0, V1, V2 };
-    return isVersionLT(TargetVersion, B);
+    return TargetVersion < VersionTuple(V0, V1, V2);
   }
 
   bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
     assert(!isTargetIPhoneOS() && "Unexpected call for iPhoneOS target!");
-    unsigned B[3] = { V0, V1, V2 };
-    return isVersionLT(TargetVersion, B);
+    return TargetVersion < VersionTuple(V0, V1, V2);
   }
 
   /// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs.
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 630b5d9..7d2002b 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -3852,8 +3852,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_init);
 
   // Add the deployment target.
-  unsigned TargetVersion[3];
-  DarwinTC.getTargetVersion(TargetVersion);
+  VersionTuple TargetVersion = DarwinTC.getTargetVersion();
 
   // If we had an explicit -mios-simulator-version-min argument, honor that,
   // otherwise use the traditional deployment targets. We can't just check the
@@ -3868,9 +3867,7 @@
     CmdArgs.push_back("-iphoneos_version_min");
   else
     CmdArgs.push_back("-macosx_version_min");
-  CmdArgs.push_back(Args.MakeArgString(Twine(TargetVersion[0]) + "." +
-                                       Twine(TargetVersion[1]) + "." +
-                                       Twine(TargetVersion[2])));
+  CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
 
   Args.AddLastArg(CmdArgs, options::OPT_nomultidefs);
   Args.AddLastArg(CmdArgs, options::OPT_multi__module);