From: Renato Golin Date: Fri, 18 Aug 2017 10:35:42 +0000 (+0000) Subject: [Triple] Define OS Check for Haiku X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aea1537f4d5c3670714cf21aba4762d072a94dbe;p=llvm [Triple] Define OS Check for Haiku 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311153 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index c6e87deead3..a4cdeb89458 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -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 && diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index 16732c9578d..c16a332de0a 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -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()); }