Skip to content

Commit 9c6be69

Browse files
committed
Register __clang_Interpreter_SetValueWithAlloc, mangle name if LLVM<22
1 parent b912765 commit 9c6be69

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

lib/CppInterOp/CppInterOp.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,17 @@
9090
#include <unistd.h>
9191
#endif // WIN32
9292

93-
extern "C" void __clang_Interpreter_SetValueNoAlloc(void* This, void* OutVal,
94-
void* OpaqueType, ...);
93+
#if CLANG_VERSION_MAJOR > 22
94+
extern "C" void* __clang_Interpreter_SetValueWithAlloc(void* This, void* OutVal,
95+
void* OpaqueType)
96+
#else
97+
void* __clang_Interpreter_SetValueWithAlloc(void* This, void* OutVal,
98+
void* OpaqueType);
99+
#endif
100+
101+
extern "C" void __clang_Interpreter_SetValueNoAlloc(void* This,
102+
void* OutVal,
103+
void* OpaqueType, ...);
95104

96105
namespace Cpp {
97106

@@ -3476,8 +3485,23 @@ TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
34763485
sInterpreters->back().get()});
34773486

34783487
assert(sInterpreters->size() == sInterpreterASTMap->size());
3479-
// define __clang_Interpreter_SetValueNoAlloc in the JIT dylib for clang-repl
3488+
3489+
// Define runtime symbols in the JIT dylib for clang-repl
34803490
#ifndef CPPINTEROP_USE_CLING
3491+
#if CLANG_VERSION_MAJOR > 22
3492+
DefineAbsoluteSymbol(*I, "__clang_Interpreter_SetValueWithAlloc",
3493+
(uint64_t)&__clang_Interpreter_SetValueNoAlloc);
3494+
#else
3495+
auto* D = static_cast<clang::Decl*>(
3496+
Cpp::GetNamed("__clang_Interpreter_SetValueWithAlloc"));
3497+
if (auto* FD = llvm::dyn_cast<FunctionDecl>(D)) {
3498+
auto GD = GlobalDecl(FD);
3499+
std::string mangledName;
3500+
compat::maybeMangleDeclName(GD, mangledName);
3501+
DefineAbsoluteSymbol(*I, mangledName.c_str(),
3502+
(uint64_t)&__clang_Interpreter_SetValueWithAlloc);
3503+
}
3504+
#endif
34813505
DefineAbsoluteSymbol(*I, "__clang_Interpreter_SetValueNoAlloc",
34823506
(uint64_t)&__clang_Interpreter_SetValueNoAlloc);
34833507
#endif

0 commit comments

Comments
 (0)