Author: Stefan Gränitz
Date: 2024-05-30T17:03:21+02:00
New Revision: 647d2728c4dbc387521ce3984ebfda78ff2b031f

URL: 
https://github.com/llvm/llvm-project/commit/647d2728c4dbc387521ce3984ebfda78ff2b031f
DIFF: 
https://github.com/llvm/llvm-project/commit/647d2728c4dbc387521ce3984ebfda78ff2b031f.diff

LOG: [clang-repl] Fix SetUp in CodeCompletionTest fixture (#93816)

And sort out some unused headers

Added: 
    

Modified: 
    clang/unittests/Interpreter/CodeCompletionTest.cpp
    clang/unittests/Interpreter/IncrementalProcessingTest.cpp
    clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
    clang/unittests/Interpreter/InterpreterTest.cpp
    clang/unittests/Interpreter/InterpreterTestFixture.h

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Interpreter/CodeCompletionTest.cpp 
b/clang/unittests/Interpreter/CodeCompletionTest.cpp
index 1dbd983da0dc3..72fcce76a1029 100644
--- a/clang/unittests/Interpreter/CodeCompletionTest.cpp
+++ b/clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -5,10 +5,6 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===----------------------------------------------------------------------===//
-//
-// Unit tests for Clang's Interpreter library.
-//
-//===----------------------------------------------------------------------===//
 
 #include "InterpreterTestFixture.h"
 
@@ -18,9 +14,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/Sema.h"
-#include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/LineEditor/LineEditor.h"
-#include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include "gmock/gmock.h"
@@ -32,12 +26,14 @@ auto CB = clang::IncrementalCompilerBuilder();
 
 class CodeCompletionTest : public InterpreterTestBase {
 public:
-  std::unique_ptr<CompilerInstance> CI;
   std::unique_ptr<Interpreter> Interp;
 
-  CodeCompletionTest()
-      : CI(cantFail(CB.CreateCpp())),
-        Interp(cantFail(clang::Interpreter::create(std::move(CI)))) {}
+  void SetUp() override {
+    if (!HostSupportsJIT())
+      GTEST_SKIP();
+    std::unique_ptr<CompilerInstance> CI = cantFail(CB.CreateCpp());
+    this->Interp = cantFail(clang::Interpreter::create(std::move(CI)));
+  }
 
   std::vector<std::string> runComp(llvm::StringRef Input, llvm::Error &ErrR) {
     auto ComplCI = CB.CreateCpp();

diff  --git a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp 
b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp
index 1abf5ad222879..4d7841a6ee580 100644
--- a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp
+++ b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -19,12 +19,11 @@
 #include "clang/Parse/Parser.h"
 #include "clang/Sema/Sema.h"
 
-#include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/TargetParser/Host.h"
 #include "llvm/TargetParser/Triple.h"
+
 #include "gtest/gtest.h"
 
 #include <memory>

diff  --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp 
b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index 02d4a3c782889..5f1f29cebab14 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -22,8 +22,6 @@
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
 #include "llvm/MC/TargetRegistry.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Testing/Support/Error.h"
 

diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 3b07d6d1cf5d2..ab9b7a31094f7 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -12,21 +12,16 @@
 
 #include "InterpreterTestFixture.h"
 
-#include "clang/Interpreter/Interpreter.h"
-
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclGroup.h"
 #include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Interpreter/Interpreter.h"
 #include "clang/Interpreter/Value.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
-#include "llvm/ExecutionEngine/Orc/LLJIT.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/TargetSelect.h"
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 

diff  --git a/clang/unittests/Interpreter/InterpreterTestFixture.h 
b/clang/unittests/Interpreter/InterpreterTestFixture.h
index caf8141a90a7b..113599ff98894 100644
--- a/clang/unittests/Interpreter/InterpreterTestFixture.h
+++ b/clang/unittests/Interpreter/InterpreterTestFixture.h
@@ -9,11 +9,9 @@
 #ifndef LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
 #define LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
 
-#include "clang/Testing/TestClangConfig.h"
-#include "clang/Tooling/Tooling.h"
-
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
 
 #include "gtest/gtest.h"
@@ -27,21 +25,21 @@ namespace clang {
 class InterpreterTestBase : public ::testing::Test {
 protected:
   static bool HostSupportsJIT() {
+#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
+    return false;
+#else
     if (auto JIT = llvm::orc::LLJITBuilder().create()) {
       return true;
     } else {
       llvm::consumeError(JIT.takeError());
       return false;
     }
+#endif
   }
 
   void SetUp() override {
-#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
-    GTEST_SKIP();
-#else
     if (!HostSupportsJIT())
       GTEST_SKIP();
-#endif
   }
 
   void TearDown() override {}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to