@@ -1924,6 +1924,7 @@ namespace Cpp {
19241924 // Make a code string that follows this pattern:
19251925 //
19261926 // ClassName(args...)
1927+ // ClassName[nary](args...)
19271928 //
19281929
19291930 if (array)
@@ -2128,7 +2129,12 @@ namespace Cpp {
21282129 // Write the return value assignment part.
21292130 //
21302131 indent (callbuf, indent_level);
2131- callbuf << " if (n_objs > 1) {\n " ;
2132+ auto *CD = dyn_cast<CXXConstructorDecl>(FD);
2133+
2134+ // FIXME : There can also arise ambiguity if there are
2135+ // multiple default construct array only if no params
2136+ if (!CD->isDefaultConstructor () and CD->getNumParams () == 0 ) {
2137+ callbuf << " if (n_objs > 1) {\n " ;
21322138 indent (callbuf, indent_level);
21332139 callbuf << " (*(" << class_name << " **)ret) = " ;
21342140 callbuf << " (obj) ? new (*(" << class_name << " **)ret) " ;
@@ -2143,25 +2149,27 @@ namespace Cpp {
21432149 // End the new expression statement.
21442150 //
21452151 callbuf << " ;\n " ;
2152+ indent (callbuf, indent_level);
2153+ callbuf << " }\n " ;
2154+ callbuf << " else {\n " ;
2155+ }
21462156 indent (callbuf, indent_level);
2147- callbuf << " }\n " ;
2148- callbuf << " else {\n " ;
2149- indent (callbuf, indent_level);
2150- callbuf << " (*(" << class_name << " **)ret) = " ;
2151- callbuf << " (obj) ? new (*(" << class_name << " **)ret) " ;
2152- make_narg_ctor (FD, N, typedefbuf, callbuf, class_name, indent_level);
2157+ callbuf << " (*(" << class_name << " **)ret) = " ;
2158+ callbuf << " (obj) ? new (*(" << class_name << " **)ret) " ;
2159+ make_narg_ctor (FD, N, typedefbuf, callbuf, class_name, indent_level);
21532160
2154- callbuf << " : new " ;
2155- //
2156- // Write the actual expression.
2157- //
2158- make_narg_ctor (FD, N, typedefbuf, callbuf, class_name, indent_level);
2159- //
2160- // End the new expression statement.
2161- //
2162- callbuf << " ;\n " ;
2161+ callbuf << " : new " ;
2162+ //
2163+ // Write the actual expression.
2164+ //
2165+ make_narg_ctor (FD, N, typedefbuf, callbuf, class_name, indent_level);
2166+ //
2167+ // End the new expression statement.
2168+ //
2169+ callbuf << " ;\n " ;
21632170 indent (callbuf, --indent_level);
2164- callbuf << " }\n " ;
2171+ if (!CD->isDefaultConstructor () and CD->getNumParams () == 0 )
2172+ callbuf << " }\n " ;
21652173
21662174 //
21672175 // Output the whole new expression and return statement.
@@ -2737,7 +2745,6 @@ namespace Cpp {
27372745 if (get_wrapper_code (I, FD, wrapper_name, wrapper_code) == 0 )
27382746 return 0 ;
27392747
2740- // std::cout<<"WRAPPER NAME: "<<wrapper_name<<"\nWRAPPER CODE:\n"<<wrapper_code;
27412748 //
27422749 // Compile the wrapper code.
27432750 //
@@ -2750,7 +2757,6 @@ namespace Cpp {
27502757 if (wrapper) {
27512758 // gWrapperStore.insert(std::make_pair(FunctionDeclInfo(FD, cct), wrapper));
27522759 gWrapperStore .insert (std::make_pair (FD, wrapper));
2753- // std::cout<<"WRAPPER CODE: \n"<<wrapper<<"\n";
27542760 } else {
27552761 llvm::errs () << " TClingCallFunc::make_wrapper"
27562762 << " :"
0 commit comments