Skip to content

Commit c6d601b

Browse files
committed
fix ctor codegen for array new
1 parent 362e7e4 commit c6d601b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/CppInterOp/CppInterOp.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ void make_narg_ctor_with_return(const FunctionDecl* FD, const unsigned N,
20772077
callbuf << "if (nary > 1) {\n";
20782078
indent(callbuf, indent_level);
20792079
callbuf << "(*(" << class_name << "**)ret) = ";
2080-
callbuf << "(obj) ? new (*(" << class_name << "**)ret) ";
2080+
callbuf << "(is_arena) ? new (*(" << class_name << "**)ret) ";
20812081
make_narg_ctor(FD, N, typedefbuf, callbuf, class_name, indent_level,
20822082
true);
20832083

@@ -2101,7 +2101,7 @@ void make_narg_ctor_with_return(const FunctionDecl* FD, const unsigned N,
21012101
// : new ClassName(args...);
21022102
indent(callbuf, indent_level);
21032103
callbuf << "(*(" << class_name << "**)ret) = ";
2104-
callbuf << "(obj) ? new (*(" << class_name << "**)ret) ";
2104+
callbuf << "(is_arena) ? new (*(" << class_name << "**)ret) ";
21052105
make_narg_ctor(FD, N, typedefbuf, callbuf, class_name, indent_level);
21062106

21072107
callbuf << ": new ";
@@ -2629,9 +2629,14 @@ int get_wrapper_code(compat::Interpreter& I, const FunctionDecl* FD,
26292629
"__attribute__((annotate(\"__cling__ptrcheck(off)\")))\n"
26302630
"extern \"C\" void ";
26312631
buf << wrapper_name;
2632-
buf << "(void* obj, unsigned long nargs, void** args, void* ret, unsigned "
2633-
"long nary)\n"
2634-
"{\n";
2632+
if (Cpp::IsConstructor(FD)) {
2633+
buf << "(void* ret, unsigned long nary, unsigned long nargs, void** args, "
2634+
"int is_arena)\n"
2635+
"{\n";
2636+
} else
2637+
buf << "(void* obj, unsigned long nargs, void** args, void* ret)\n"
2638+
"{\n";
2639+
26352640
++indent_level;
26362641
if (min_args == num_params) {
26372642
// No parameters with defaults.

0 commit comments

Comments
 (0)