[llvm-commits] [llvm] r129801 - /llvm/trunk/include/llvm/ADT/Triple.h
Daniel Dunbar
daniel at zuster.org
Tue Apr 19 13:30:10 PDT 2011
Author: ddunbar
Date: Tue Apr 19 15:30:10 2011
New Revision: 129801
URL: http://llvm.org/viewvc/llvm-project?rev=129801&view=rev
Log:
ADT/Triple: Add helper function for OS X version checks.
Modified:
llvm/trunk/include/llvm/ADT/Triple.h
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=129801&r1=129800&r2=129801&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Tue Apr 19 15:30:10 2011
@@ -249,7 +249,8 @@
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 @@
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
/// @{
More information about the llvm-commits
mailing list