From: Rico Tzschichholz Date: Wed, 26 Dec 2018 19:34:39 +0000 (+0100) Subject: codegen: Use temp-var for MethodCall with out/ref arguments X-Git-Tag: 0.43.4~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8524dc8d547f2f2021516062e9915709dcc1c2b2;p=thirdparty%2Fvala.git codegen: Use temp-var for MethodCall with out/ref arguments Checking arguments of a MethodCall expression is required for varidic methods where checking parameters isn't sufficient. Doing this makes looking for out/ref parameters superfluous. Fixes https://gitlab.gnome.org/GNOME/vala/issues/722 --- diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 90da65c88..e8a332d21 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -814,7 +814,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { } else if (m != null && m.get_attribute_bool ("CCode", "use_inplace", false)) { set_cvalue (expr, ccall_expr); } else if (!return_result_via_out_param - && ((m != null && !has_ref_out_param (m)) || (deleg != null && !has_ref_out_param (deleg))) + && !has_ref_out_argument (expr) && (result_type is ValueType && !result_type.is_disposable ())) { set_cvalue (expr, ccall_expr); } else if (!return_result_via_out_param) { @@ -909,9 +909,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { return to_string_func; } - bool has_ref_out_param (Callable c) { - foreach (var param in c.get_parameters ()) { - if (param.direction != ParameterDirection.IN) { + bool has_ref_out_argument (MethodCall c) { + foreach (var arg in c.get_argument_list ()) { + unowned UnaryExpression? unary = arg as UnaryExpression; + if (unary != null && (unary.operator == UnaryOperator.OUT || unary.operator == UnaryOperator.REF)) { return true; } }