From 15321dc0f7dc85ce24272cbaef53bcbc6e030f5f Mon Sep 17 00:00:00 2001 From: Anurag Bhat <90216905+faze-geek@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:00:25 +0530 Subject: [PATCH 1/9] Make USE_REPL=On --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fcdcc915..6dbd25249 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) endif() option(USE_CLING "Use Cling as backend" OFF) - option(USE_REPL "Use clang-repl as backend" OFF) + option(USE_REPL "Use clang-repl as backend" ON) if (USE_CLING AND USE_REPL) message(FATAL_ERROR "We can only use Cling (USE_CLING=On) or Repl (USE_REPL=On), but not both of them.") From bffb35548b5c1ecc5a3c494998f632609c5757d5 Mon Sep 17 00:00:00 2001 From: Anurag Bhat <90216905+faze-geek@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:15:38 +0530 Subject: [PATCH 2/9] Remove unnecessary DUSE_REPL=ON tags --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 293bfd42b..4bf620756 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -884,7 +884,6 @@ jobs: else cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DUSE_CLING=OFF \ - -DUSE_REPL=ON \ -DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \ -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ @@ -977,7 +976,6 @@ jobs: { cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ` -DUSE_CLING=OFF ` - -DUSE_REPL=ON ` -DLLVM_DIR="$env:LLVM_BUILD_DIR\lib\cmake\llvm" ` -DLLVM_ENABLE_WERROR=On ` -DClang_DIR="$env:LLVM_BUILD_DIR\lib\cmake\clang" -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} -DCMAKE_INSTALL_PREFIX="$env:CPPINTEROP_DIR" ..\ @@ -1272,7 +1270,6 @@ jobs: else emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ -DUSE_CLING=OFF \ - -DUSE_REPL=ON \ -DCMAKE_PREFIX_PATH=$PREFIX \ -DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \ -DClang_DIR=$LLVM_BUILD_DIR/lib/cmake/clang \ From 233d178898175ce4baaa38daa3d348d9c97049ee Mon Sep 17 00:00:00 2001 From: Anurag Bhat <90216905+faze-geek@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:18:05 +0530 Subject: [PATCH 3/9] Update InterpreterTest.cpp --- unittests/CppInterOp/InterpreterTest.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/unittests/CppInterOp/InterpreterTest.cpp b/unittests/CppInterOp/InterpreterTest.cpp index 7a026d0f2..424554e5d 100644 --- a/unittests/CppInterOp/InterpreterTest.cpp +++ b/unittests/CppInterOp/InterpreterTest.cpp @@ -7,9 +7,7 @@ #include "cling/Interpreter/Interpreter.h" #endif // USE_CLING -#ifdef USE_REPL #include "clang/Interpreter/Interpreter.h" -#endif // USE_REPL #include "clang/Basic/Version.h" @@ -175,7 +173,6 @@ TEST(InterpreterTest, CodeCompletion) { TEST(InterpreterTest, ExternalInterpreterTest) { -#ifdef USE_REPL llvm::ExitOnError ExitOnErr; clang::IncrementalCompilerBuilder CB; CB.SetCompilerArgs({"-std=c++20"}); @@ -188,7 +185,6 @@ TEST(InterpreterTest, ExternalInterpreterTest) { std::unique_ptr I = ExitOnErr(clang::Interpreter::create(std::move(CI))); auto ExtInterp = I.get(); -#endif #ifdef USE_CLING std::string MainExecutableName = sys::fs::getMainExecutable(nullptr, nullptr); @@ -203,9 +199,8 @@ TEST(InterpreterTest, ExternalInterpreterTest) { Cpp::UseExternalInterpreter(ExtInterp); EXPECT_TRUE(Cpp::GetInterpreter()) << "External Interpreter not set"; -#ifdef USE_REPL I.release(); -#endif + #ifdef USE_CLING delete ExtInterp; #endif From 5b55c3d6104a04c058d0ff8a4e6d1dfcc312bb7f Mon Sep 17 00:00:00 2001 From: Anurag Bhat <90216905+faze-geek@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:21:33 +0530 Subject: [PATCH 4/9] Update Compatibility.h --- lib/Interpreter/Compatibility.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Interpreter/Compatibility.h b/lib/Interpreter/Compatibility.h index 0a0dfaa4e..c839237d8 100644 --- a/lib/Interpreter/Compatibility.h +++ b/lib/Interpreter/Compatibility.h @@ -183,7 +183,6 @@ inline void codeComplete(std::vector& Results, #endif // USE_CLING -#ifdef USE_REPL #include "DynamicLibraryManager.h" #include "clang/AST/Mangle.h" @@ -403,7 +402,6 @@ namespace compat { using Interpreter = Cpp::Interpreter; } -#endif // USE_REPL namespace compat { From d3752df185655afe7f4bcc46f91d677c0a97b40f Mon Sep 17 00:00:00 2001 From: Anurag Bhat <90216905+faze-geek@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:47:53 +0530 Subject: [PATCH 5/9] Add USE_CLING definition instead of USE_REPL --- lib/Interpreter/Compatibility.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Interpreter/Compatibility.h b/lib/Interpreter/Compatibility.h index c839237d8..a7640aee0 100644 --- a/lib/Interpreter/Compatibility.h +++ b/lib/Interpreter/Compatibility.h @@ -183,6 +183,7 @@ inline void codeComplete(std::vector& Results, #endif // USE_CLING +#ifndef USE_CLING #include "DynamicLibraryManager.h" #include "clang/AST/Mangle.h" @@ -403,6 +404,8 @@ using Interpreter = Cpp::Interpreter; } +#endif // USE_CLING + namespace compat { // Clang >= 14 change type name to string (spaces formatting problem) From 1e18aa794ef189f75ddc1b6ba99f0aa4a52ffe76 Mon Sep 17 00:00:00 2001 From: Anurag Bhat <90216905+faze-geek@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:55:16 +0530 Subject: [PATCH 6/9] Remove unnecessary space --- lib/Interpreter/Compatibility.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Interpreter/Compatibility.h b/lib/Interpreter/Compatibility.h index a7640aee0..03594077b 100644 --- a/lib/Interpreter/Compatibility.h +++ b/lib/Interpreter/Compatibility.h @@ -403,7 +403,6 @@ namespace compat { using Interpreter = Cpp::Interpreter; } - #endif // USE_CLING namespace compat { From a66d6ced41cf85aaba75abf49809aace7041afb8 Mon Sep 17 00:00:00 2001 From: faze-geek Date: Sat, 14 Dec 2024 17:01:03 +0530 Subject: [PATCH 7/9] Update ifdef REPL to ifndef CLING --- unittests/CppInterOp/InterpreterTest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/unittests/CppInterOp/InterpreterTest.cpp b/unittests/CppInterOp/InterpreterTest.cpp index 3a578af57..f2683a7a6 100644 --- a/unittests/CppInterOp/InterpreterTest.cpp +++ b/unittests/CppInterOp/InterpreterTest.cpp @@ -7,6 +7,7 @@ #include "cling/Interpreter/Interpreter.h" #endif // USE_CLING +#ifndef USE_CLING #include "clang/Interpreter/Interpreter.h" #include "clang/Basic/Version.h" @@ -106,6 +107,16 @@ TEST(InterpreterTest, CreateInterpreter) { "#endif"); EXPECT_TRUE(Cpp::GetNamed("cpp17")); EXPECT_FALSE(Cpp::GetNamed("cppUnknown")); + +#ifndef USE_CLING + // C API + auto CXI = clang_createInterpreterFromRawPtr(I); + auto CLI = clang_Interpreter_getClangInterpreter(CXI); + EXPECT_TRUE(CLI); + auto I2 = clang_Interpreter_takeInterpreterAsPtr(CXI); + EXPECT_EQ(I, I2); + clang_Interpreter_dispose(CXI); +#endif // USE_REPL } #ifdef LLVM_BINARY_DIR @@ -176,6 +187,7 @@ TEST(InterpreterTest, ExternalInterpreterTest) { if (llvm::sys::RunningOnValgrind()) GTEST_SKIP() << "XFAIL due to Valgrind report"; +#ifndef USE_CLING llvm::ExitOnError ExitOnErr; clang::IncrementalCompilerBuilder CB; CB.SetCompilerArgs({"-std=c++20"}); @@ -188,6 +200,7 @@ if (llvm::sys::RunningOnValgrind()) std::unique_ptr I = ExitOnErr(clang::Interpreter::create(std::move(CI))); auto ExtInterp = I.get(); +#endif // USE_REPL #ifdef USE_CLING std::string MainExecutableName = sys::fs::getMainExecutable(nullptr, nullptr); @@ -207,6 +220,7 @@ if (llvm::sys::RunningOnValgrind()) #endif EXPECT_TRUE(Cpp::GetInterpreter()) << "External Interpreter not set"; +#ifndef USE_CLING I.release(); #ifdef USE_CLING From 8867cf50c79a9723df5d325f97b49ad2547db1a4 Mon Sep 17 00:00:00 2001 From: faze-geek Date: Sat, 14 Dec 2024 17:24:59 +0530 Subject: [PATCH 8/9] Minor fix --- lib/Interpreter/Compatibility.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Interpreter/Compatibility.h b/lib/Interpreter/Compatibility.h index 03594077b..d6efc7324 100644 --- a/lib/Interpreter/Compatibility.h +++ b/lib/Interpreter/Compatibility.h @@ -403,7 +403,7 @@ namespace compat { using Interpreter = Cpp::Interpreter; } -#endif // USE_CLING +#endif // USE_REPL namespace compat { From 9432bb5279e0470196059d0d3325d124c1c86308 Mon Sep 17 00:00:00 2001 From: faze-geek Date: Sat, 14 Dec 2024 17:53:47 +0530 Subject: [PATCH 9/9] Add missed endif --- unittests/CppInterOp/InterpreterTest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unittests/CppInterOp/InterpreterTest.cpp b/unittests/CppInterOp/InterpreterTest.cpp index f2683a7a6..2a290fb02 100644 --- a/unittests/CppInterOp/InterpreterTest.cpp +++ b/unittests/CppInterOp/InterpreterTest.cpp @@ -9,6 +9,7 @@ #ifndef USE_CLING #include "clang/Interpreter/Interpreter.h" +#endif // USE_REPL #include "clang/Basic/Version.h" @@ -116,7 +117,7 @@ TEST(InterpreterTest, CreateInterpreter) { auto I2 = clang_Interpreter_takeInterpreterAsPtr(CXI); EXPECT_EQ(I, I2); clang_Interpreter_dispose(CXI); -#endif // USE_REPL +#endif } #ifdef LLVM_BINARY_DIR @@ -222,6 +223,7 @@ if (llvm::sys::RunningOnValgrind()) #ifndef USE_CLING I.release(); +#endif #ifdef USE_CLING delete ExtInterp;