if (msg != NULL_TREE)
- return build_libcall (libcall, Type::tnoreturn, 3, msg, file, line);
+ return build_libcall (libcall, 3, msg, file, line);
else
- return build_libcall (libcall, Type::tnoreturn, 2, file, line);
+ return build_libcall (libcall, 2, file, line);
}
/* Builds a CALL_EXPR at location LOC in the source file to execute when an
return build_call_expr (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
- return build_libcall (LIBCALL_ARRAYBOUNDSP, Type::tnoreturn, 2,
+ return build_libcall (LIBCALL_ARRAYBOUNDSP, 2,
build_filename_from_loc (loc),
size_int (loc.linnum ()));
}
boundserr = build_call_expr (builtin_decl_explicit (BUILT_IN_TRAP), 0);
else
{
- boundserr = build_libcall (LIBCALL_ARRAYBOUNDS_INDEXP, Type::tnoreturn, 4,
+ boundserr = build_libcall (LIBCALL_ARRAYBOUNDS_INDEXP, 4,
build_filename_from_loc (ie->e2->loc),
size_int (ie->e2->loc.linnum ()),
index, length);
}
else
{
- boundserr = build_libcall (LIBCALL_ARRAYBOUNDS_SLICEP,
- Type::tnoreturn, 5,
+ boundserr = build_libcall (LIBCALL_ARRAYBOUNDS_SLICEP, 5,
build_filename_from_loc (se->loc),
size_int (se->loc.linnum ()),
lower, upper, length);
/* Allocate memory for closure. */
tree arg = convert (build_ctype (Type::tsize_t), TYPE_SIZE_UNIT (type));
- tree init = build_libcall (LIBCALL_ALLOCMEMORY, Type::tvoidptr, 1, arg);
+ tree init = build_libcall (LIBCALL_ALLOCMEMORY, 1, arg);
tree init_exp = build_assign (INIT_EXPR, decl,
build_nop (TREE_TYPE (decl), init));
extern void d_finish_compilation (tree *, int);
/* In runtime.cc. */
+extern tree build_libcall (libcall_fn, int ...);
extern tree build_libcall (libcall_fn, Type *, int ...);
/* In typeinfo.cc. */
void visit (ThrowExp *e) final override
{
tree arg = build_expr_dtor (e->e1);
- this->result_ = build_libcall (LIBCALL_THROW, Type::tnoreturn, 1, arg);
+ this->result_ = build_libcall (LIBCALL_THROW, 1, arg);
}
/* Build a postfix expression. */
libcall_fn libcall = tb1->isClassHandle ()->isInterfaceDeclaration ()
? LIBCALL_CALLINTERFACEFINALIZER : LIBCALL_CALLFINALIZER;
- this->result_ = build_libcall (libcall, Type::tvoid, 1, t1);
+ this->result_ = build_libcall (libcall, 1, t1);
return;
}
else
if (!cd->isInterfaceDeclaration () && !cd->isCPPclass ())
{
arg = d_save_expr (arg);
- assert_pass = build_libcall (LIBCALL_INVARIANT,
- Type::tvoid, 1, arg);
+ assert_pass = build_libcall (LIBCALL_INVARIANT, 1, arg);
}
}
else if (tb1->ty == TY::Tpointer
return libcall_decls[libcall];
}
-/* Generate a call to LIBCALL, returning the result as TYPE. NARGS is the
- number of call arguments, the expressions of which are provided in `...'.
+
+/* Subroutine of build_libcall; generate a call to LIBCALL. NARGS is the
+ number of call arguments, the expressions of which are provided in ARGP.
This does not perform conversions or promotions on the arguments. */
-tree
-build_libcall (libcall_fn libcall, Type *type, int nargs, ...)
+static tree
+build_libcall_1 (libcall_fn libcall, int nargs, va_list argp)
{
/* Build the call expression to the runtime function. */
tree decl = get_libcall (libcall);
tree *args = XALLOCAVEC (tree, nargs);
+
+ for (int i = 0; i < nargs; i++)
+ args[i] = va_arg (argp, tree);
+
+ return build_call_expr_loc_array (input_location, decl, nargs, args);
+}
+
+/* Generate a call to LIBCALL. NARGS is the number of call arguments, the
+ expressions of which are provided in `...'. */
+
+tree
+build_libcall (libcall_fn libcall, int nargs, ...)
+{
va_list ap;
va_start (ap, nargs);
- for (int i = 0; i < nargs; i++)
- args[i] = va_arg (ap, tree);
+
+ tree result = build_libcall_1 (libcall, nargs, ap);
va_end (ap);
- tree result = build_call_expr_loc_array (input_location, decl, nargs, args);
+ return result;
+}
+
+/* Generate a call to LIBCALL, returning the result as TYPE. NARGS is the
+ number of call arguments, the expressions of which are provided in `...'. */
+
+tree
+build_libcall (libcall_fn libcall, Type *type, int nargs, ...)
+{
+ va_list ap;
+
+ va_start (ap, nargs);
+
+ tree result = build_libcall_1 (libcall, nargs, ap);
+ va_end (ap);
/* Assumes caller knows what it is doing. */
return convert (build_ctype (type), result);
else
arg = build_nop (build_ctype (get_object_type ()), arg);
- add_stmt (build_libcall (LIBCALL_THROW, Type::tnoreturn, 1, arg));
+ add_stmt (build_libcall (LIBCALL_THROW, 1, arg));
}
/* Build a try-catch statement, one of the building blocks for exception
the end catch callback. */
if (cd->isCPPclass ())
{
- tree endcatch = build_libcall (LIBCALL_CXA_END_CATCH,
- Type::tvoid, 0);
+ tree endcatch = build_libcall (LIBCALL_CXA_END_CATCH, 0);
catchbody = build2 (TRY_FINALLY_EXPR, void_type_node,
catchbody, endcatch);
}