Skip to content

Commit 647d272

Browse files
[clang-repl] Fix SetUp in CodeCompletionTest fixture (#93816)
And sort out some unused headers
1 parent e8de977 commit 647d272

File tree

5 files changed

+13
-27
lines changed

5 files changed

+13
-27
lines changed

clang/unittests/Interpreter/CodeCompletionTest.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
9-
// Unit tests for Clang's Interpreter library.
10-
//
11-
//===----------------------------------------------------------------------===//
128

139
#include "InterpreterTestFixture.h"
1410

@@ -18,9 +14,7 @@
1814
#include "clang/Lex/Preprocessor.h"
1915
#include "clang/Sema/CodeCompleteConsumer.h"
2016
#include "clang/Sema/Sema.h"
21-
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
2217
#include "llvm/LineEditor/LineEditor.h"
23-
#include "llvm/Support/Error.h"
2418
#include "llvm/Support/raw_ostream.h"
2519

2620
#include "gmock/gmock.h"
@@ -32,12 +26,14 @@ auto CB = clang::IncrementalCompilerBuilder();
3226

3327
class CodeCompletionTest : public InterpreterTestBase {
3428
public:
35-
std::unique_ptr<CompilerInstance> CI;
3629
std::unique_ptr<Interpreter> Interp;
3730

38-
CodeCompletionTest()
39-
: CI(cantFail(CB.CreateCpp())),
40-
Interp(cantFail(clang::Interpreter::create(std::move(CI)))) {}
31+
void SetUp() override {
32+
if (!HostSupportsJIT())
33+
GTEST_SKIP();
34+
std::unique_ptr<CompilerInstance> CI = cantFail(CB.CreateCpp());
35+
this->Interp = cantFail(clang::Interpreter::create(std::move(CI)));
36+
}
4137

4238
std::vector<std::string> runComp(llvm::StringRef Input, llvm::Error &ErrR) {
4339
auto ComplCI = CB.CreateCpp();

clang/unittests/Interpreter/IncrementalProcessingTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
#include "clang/Parse/Parser.h"
2020
#include "clang/Sema/Sema.h"
2121

22-
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
2322
#include "llvm/IR/LLVMContext.h"
2423
#include "llvm/IR/Module.h"
25-
#include "llvm/Support/MemoryBuffer.h"
2624
#include "llvm/TargetParser/Host.h"
2725
#include "llvm/TargetParser/Triple.h"
26+
2827
#include "gtest/gtest.h"
2928

3029
#include <memory>

clang/unittests/Interpreter/InterpreterExtensionsTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
2323
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
2424
#include "llvm/MC/TargetRegistry.h"
25-
#include "llvm/Support/Error.h"
26-
#include "llvm/Support/TargetSelect.h"
2725
#include "llvm/Support/Threading.h"
2826
#include "llvm/Testing/Support/Error.h"
2927

clang/unittests/Interpreter/InterpreterTest.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@
1212

1313
#include "InterpreterTestFixture.h"
1414

15-
#include "clang/Interpreter/Interpreter.h"
16-
1715
#include "clang/AST/Decl.h"
1816
#include "clang/AST/DeclGroup.h"
1917
#include "clang/AST/Mangle.h"
2018
#include "clang/Frontend/CompilerInstance.h"
2119
#include "clang/Frontend/TextDiagnosticPrinter.h"
20+
#include "clang/Interpreter/Interpreter.h"
2221
#include "clang/Interpreter/Value.h"
2322
#include "clang/Sema/Lookup.h"
2423
#include "clang/Sema/Sema.h"
2524

26-
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
27-
#include "llvm/Support/ManagedStatic.h"
28-
#include "llvm/Support/TargetSelect.h"
29-
3025
#include "gmock/gmock.h"
3126
#include "gtest/gtest.h"
3227

clang/unittests/Interpreter/InterpreterTestFixture.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
#ifndef LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
1010
#define LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
1111

12-
#include "clang/Testing/TestClangConfig.h"
13-
#include "clang/Tooling/Tooling.h"
14-
1512
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
1613
#include "llvm/Support/Error.h"
14+
#include "llvm/Support/ManagedStatic.h"
1715
#include "llvm/Support/TargetSelect.h"
1816

1917
#include "gtest/gtest.h"
@@ -27,21 +25,21 @@ namespace clang {
2725
class InterpreterTestBase : public ::testing::Test {
2826
protected:
2927
static bool HostSupportsJIT() {
28+
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
29+
return false;
30+
#else
3031
if (auto JIT = llvm::orc::LLJITBuilder().create()) {
3132
return true;
3233
} else {
3334
llvm::consumeError(JIT.takeError());
3435
return false;
3536
}
37+
#endif
3638
}
3739

3840
void SetUp() override {
39-
#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
40-
GTEST_SKIP();
41-
#else
4241
if (!HostSupportsJIT())
4342
GTEST_SKIP();
44-
#endif
4543
}
4644

4745
void TearDown() override {}

0 commit comments

Comments
 (0)