Skip to content

Commit 376cc2b

Browse files
committed
Register __clang_Interpreter_SetValueWithAlloc, mangle name if LLVM<22
1 parent af3c606 commit 376cc2b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

lib/CppInterOp/CppInterOp.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,17 @@
8686
#include <unistd.h>
8787
#endif // WIN32
8888

89-
extern "C" void __clang_Interpreter_SetValueNoAlloc(void* This, void* OutVal,
90-
void* OpaqueType, ...);
89+
#if CLANG_VERSION_MAJOR > 22
90+
extern "C" void* __clang_Interpreter_SetValueWithAlloc(void* This, void* OutVal,
91+
void* OpaqueType)
92+
#else
93+
void* __clang_Interpreter_SetValueWithAlloc(void* This, void* OutVal,
94+
void* OpaqueType);
95+
#endif
96+
97+
extern "C" void __clang_Interpreter_SetValueNoAlloc(void* This,
98+
void* OutVal,
99+
void* OpaqueType, ...);
91100

92101
namespace Cpp {
93102

@@ -3307,8 +3316,22 @@ TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
33073316

33083317
sInterpreters->emplace_back(I, /*Owned=*/true);
33093318

3310-
// define __clang_Interpreter_SetValueNoAlloc in the JIT dylib for clang-repl
3319+
// Define runtime symbols in the JIT dylib for clang-repl
33113320
#ifndef CPPINTEROP_USE_CLING
3321+
#if CLANG_VERSION_MAJOR > 22
3322+
DefineAbsoluteSymbol(*I, "__clang_Interpreter_SetValueWithAlloc",
3323+
(uint64_t)&__clang_Interpreter_SetValueNoAlloc);
3324+
#else
3325+
auto* D = static_cast<clang::Decl*>(
3326+
Cpp::GetNamed("__clang_Interpreter_SetValueWithAlloc"));
3327+
if (auto* FD = llvm::dyn_cast<FunctionDecl>(D)) {
3328+
auto GD = GlobalDecl(FD);
3329+
std::string mangledName;
3330+
compat::maybeMangleDeclName(GD, mangledName);
3331+
DefineAbsoluteSymbol(*I, mangledName.c_str(),
3332+
(uint64_t)&__clang_Interpreter_SetValueWithAlloc);
3333+
}
3334+
#endif
33123335
DefineAbsoluteSymbol(*I, "__clang_Interpreter_SetValueNoAlloc",
33133336
(uint64_t)&__clang_Interpreter_SetValueNoAlloc);
33143337
#endif

0 commit comments

Comments
 (0)