4
4
#include " clang/Lex/Preprocessor.h"
5
5
#include " clang/Sema/CodeCompleteConsumer.h"
6
6
#include " clang/Sema/Sema.h"
7
+ #include " llvm/ExecutionEngine/Orc/LLJIT.h"
7
8
#include " llvm/LineEditor/LineEditor.h"
8
9
#include " llvm/Support/Error.h"
9
10
#include " llvm/Support/raw_ostream.h"
10
11
11
12
#include " gmock/gmock.h"
12
13
#include " gtest/gtest.h"
13
14
15
+ #if defined(_AIX) || defined(__MVS__)
16
+ #define CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
17
+ #endif
18
+
14
19
using namespace clang ;
15
20
namespace {
16
21
auto CB = clang::IncrementalCompilerBuilder();
@@ -50,7 +55,21 @@ static std::vector<std::string> runComp(clang::Interpreter &MainInterp,
50
55
return Comps;
51
56
}
52
57
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
53
69
TEST (CodeCompletionTest, Sanity) {
70
+ #endif
71
+ if (!HostSupportsJit ())
72
+ GTEST_SKIP ();
54
73
auto Interp = createInterpreter ();
55
74
cantFail (Interp->Parse (" int foo = 12;" ));
56
75
auto Err = llvm::Error::success ();
@@ -61,7 +80,13 @@ TEST(CodeCompletionTest, Sanity) {
61
80
EXPECT_EQ ((bool )Err, false );
62
81
}
63
82
83
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
84
+ TEST (CodeCompletionTest, DISABLED_SanityNoneValid) {
85
+ #else
64
86
TEST (CodeCompletionTest, SanityNoneValid) {
87
+ #endif
88
+ if (!HostSupportsJit ())
89
+ GTEST_SKIP ();
65
90
auto Interp = createInterpreter ();
66
91
cantFail (Interp->Parse (" int foo = 12;" ));
67
92
auto Err = llvm::Error::success ();
@@ -70,7 +95,13 @@ TEST(CodeCompletionTest, SanityNoneValid) {
70
95
EXPECT_EQ ((bool )Err, false );
71
96
}
72
97
98
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
99
+ TEST (CodeCompletionTest, DISABLED_TwoDecls) {
100
+ #else
73
101
TEST (CodeCompletionTest, TwoDecls) {
102
+ #endif
103
+ if (!HostSupportsJit ())
104
+ GTEST_SKIP ();
74
105
auto Interp = createInterpreter ();
75
106
cantFail (Interp->Parse (" int application = 12;" ));
76
107
cantFail (Interp->Parse (" int apple = 12;" ));
@@ -80,14 +111,26 @@ TEST(CodeCompletionTest, TwoDecls) {
80
111
EXPECT_EQ ((bool )Err, false );
81
112
}
82
113
114
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
115
+ TEST (CodeCompletionTest, DISABLED_CompFunDeclsNoError) {
116
+ #else
83
117
TEST (CodeCompletionTest, CompFunDeclsNoError) {
118
+ #endif
119
+ if (!HostSupportsJit ())
120
+ GTEST_SKIP ();
84
121
auto Interp = createInterpreter ();
85
122
auto Err = llvm::Error::success ();
86
123
auto comps = runComp (*Interp, " void app(" , Err);
87
124
EXPECT_EQ ((bool )Err, false );
88
125
}
89
126
127
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
128
+ TEST (CodeCompletionTest, DISABLED_TypedDirected) {
129
+ #else
90
130
TEST (CodeCompletionTest, TypedDirected) {
131
+ #endif
132
+ if (!HostSupportsJit ())
133
+ GTEST_SKIP ();
91
134
auto Interp = createInterpreter ();
92
135
cantFail (Interp->Parse (" int application = 12;" ));
93
136
cantFail (Interp->Parse (" char apple = '2';" ));
@@ -119,7 +162,13 @@ TEST(CodeCompletionTest, TypedDirected) {
119
162
}
120
163
}
121
164
165
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
166
+ TEST (CodeCompletionTest, DISABLED_SanityClasses) {
167
+ #else
122
168
TEST (CodeCompletionTest, SanityClasses) {
169
+ #endif
170
+ if (!HostSupportsJit ())
171
+ GTEST_SKIP ();
123
172
auto Interp = createInterpreter ();
124
173
cantFail (Interp->Parse (" struct Apple{};" ));
125
174
cantFail (Interp->Parse (" void takeApple(Apple &a1){}" ));
@@ -142,7 +191,13 @@ TEST(CodeCompletionTest, SanityClasses) {
142
191
}
143
192
}
144
193
194
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
195
+ TEST (CodeCompletionTest, DISABLED_SubClassing) {
196
+ #else
145
197
TEST (CodeCompletionTest, SubClassing) {
198
+ #endif
199
+ if (!HostSupportsJit ())
200
+ GTEST_SKIP ();
146
201
auto Interp = createInterpreter ();
147
202
cantFail (Interp->Parse (" struct Fruit {};" ));
148
203
cantFail (Interp->Parse (" struct Apple : Fruit{};" ));
@@ -157,7 +212,13 @@ TEST(CodeCompletionTest, SubClassing) {
157
212
EXPECT_EQ ((bool )Err, false );
158
213
}
159
214
215
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
216
+ TEST (CodeCompletionTest, DISABLED_MultipleArguments) {
217
+ #else
160
218
TEST (CodeCompletionTest, MultipleArguments) {
219
+ #endif
220
+ if (!HostSupportsJit ())
221
+ GTEST_SKIP ();
161
222
auto Interp = createInterpreter ();
162
223
cantFail (Interp->Parse (" int foo = 42;" ));
163
224
cantFail (Interp->Parse (" char fowl = 'A';" ));
@@ -169,7 +230,13 @@ TEST(CodeCompletionTest, MultipleArguments) {
169
230
EXPECT_EQ ((bool )Err, false );
170
231
}
171
232
233
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
234
+ TEST (CodeCompletionTest, DISABLED_Methods) {
235
+ #else
172
236
TEST (CodeCompletionTest, Methods) {
237
+ #endif
238
+ if (!HostSupportsJit ())
239
+ GTEST_SKIP ();
173
240
auto Interp = createInterpreter ();
174
241
cantFail (Interp->Parse (
175
242
" struct Foo{int add(int a){return 42;} int par(int b){return 42;}};" ));
@@ -183,7 +250,13 @@ TEST(CodeCompletionTest, Methods) {
183
250
EXPECT_EQ ((bool )Err, false );
184
251
}
185
252
253
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
254
+ TEST (CodeCompletionTest, DISABLED_MethodsInvocations) {
255
+ #else
186
256
TEST (CodeCompletionTest, MethodsInvocations) {
257
+ #endif
258
+ if (!HostSupportsJit ())
259
+ GTEST_SKIP ();
187
260
auto Interp = createInterpreter ();
188
261
cantFail (Interp->Parse (
189
262
" struct Foo{int add(int a){return 42;} int par(int b){return 42;}};" ));
@@ -197,7 +270,13 @@ TEST(CodeCompletionTest, MethodsInvocations) {
197
270
EXPECT_EQ ((bool )Err, false );
198
271
}
199
272
273
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
274
+ TEST (CodeCompletionTest, DISABLED_NestedInvocations) {
275
+ #else
200
276
TEST (CodeCompletionTest, NestedInvocations) {
277
+ #endif
278
+ if (!HostSupportsJit ())
279
+ GTEST_SKIP ();
201
280
auto Interp = createInterpreter ();
202
281
cantFail (Interp->Parse (
203
282
" struct Foo{int add(int a){return 42;} int par(int b){return 42;}};" ));
@@ -212,7 +291,13 @@ TEST(CodeCompletionTest, NestedInvocations) {
212
291
EXPECT_EQ ((bool )Err, false );
213
292
}
214
293
294
+ #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
295
+ TEST (CodeCompletionTest, DISABLED_TemplateFunctions) {
296
+ #else
215
297
TEST (CodeCompletionTest, TemplateFunctions) {
298
+ #endif
299
+ if (!HostSupportsJit ())
300
+ GTEST_SKIP ();
216
301
auto Interp = createInterpreter ();
217
302
cantFail (
218
303
Interp->Parse (" template <typename T> T id(T a) { return a;} " ));
0 commit comments