Skip to content

Commit d73c2d5

Browse files
Fix unittest after #84460: only applicable if the platform supports JIT
1 parent 1a6ec90 commit d73c2d5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

clang/unittests/Interpreter/InterpreterExtensionsTest.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
#include "clang/Sema/Lookup.h"
1818
#include "clang/Sema/Sema.h"
1919

20+
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
2021
#include "llvm/Support/Error.h"
22+
#include "llvm/Support/TargetSelect.h"
2123
#include "llvm/Testing/Support/Error.h"
2224

2325
#include "gmock/gmock.h"
@@ -27,6 +29,22 @@
2729
using namespace clang;
2830
namespace {
2931

32+
static bool HostSupportsJit() {
33+
auto J = llvm::orc::LLJITBuilder().create();
34+
if (J)
35+
return true;
36+
LLVMConsumeError(llvm::wrap(J.takeError()));
37+
return false;
38+
}
39+
40+
struct LLVMInitRAII {
41+
LLVMInitRAII() {
42+
llvm::InitializeNativeTarget();
43+
llvm::InitializeNativeTargetAsmPrinter();
44+
}
45+
~LLVMInitRAII() { llvm::llvm_shutdown(); }
46+
} LLVMInit;
47+
3048
class TestCreateResetExecutor : public Interpreter {
3149
public:
3250
TestCreateResetExecutor(std::unique_ptr<CompilerInstance> CI,
@@ -39,6 +57,10 @@ class TestCreateResetExecutor : public Interpreter {
3957
};
4058

4159
TEST(InterpreterExtensionsTest, ExecutorCreateReset) {
60+
// Make sure we can create the executer on the platform.
61+
if (!HostSupportsJit())
62+
GTEST_SKIP();
63+
4264
clang::IncrementalCompilerBuilder CB;
4365
llvm::Error ErrOut = llvm::Error::success();
4466
TestCreateResetExecutor Interp(cantFail(CB.CreateCpp()), ErrOut);

0 commit comments

Comments
 (0)