summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-04-19 20:30:10 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-04-19 20:30:10 +0000
commit0b654f4299e4460ee15511e0a1d8bcfeb4f67c63 (patch)
tree7ca4ae50507b48b937390fcc2745fb1428416474
parent78f5241504fd743b4cbd57e42f71e1a54a211346 (diff)
downloadbcm5719-llvm-0b654f4299e4460ee15511e0a1d8bcfeb4f67c63.tar.gz
bcm5719-llvm-0b654f4299e4460ee15511e0a1d8bcfeb4f67c63.zip
ADT/Triple: Add helper function for OS X version checks.
llvm-svn: 129801
-rw-r--r--llvm/include/llvm/ADT/Triple.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index ea5a6225df6..480c9316bd0 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -249,7 +249,8 @@ public:
return getOSMajorVersion();
}
- bool isOSVersionLT(unsigned Major, unsigned B_Minor, unsigned Micro) {
+ bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
+ unsigned Micro = 0) const {
unsigned LHS[3];
getOSVersion(LHS[0], LHS[1], LHS[2]);
@@ -263,6 +264,28 @@ public:
return false;
}
+ /// isOSX - Is this an OS X triple. For legacy reasons, we support both
+ /// "darwin" and "osx" as OS X triples.
+ bool isOSX() const {
+ return getOS() == Triple::Darwin || getOS() == Triple::OSX;
+ }
+
+ /// isOSXVersionLT - Comparison function for checking OS X version
+ /// compatibility, which handles supporting skewed version numbering schemes
+ /// used by the "darwin" triples.
+ unsigned isOSXVersionLT(unsigned Major, unsigned Minor = 0,
+ unsigned Micro = 0) const {
+ assert(isOSX() && "Not an OS X triple!");
+
+ // If this is OS X, expect a sane version number.
+ if (getOS() == Triple::OSX)
+ return isOSVersionLT(Major, Minor, Micro);
+
+ // Otherwise, compare to the "Darwin" number.
+ assert(Major == 10 && "Unexpected major version");
+ return isOSVersionLT(Minor + 4, Micro, 0);
+ }
+
/// @}
/// @name Mutators
/// @{
OpenPOWER on IntegriCloud