Remove some variables in favor of using gdb::optional
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 5 Aug 2019 02:44:05 +0000 (22:44 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 5 Aug 2019 02:44:05 +0000 (22:44 -0400)
commit2b79f3761c834cd217407f75f867f6a761703ab3
tree4dcf6e42276048cba74d7ffdbd15507087de63e3
parent188a63736c70060180382e36364a23dcebe3c29c
Remove some variables in favor of using gdb::optional

While reading that code, I noticed that some variables essentially meant
whether to consider some other variable or not.  I think using
gdb::optional (which was not available when this code was written) is
clearer, as it embeds the used/not used predicate directly in the type
of the variable, making it harder to miss.

gdb/ChangeLog:

* dwarf2read.c (struct dw2_symtab_iterator):
<want_specific_block>: Remove.
<block_index>: Change type to gdb::optional.
(dw2_symtab_iter_init): Remove WANT_SPECIFIC_BLOCK parameter,
change type of BLOCK_INDEX parameter to gdb::optional.
(dw2_symtab_iter_next): Re-write in function of gdb::optional.
(dw2_lookup_symbol): Don't pass argument for
WANT_SPECIFIC_BLOCK.
(dw2_expand_symtabs_for_function): Don't pass argument for
WANT_SPECIFIC_BLOCK, pass empty optional for BLOCK_INDEX.
(class dw2_debug_names_iterator)
<dw2_debug_names_iterator>: Remove WANT_SPECIFIC_BLOCK
parameter, change BLOCK_INDEX type to gdb::optional.
<m_want_specific_block>: Remove.
<m_block_index>: Change type to gdb::optional.
(dw2_debug_names_iterator::next): Change type of IS_STATIC to
gdb::optional.  Re-write in function of gdb::optional.
(dw2_debug_names_lookup_symbol): Don't pass argument for
WANT_SPECIFIC_BLOCK.
(dw2_debug_names_expand_symtabs_for_function): Don't pass
argument for WANT_SPECIFIC_BLOCK, pass empty optional for
BLOCK_INDEX.
gdb/ChangeLog
gdb/dwarf2read.c