summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/Triple.h
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-02-05 08:26:40 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-02-05 08:26:40 +0000
commit69f44692bf5fea1d908fc06487e173837d06ea58 (patch)
tree8ea11c4bc257394ee3f02d9ba456afa8c276bc02 /include/llvm/ADT/Triple.h
parent655b8de7b2ab773a977e0c524307e71354d8af29 (diff)
downloadllvm-69f44692bf5fea1d908fc06487e173837d06ea58.tar.gz
llvm-69f44692bf5fea1d908fc06487e173837d06ea58.tar.bz2
llvm-69f44692bf5fea1d908fc06487e173837d06ea58.tar.xz
Begin fleshing out more convenience predicates in llvm::Triple and
convert at least one client over to use them. Subsequent patches both to LLVM and Clang will try to convert more people over to a common set of predicates. This round of predicates is focused on OS-categorization predicates. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149815 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/Triple.h')
-rw-r--r--include/llvm/ADT/Triple.h48
1 files changed, 34 insertions, 14 deletions
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index eabb7c3f58..3a20aad386 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -284,6 +284,22 @@ public:
return false;
}
+ /// isMacOSXVersionLT - Comparison function for checking OS X version
+ /// compatibility, which handles supporting skewed version numbering schemes
+ /// used by the "darwin" triples.
+ unsigned isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
+ unsigned Micro = 0) const {
+ assert(isMacOSX() && "Not an OS X triple!");
+
+ // If this is OS X, expect a sane version number.
+ if (getOS() == Triple::MacOSX)
+ return isOSVersionLT(Major, Minor, Micro);
+
+ // Otherwise, compare to the "Darwin" number.
+ assert(Major == 10 && "Unexpected major version");
+ return isOSVersionLT(Minor + 4, Micro, 0);
+ }
+
/// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
/// "darwin" and "osx" as OS X triples.
bool isMacOSX() const {
@@ -295,26 +311,30 @@ public:
return isMacOSX() || getOS() == Triple::IOS;
}
+ /// \brief Tests for either Cygwin or MinGW OS
+ bool isOSCygMing() const {
+ return getOS() == Triple::Cygwin || getOS() == Triple::MinGW32;
+ }
+
/// isOSWindows - Is this a "Windows" OS.
bool isOSWindows() const {
- return getOS() == Triple::Win32 || getOS() == Triple::Cygwin ||
- getOS() == Triple::MinGW32;
+ return getOS() == Triple::Win32 || isOSCygMing();
}
- /// isMacOSXVersionLT - Comparison function for checking OS X version
- /// compatibility, which handles supporting skewed version numbering schemes
- /// used by the "darwin" triples.
- unsigned isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
- unsigned Micro = 0) const {
- assert(isMacOSX() && "Not an OS X triple!");
+ /// \brief Tests whether the OS uses the ELF binary format.
+ bool isOSBinFormatELF() const {
+ return !isOSDarwin() && !isOSWindows();
+ }
- // If this is OS X, expect a sane version number.
- if (getOS() == Triple::MacOSX)
- return isOSVersionLT(Major, Minor, Micro);
+ /// \brief Tests whether the OS uses the COFF binary format.
+ bool isOSBinFormatCOFF() const {
+ return isOSWindows();
+ }
- // Otherwise, compare to the "Darwin" number.
- assert(Major == 10 && "Unexpected major version");
- return isOSVersionLT(Minor + 4, Micro, 0);
+ /// \brief Tests whether the environment is MachO.
+ // FIXME: Should this be an OSBinFormat predicate?
+ bool isEnvironmentMachO() const {
+ return getEnvironment() == Triple::MachO || isOSDarwin();
}
/// @}