[Orc] Require target support for host before running execution unit tests.
authorLang Hames <lhames@gmail.com>
Wed, 28 Oct 2015 20:08:51 +0000 (20:08 +0000)
committerLang Hames <lhames@gmail.com>
Wed, 28 Oct 2015 20:08:51 +0000 (20:08 +0000)
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

unittests/ExecutionEngine/Orc/OrcTestCommon.h

index 875db202a20e69cc01240f36716f9306de268a24..bfdaced05b14d9a50f8ad83eaf9321d3a028d11a 100644 (file)
@@ -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: