]> granicus.if.org Git - llvm/commitdiff
[Triple] Define OS Check for Haiku
authorRenato Golin <renato.golin@linaro.org>
Fri, 18 Aug 2017 10:35:42 +0000 (10:35 +0000)
committerRenato Golin <renato.golin@linaro.org>
Fri, 18 Aug 2017 10:35:42 +0000 (10:35 +0000)
This adds the OS check for the Haiku operating system, as it was
missing in the Triple class. Tests for x86_64-unknown-haiku and
i586-pc-haiku were also added.

These patches only affect Haiku and are completely harmless for
other platforms.

Patch by Calvin Hill <calvin@hakobaito.co.uk>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311153 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/Triple.h
unittests/ADT/TripleTest.cpp

index c6e87deead354d70002f25cae545b0c941e937ab..a4cdeb89458d808e884308ab11fca53e81496294 100644 (file)
@@ -504,6 +504,11 @@ public:
     return getOS() == Triple::Contiki;
   }
 
+  /// Tests whether the OS is Haiku.
+  bool isOSHaiku() const {
+    return getOS() == Triple::Haiku;
+  }
+
   /// Checks if the environment could be MSVC.
   bool isWindowsMSVCEnvironment() const {
     return getOS() == Triple::Win32 &&
index 16732c9578d136a1c18dedbf080b8c6ac76ea74d..c16a332de0adad038f86621a09d9bc71107de226 100644 (file)
@@ -296,6 +296,18 @@ TEST(TripleTest, ParsedIDs) {
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
 
+  T = Triple("i586-pc-haiku");
+  EXPECT_EQ(Triple::x86, T.getArch());
+  EXPECT_EQ(Triple::PC, T.getVendor());
+  EXPECT_EQ(Triple::Haiku, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
+  T = Triple("x86_64-unknown-haiku");
+  EXPECT_EQ(Triple::x86_64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Haiku, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
   T = Triple("huh");
   EXPECT_EQ(Triple::UnknownArch, T.getArch());
 }