Skip to content

Commit 01a9c67

Browse files
fix: by forcing to compile empty code block
1 parent 57ea015 commit 01a9c67

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/CppInterOp/CppInterOp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,16 @@ int get_wrapper_code(compat::Interpreter& I, const FunctionDecl* FD,
24902490
S.InstantiateFunctionDefinition(SourceLocation(), FDmod,
24912491
/*Recursive=*/true,
24922492
/*DefinitionRequired=*/true);
2493+
#ifndef CPPINTEROP_USE_CLING
2494+
// TODO: Will need to replace this with a RAII for clang-repl too
2495+
auto GeneratedPTU = I.Parse("");
2496+
if (!GeneratedPTU)
2497+
llvm::logAllUnhandledErrors(
2498+
GeneratedPTU.takeError(), llvm::errs(),
2499+
"[MakeFunctionCallable -> InstantiateFunctionDefinition] Failed to "
2500+
"generate PTU:");
2501+
#endif
2502+
24932503
if (!FD->isDefined(Definition)) {
24942504
llvm::errs() << "TClingCallFunc::make_wrapper"
24952505
<< ":"

unittests/CppInterOp/FunctionReflectionTest.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,12 @@ TEST(FunctionReflectionTest, UndoTest) {
21352135
}
21362136

21372137
TEST(FunctionReflectionTest, FailingTest1) {
2138+
#ifdef _WIN32
2139+
GTEST_SKIP() << "Disabled on Windows. Needs fixing.";
2140+
#endif
2141+
#ifdef EMSCRIPTEN
2142+
GTEST_SKIP() << "Test fails for Emscipten builds";
2143+
#endif
21382144
Cpp::CreateInterpreter();
21392145
EXPECT_FALSE(Cpp::Declare(R"(
21402146
class WithOutEqualOp1 {};
@@ -2157,7 +2163,6 @@ TEST(FunctionReflectionTest, FailingTest1) {
21572163
EXPECT_TRUE(fn);
21582164
Cpp::JitCall jit_call = Cpp::MakeFunctionCallable(fn);
21592165
EXPECT_EQ(jit_call.getKind(), Cpp::JitCall::kUnknown); // expected to fail
2160-
EXPECT_FALSE(Cpp::Declare("int x = 1;")); // expected to pass, but fails
2161-
EXPECT_FALSE(Cpp::Declare(
2162-
"int y = 1;")); // expected to pass, and passes on second attempt
2166+
EXPECT_FALSE(Cpp::Declare("int x = 1;"));
2167+
EXPECT_FALSE(Cpp::Declare("int y = x;"));
21632168
}

0 commit comments

Comments
 (0)