1//===- unittests/Interpreter/InterpreterTestBase.h ------------------ C++ -===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
10#define LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
11
12#include "llvm/ExecutionEngine/Orc/LLJIT.h"
13#include "llvm/Support/Error.h"
14#include "llvm/Support/ManagedStatic.h"
15#include "llvm/Support/TargetSelect.h"
16
17#include "gtest/gtest.h"
18
19#if defined(_AIX) || defined(__MVS__)
20#define CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
21#endif
22
23namespace clang {
24
25class InterpreterTestBase : public ::testing::Test {
26protected:
27 static bool HostSupportsJIT() {
28#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
29 return false;
30#else
31 if (auto JIT = llvm::orc::LLJITBuilder().create()) {
32 return true;
33 } else {
34 llvm::consumeError(Err: JIT.takeError());
35 return false;
36 }
37#endif
38 }
39
40 void SetUp() override {
41 if (!HostSupportsJIT())
42 GTEST_SKIP();
43 }
44
45 void TearDown() override {}
46
47 static void SetUpTestSuite() {
48 llvm::InitializeNativeTarget();
49 llvm::InitializeNativeTargetAsmPrinter();
50 }
51
52 static void TearDownTestSuite() { llvm::llvm_shutdown(); }
53};
54
55} // namespace clang
56
57#undef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
58
59#endif // LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
60

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of clang/unittests/Interpreter/InterpreterTestFixture.h