summaryrefslogtreecommitdiff
path: root/lib/Support/Triple.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2012-01-31 22:32:29 +0000
committerBob Wilson <bob.wilson@apple.com>2012-01-31 22:32:29 +0000
commitbda59fdd71033a8ddfa30ec4b514753017f3da5c (patch)
treeda934da5f8fe784ca9772a8f8d5b4c5a6cfeb9db /lib/Support/Triple.cpp
parented2d17b2d4ae20a83304357d6c84ed10e88bc036 (diff)
downloadllvm-bda59fdd71033a8ddfa30ec4b514753017f3da5c.tar.gz
llvm-bda59fdd71033a8ddfa30ec4b514753017f3da5c.tar.bz2
llvm-bda59fdd71033a8ddfa30ec4b514753017f3da5c.tar.xz
Add Triple::getMacOSXVersion to replace crufty code in the clang driver.
This new function provides a way to get the Mac OS X version number from either generic "darwin" triples of macosx triples. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149438 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Triple.cpp')
-rw-r--r--lib/Support/Triple.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
index d726fa300d..7433c0ae86 100644
--- a/lib/Support/Triple.cpp
+++ b/lib/Support/Triple.cpp
@@ -613,6 +613,45 @@ void Triple::getOSVersion(unsigned &Major, unsigned &Minor,
}
}
+bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
+ unsigned &Micro) const {
+ getOSVersion(Major, Minor, Micro);
+
+ switch (getOS()) {
+ default: assert(0 && "unexpected OS for Darwin triple");
+ case Darwin:
+ // Default to darwin8, i.e., MacOSX 10.4.
+ if (Major == 0)
+ Major = 8;
+ // Darwin version numbers are skewed from OS X versions.
+ if (Major < 4)
+ return false;
+ Micro = 0;
+ Minor = Major - 4;
+ Major = 10;
+ break;
+ case MacOSX:
+ // Default to 10.4.
+ if (Major == 0) {
+ Major = 10;
+ Minor = 4;
+ }
+ if (Major != 10)
+ return false;
+ break;
+ case IOS:
+ // Ignore the version from the triple. This is only handled because the
+ // 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.
+ Major = 10;
+ Minor = 4;
+ Micro = 0;
+ break;
+ }
+ return true;
+}
+
void Triple::setTriple(const Twine &Str) {
Data = Str.str();
Arch = InvalidArch;