[clang] d73c2d5 - Fix unittest after #84460: only applicable if the platform supports JIT

Stefan Gränitz via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 15:17:33 PDT 2024


Author: Stefan Gränitz
Date: 2024-03-12T23:14:23+01:00
New Revision: d73c2d5df21735805a1f46a85790db64c0615e1c

URL: https://github.com/llvm/llvm-project/commit/d73c2d5df21735805a1f46a85790db64c0615e1c
DIFF: https://github.com/llvm/llvm-project/commit/d73c2d5df21735805a1f46a85790db64c0615e1c.diff

LOG: Fix unittest after #84460: only applicable if the platform supports JIT

Added: 
    

Modified: 
    clang/unittests/Interpreter/InterpreterExtensionsTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index f1c3d65ab0a95d..77fd1b4e19816c 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -17,7 +17,9 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
+#include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/TargetSelect.h"
 #include "llvm/Testing/Support/Error.h"
 
 #include "gmock/gmock.h"
@@ -27,6 +29,22 @@
 using namespace clang;
 namespace {
 
+static bool HostSupportsJit() {
+  auto J = llvm::orc::LLJITBuilder().create();
+  if (J)
+    return true;
+  LLVMConsumeError(llvm::wrap(J.takeError()));
+  return false;
+}
+
+struct LLVMInitRAII {
+  LLVMInitRAII() {
+    llvm::InitializeNativeTarget();
+    llvm::InitializeNativeTargetAsmPrinter();
+  }
+  ~LLVMInitRAII() { llvm::llvm_shutdown(); }
+} LLVMInit;
+
 class TestCreateResetExecutor : public Interpreter {
 public:
   TestCreateResetExecutor(std::unique_ptr<CompilerInstance> CI,
@@ -39,6 +57,10 @@ class TestCreateResetExecutor : public Interpreter {
 };
 
 TEST(InterpreterExtensionsTest, ExecutorCreateReset) {
+  // Make sure we can create the executer on the platform.
+  if (!HostSupportsJit())
+    GTEST_SKIP();
+
   clang::IncrementalCompilerBuilder CB;
   llvm::Error ErrOut = llvm::Error::success();
   TestCreateResetExecutor Interp(cantFail(CB.CreateCpp()), ErrOut);


        


More information about the cfe-commits mailing list