[llvm] r294073 - [Support] Simplify triple check in Host CPU test. NFC.

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 16:47:00 PST 2017


Author: ab
Date: Fri Feb  3 18:46:59 2017
New Revision: 294073

URL: http://llvm.org/viewvc/llvm-project?rev=294073&view=rev
Log:
[Support] Simplify triple check in Host CPU test. NFC.

Cleanup the check added in r293990 using the Triple helpers.

Modified:
    llvm/trunk/unittests/Support/Host.cpp

Modified: llvm/trunk/unittests/Support/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Host.cpp?rev=294073&r1=294072&r2=294073&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Host.cpp (original)
+++ llvm/trunk/unittests/Support/Host.cpp Fri Feb  3 18:46:59 2017
@@ -17,26 +17,17 @@ using namespace llvm;
 
 class HostTest : public testing::Test {
   Triple Host;
-  SmallVector<std::pair<Triple::ArchType, Triple::OSType>, 4> SupportedArchAndOSs;
 
 protected:
   bool isSupportedArchAndOS() {
-    if (is_contained(SupportedArchAndOSs, std::make_pair(Host.getArch(), Host.getOS())))
-      return true;
-
-    return false;
-  }
-
-  HostTest() {
-    Host.setTriple(Triple::normalize(sys::getProcessTriple()));
-
     // Initially this is only testing detection of the number of
     // physical cores, which is currently only supported/tested for
     // x86_64 Linux and Darwin.
-    SupportedArchAndOSs.push_back(std::make_pair(Triple::x86_64, Triple::Linux));
-    SupportedArchAndOSs.push_back(std::make_pair(Triple::x86_64, Triple::Darwin));
-    SupportedArchAndOSs.push_back(std::make_pair(Triple::x86_64, Triple::MacOSX));
+    return (Host.getArch() == Triple::x86_64 &&
+            (Host.isOSDarwin() || Host.getOS() == Triple::Linux));
   }
+
+  HostTest() : Host(Triple::normalize(sys::getProcessTriple())) {}
 };
 
 TEST_F(HostTest, NumPhysicalCores) {




More information about the llvm-commits mailing list