Skip to content

Commit 679833b

Browse files
committed
Forward clang_construct to Cpp::Construct
1 parent 732a459 commit 679833b

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

lib/Interpreter/CXCppInterOp.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -588,27 +588,14 @@ CXObject clang_allocate(unsigned int n) { return ::operator new(n); }
588588

589589
void clang_deallocate(CXObject address) { ::operator delete(address); }
590590

591-
CXObject clang_construct(CXScope scope, void* arena) {
592-
if (!clang_hasDefaultConstructor(scope))
593-
return nullptr;
594-
595-
const auto Ctor = clang_getDefaultConstructor(scope);
596-
if (kind(Ctor) == CXCursor_FirstInvalid)
597-
return nullptr;
598-
599-
auto* I = getInterpreter(scope);
600-
if (const Cpp::JitCall JC = Cpp::MakeFunctionCallable(I, getDecl(Ctor))) {
601-
if (arena) {
602-
JC.Invoke(&arena, {}, (void*)~0); // Tell Invoke to use placement new.
603-
return arena;
604-
}
605-
606-
void* obj = nullptr;
607-
JC.Invoke(&obj);
608-
return obj;
609-
}
591+
namespace Cpp {
592+
void* Construct(compat::Interpreter& interp, TCppScope_t scope,
593+
void* arena /*=nullptr*/);
594+
} // namespace Cpp
610595

611-
return nullptr;
596+
CXObject clang_construct(CXScope scope, void* arena) {
597+
return Cpp::Construct(*getInterpreter(scope),
598+
static_cast<void*>(getDecl(scope)), arena);
612599
}
613600

614601
void clang_invoke(CXScope func, void* result, void** args, size_t n,

0 commit comments

Comments
 (0)