From d84eaac673f0b7f45995233d58f58cb73d368ce0 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 9 May 2012 17:23:48 +0000 Subject: [PATCH] Add Triple::getiOSVersion. This new function provides a way to get the iOS version number from ios triples. Part of rdar://11409204 llvm-svn: 156483 --- llvm/include/llvm/ADT/Triple.h | 5 +++++ llvm/lib/Support/Triple.cpp | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index edbbdc51f69d..957c5819767a 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -196,6 +196,11 @@ public: bool getMacOSXVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const; + /// getiOSVersion - Parse the version number as with getOSVersion. This should + /// only be called with IOS triples. + void getiOSVersion(unsigned &Major, unsigned &Minor, + unsigned &Micro) const; + /// @} /// @name Direct Component Access /// @{ diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 4ee4716b37fb..2a22f7548062 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -596,6 +596,27 @@ bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor, return true; } +void Triple::getiOSVersion(unsigned &Major, unsigned &Minor, + unsigned &Micro) const { + switch (getOS()) { + default: llvm_unreachable("unexpected OS for Darwin triple"); + case Darwin: + case MacOSX: + // 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 iOS version number even when targeting + // OS X. + Major = 0; + Minor = 0; + Micro = 0; + return true; + case IOS: + getOSVersion(Major, Minor, Micro); + // Default to 0.0. + break; + } +} + void Triple::setTriple(const Twine &Str) { *this = Triple(Str); }