Skip to content

Commit 6a47315

Browse files
[clang-repl] Even more tests create the Interpreter and must check host JIT support (#84758)
1 parent 5a23d31 commit 6a47315

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

clang/unittests/Interpreter/CodeCompletionTest.cpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
#include "clang/Lex/Preprocessor.h"
55
#include "clang/Sema/CodeCompleteConsumer.h"
66
#include "clang/Sema/Sema.h"
7+
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
78
#include "llvm/LineEditor/LineEditor.h"
89
#include "llvm/Support/Error.h"
910
#include "llvm/Support/raw_ostream.h"
1011

1112
#include "gmock/gmock.h"
1213
#include "gtest/gtest.h"
1314

15+
#if defined(_AIX) || defined(__MVS__)
16+
#define CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
17+
#endif
18+
1419
using namespace clang;
1520
namespace {
1621
auto CB = clang::IncrementalCompilerBuilder();
@@ -50,7 +55,21 @@ static std::vector<std::string> runComp(clang::Interpreter &MainInterp,
5055
return Comps;
5156
}
5257

58+
static bool HostSupportsJit() {
59+
auto J = llvm::orc::LLJITBuilder().create();
60+
if (J)
61+
return true;
62+
LLVMConsumeError(llvm::wrap(J.takeError()));
63+
return false;
64+
}
65+
66+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
67+
TEST(CodeCompletionTest, DISABLED_Sanity) {
68+
#else
5369
TEST(CodeCompletionTest, Sanity) {
70+
#endif
71+
if (!HostSupportsJit())
72+
GTEST_SKIP();
5473
auto Interp = createInterpreter();
5574
cantFail(Interp->Parse("int foo = 12;"));
5675
auto Err = llvm::Error::success();
@@ -61,7 +80,13 @@ TEST(CodeCompletionTest, Sanity) {
6180
EXPECT_EQ((bool)Err, false);
6281
}
6382

83+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
84+
TEST(CodeCompletionTest, DISABLED_SanityNoneValid) {
85+
#else
6486
TEST(CodeCompletionTest, SanityNoneValid) {
87+
#endif
88+
if (!HostSupportsJit())
89+
GTEST_SKIP();
6590
auto Interp = createInterpreter();
6691
cantFail(Interp->Parse("int foo = 12;"));
6792
auto Err = llvm::Error::success();
@@ -70,7 +95,13 @@ TEST(CodeCompletionTest, SanityNoneValid) {
7095
EXPECT_EQ((bool)Err, false);
7196
}
7297

98+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
99+
TEST(CodeCompletionTest, DISABLED_TwoDecls) {
100+
#else
73101
TEST(CodeCompletionTest, TwoDecls) {
102+
#endif
103+
if (!HostSupportsJit())
104+
GTEST_SKIP();
74105
auto Interp = createInterpreter();
75106
cantFail(Interp->Parse("int application = 12;"));
76107
cantFail(Interp->Parse("int apple = 12;"));
@@ -80,14 +111,26 @@ TEST(CodeCompletionTest, TwoDecls) {
80111
EXPECT_EQ((bool)Err, false);
81112
}
82113

114+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
115+
TEST(CodeCompletionTest, DISABLED_CompFunDeclsNoError) {
116+
#else
83117
TEST(CodeCompletionTest, CompFunDeclsNoError) {
118+
#endif
119+
if (!HostSupportsJit())
120+
GTEST_SKIP();
84121
auto Interp = createInterpreter();
85122
auto Err = llvm::Error::success();
86123
auto comps = runComp(*Interp, "void app(", Err);
87124
EXPECT_EQ((bool)Err, false);
88125
}
89126

127+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
128+
TEST(CodeCompletionTest, DISABLED_TypedDirected) {
129+
#else
90130
TEST(CodeCompletionTest, TypedDirected) {
131+
#endif
132+
if (!HostSupportsJit())
133+
GTEST_SKIP();
91134
auto Interp = createInterpreter();
92135
cantFail(Interp->Parse("int application = 12;"));
93136
cantFail(Interp->Parse("char apple = '2';"));
@@ -119,7 +162,13 @@ TEST(CodeCompletionTest, TypedDirected) {
119162
}
120163
}
121164

165+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
166+
TEST(CodeCompletionTest, DISABLED_SanityClasses) {
167+
#else
122168
TEST(CodeCompletionTest, SanityClasses) {
169+
#endif
170+
if (!HostSupportsJit())
171+
GTEST_SKIP();
123172
auto Interp = createInterpreter();
124173
cantFail(Interp->Parse("struct Apple{};"));
125174
cantFail(Interp->Parse("void takeApple(Apple &a1){}"));
@@ -142,7 +191,13 @@ TEST(CodeCompletionTest, SanityClasses) {
142191
}
143192
}
144193

194+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
195+
TEST(CodeCompletionTest, DISABLED_SubClassing) {
196+
#else
145197
TEST(CodeCompletionTest, SubClassing) {
198+
#endif
199+
if (!HostSupportsJit())
200+
GTEST_SKIP();
146201
auto Interp = createInterpreter();
147202
cantFail(Interp->Parse("struct Fruit {};"));
148203
cantFail(Interp->Parse("struct Apple : Fruit{};"));
@@ -157,7 +212,13 @@ TEST(CodeCompletionTest, SubClassing) {
157212
EXPECT_EQ((bool)Err, false);
158213
}
159214

215+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
216+
TEST(CodeCompletionTest, DISABLED_MultipleArguments) {
217+
#else
160218
TEST(CodeCompletionTest, MultipleArguments) {
219+
#endif
220+
if (!HostSupportsJit())
221+
GTEST_SKIP();
161222
auto Interp = createInterpreter();
162223
cantFail(Interp->Parse("int foo = 42;"));
163224
cantFail(Interp->Parse("char fowl = 'A';"));
@@ -169,7 +230,13 @@ TEST(CodeCompletionTest, MultipleArguments) {
169230
EXPECT_EQ((bool)Err, false);
170231
}
171232

233+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
234+
TEST(CodeCompletionTest, DISABLED_Methods) {
235+
#else
172236
TEST(CodeCompletionTest, Methods) {
237+
#endif
238+
if (!HostSupportsJit())
239+
GTEST_SKIP();
173240
auto Interp = createInterpreter();
174241
cantFail(Interp->Parse(
175242
"struct Foo{int add(int a){return 42;} int par(int b){return 42;}};"));
@@ -183,7 +250,13 @@ TEST(CodeCompletionTest, Methods) {
183250
EXPECT_EQ((bool)Err, false);
184251
}
185252

253+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
254+
TEST(CodeCompletionTest, DISABLED_MethodsInvocations) {
255+
#else
186256
TEST(CodeCompletionTest, MethodsInvocations) {
257+
#endif
258+
if (!HostSupportsJit())
259+
GTEST_SKIP();
187260
auto Interp = createInterpreter();
188261
cantFail(Interp->Parse(
189262
"struct Foo{int add(int a){return 42;} int par(int b){return 42;}};"));
@@ -197,7 +270,13 @@ TEST(CodeCompletionTest, MethodsInvocations) {
197270
EXPECT_EQ((bool)Err, false);
198271
}
199272

273+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
274+
TEST(CodeCompletionTest, DISABLED_NestedInvocations) {
275+
#else
200276
TEST(CodeCompletionTest, NestedInvocations) {
277+
#endif
278+
if (!HostSupportsJit())
279+
GTEST_SKIP();
201280
auto Interp = createInterpreter();
202281
cantFail(Interp->Parse(
203282
"struct Foo{int add(int a){return 42;} int par(int b){return 42;}};"));
@@ -212,7 +291,13 @@ TEST(CodeCompletionTest, NestedInvocations) {
212291
EXPECT_EQ((bool)Err, false);
213292
}
214293

294+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
295+
TEST(CodeCompletionTest, DISABLED_TemplateFunctions) {
296+
#else
215297
TEST(CodeCompletionTest, TemplateFunctions) {
298+
#endif
299+
if (!HostSupportsJit())
300+
GTEST_SKIP();
216301
auto Interp = createInterpreter();
217302
cantFail(
218303
Interp->Parse("template <typename T> T id(T a) { return a;} "));

clang/unittests/Interpreter/IncrementalProcessingTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ TEST(IncrementalProcessing, DISABLED_EmitCXXGlobalInitFunc) {
6161
#else
6262
TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) {
6363
#endif
64+
if (!HostSupportsJit())
65+
GTEST_SKIP();
66+
6467
std::vector<const char *> ClangArgv = {"-Xclang", "-emit-llvm-only"};
6568
auto CB = clang::IncrementalCompilerBuilder();
6669
CB.SetCompilerArgs(ClangArgv);

0 commit comments

Comments
 (0)