Skip to content

Commit 96b8f0d

Browse files
committed
[interop] Bump to latest version, fixes cmake overriding testing flag
1 parent 6935793 commit 96b8f0d

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

Diff for: .github/workflows/cppinterop-diff.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v4
1717
with:
1818
repository: compiler-research/CppInterOp
19-
ref: 6c6f94a22bd971520a249e2c02e4259cdd3a5be6
19+
ref: b0c3e360bdbea9618dd2744836671667c108bf97
2020
path: CppInterOp
2121
- name: Drop directories that are not added to ROOT
2222
working-directory: CppInterOp

Diff for: interpreter/CppInterOp/CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
5959
include(GNUInstallDirs)
6060
option(CPPINTEROP_USE_CLING "Use Cling as backend" OFF)
6161
option(CPPINTEROP_USE_REPL "Use clang-repl as backend" ON)
62+
option(CPPINTEROP_ENABLE_TESTING "Enable the CppInterOp testing infrastructure." ON)
6263

6364
if (CPPINTEROP_USE_CLING AND CPPINTEROP_USE_REPL)
6465
message(FATAL_ERROR "We can only use Cling (CPPINTEROP_USE_CLING=On) or Repl (CPPINTEROP_USE_REPL=On), but not both of them.")
@@ -453,10 +454,7 @@ option(CPPINTEROP_ENABLE_SPHINX "Use sphinx to generage CppInterOp user document
453454

454455
if(EMSCRIPTEN)
455456
message("Build with emscripten")
456-
option(CPPINTEROP_ENABLE_TESTING "Enables the testing infrastructure." OFF)
457-
else()
458-
message("Build with cmake")
459-
option(CPPINTEROP_ENABLE_TESTING "Enables the testing infrastructure." ON)
457+
set(CPPINTEROP_ENABLE_TESTING OFF)
460458
endif()
461459

462460
if(MSVC)

Diff for: interpreter/CppInterOp/lib/Interpreter/CppInterOp.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,9 @@ namespace Cpp {
16751675
//
16761676
ASTContext& C = FD->getASTContext();
16771677
PrintingPolicy Policy(C.getPrintingPolicy());
1678+
#if CLANG_VERSION_MAJOR > 16
1679+
Policy.SuppressElaboration = true;
1680+
#endif
16781681
refType = kNotReference;
16791682
if (QT->isRecordType() && forArgument) {
16801683
get_type_as_string(QT, type_name, C, Policy);
@@ -1989,18 +1992,22 @@ namespace Cpp {
19891992
EReferenceType refType = kNotReference;
19901993
bool isPointer = false;
19911994

1995+
std::ostringstream typedefbuf;
1996+
std::ostringstream callbuf;
1997+
1998+
collect_type_info(FD, QT, typedefbuf, callbuf, type_name, refType,
1999+
isPointer, indent_level, false);
2000+
2001+
buf << typedefbuf.str();
2002+
19922003
buf << "if (ret) {\n";
19932004
++indent_level;
19942005
{
1995-
std::ostringstream typedefbuf;
1996-
std::ostringstream callbuf;
19972006
//
19982007
// Write the placement part of the placement new.
19992008
//
20002009
indent(callbuf, indent_level);
20012010
callbuf << "new (ret) ";
2002-
collect_type_info(FD, QT, typedefbuf, callbuf, type_name, refType,
2003-
isPointer, indent_level, false);
20042011
//
20052012
// Write the type part of the placement new.
20062013
//

Diff for: interpreter/CppInterOp/unittests/CppInterOp/FunctionReflectionTest.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,9 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
888888
int f3() { return 3; }
889889
890890
extern "C" int f4() { return 4; }
891+
892+
typedef int(*int_func)(void);
893+
int_func f5() { return f3; }
891894
}
892895
)");
893896

@@ -923,6 +926,18 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
923926
FCI4.Invoke(&ret4);
924927
EXPECT_EQ(ret4, 4);
925928

929+
#if CLANG_VERSION_MAJOR > 16
930+
Cpp::JitCall FCI5 =
931+
Cpp::MakeFunctionCallable(Cpp::GetNamed("f5", Cpp::GetNamed("NS")));
932+
EXPECT_TRUE(FCI5.getKind() == Cpp::JitCall::kGenericCall);
933+
934+
typedef int (*int_func)();
935+
int_func callback = nullptr;
936+
FCI5.Invoke((void*)&callback);
937+
EXPECT_TRUE(callback);
938+
EXPECT_EQ(callback(), 3);
939+
#endif
940+
926941
// FIXME: Do we need to support private ctors?
927942
Interp->process(R"(
928943
class C {

0 commit comments

Comments
 (0)