From: Lang Hames <lhames@gmail.com>
Date: Wed, 28 Oct 2015 20:08:51 +0000 (+0000)
Subject: [Orc] Require target support for host before running execution unit tests.
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79dc87fc1ed4270dcc72bf12aeb5aae9b9163041;p=llvm

[Orc] Require target support for host before running execution unit tests.

Orc unit tests that execute code shouldn't run if the compiler doesn't have
target support for the host machine.



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

diff --git a/unittests/ExecutionEngine/Orc/OrcTestCommon.h b/unittests/ExecutionEngine/Orc/OrcTestCommon.h
index 875db202a20..bfdaced05b1 100644
--- a/unittests/ExecutionEngine/Orc/OrcTestCommon.h
+++ b/unittests/ExecutionEngine/Orc/OrcTestCommon.h
@@ -44,12 +44,15 @@ public:
   std::unique_ptr<TargetMachine> getHostTargetMachineIfSupported() {
     std::unique_ptr<TargetMachine> TM(EngineBuilder().selectTarget());
 
+    if (!TM)
+      return nullptr;
+
     const Triple& TT = TM->getTargetTriple();
 
-    if (TT.getArch() == Triple::x86_64 && TT.isOSDarwin())
-      return TM;
+    if (TT.getArch() != Triple::x86_64 || !TT.isOSDarwin())
+      return nullptr;
 
-    return nullptr;
+    return TM;
   }
 
 private: