Change ada_which_variant_applies to value API

While debugging an Ada regression, I noticed that all the callers of
ada_which_variant_applies desconstruct a value, only to have it be
reconstructed by this function.

This patch removes this inefficiency in favor of simply passing in the
value directly.

Tested on x86-64 Fedora 30.

gdb/ChangeLog
2020-03-30  Tom Tromey  <tromey@adacore.com>

	* ada-valprint.c (print_variant_part): Update.
	* ada-lang.h (ada_which_variant_applies): Update.
	* ada-lang.c (ada_which_variant_applies): Remove outer_type and
	outer_valaddr parameters; replace with "outer" value parameter.
	(to_fixed_variant_branch_type): Update.
This commit is contained in:
Tom Tromey
2020-03-30 11:50:35 -06:00
parent 00386881a3
commit d8af906814
4 changed files with 13 additions and 15 deletions

View File

@@ -560,9 +560,7 @@ print_variant_part (struct value *value, int field_num,
{
struct type *type = value_type (value);
struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
int which = ada_which_variant_applies (var_type,
value_type (outer_value),
value_contents (outer_value));
int which = ada_which_variant_applies (var_type, outer_value);
if (which < 0)
return 0;