aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2019-08-25 18:09:47 -0400
committerSimon Marchi <simon.marchi@efficios.com>2019-08-25 18:09:47 -0400
commitbeadd3e84ed8e652015f07eb4734a6d3b17e79cb (patch)
tree760d19a2058f7b19ef9d792d0bb44fd984110325 /gdb/dwarf2read.c
parente3ec872f8012377e50f0c9c888d2bc3163a356b2 (diff)
downloadgdb-beadd3e84ed8e652015f07eb4734a6d3b17e79cb.zip
gdb-beadd3e84ed8e652015f07eb4734a6d3b17e79cb.tar.gz
gdb-beadd3e84ed8e652015f07eb4734a6d3b17e79cb.tar.bz2
dwarf2read: replace gdb::optional<bool> with enum
gdb::optional<bool> is dangerous, because it's easy to do: if (opt_bool) when you actually meant if (*opt_bool) or vice-versa. The first checks if the optional is set, the second checks if the wrapped bool is true. Replace it with an enum that explicitly defines the three possible states. gdb/ChangeLog: * dwarf2read.c (dw2_debug_names_iterator::next): Use enum to represent whether the symbol is static, dynamic, or we don't know.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index de9755f..a0b989f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -5843,7 +5843,11 @@ dw2_debug_names_iterator::next ()
return NULL;
}
const mapped_debug_names::index_val &indexval = indexval_it->second;
- gdb::optional<bool> is_static;
+ enum class symbol_linkage {
+ unknown,
+ static_,
+ extern_,
+ } symbol_linkage = symbol_linkage::unknown;
dwarf2_per_cu_data *per_cu = NULL;
for (const mapped_debug_names::index_val::attr &attr : indexval.attr_vec)
{
@@ -5895,12 +5899,12 @@ dw2_debug_names_iterator::next ()
case DW_IDX_GNU_internal:
if (!m_map.augmentation_is_gdb)
break;
- is_static = true;
+ symbol_linkage = symbol_linkage::static_;
break;
case DW_IDX_GNU_external:
if (!m_map.augmentation_is_gdb)
break;
- is_static = false;
+ symbol_linkage = symbol_linkage::extern_;
break;
}
}
@@ -5910,10 +5914,11 @@ dw2_debug_names_iterator::next ()
goto again;
/* Check static vs global. */
- if (is_static.has_value () && m_block_index.has_value ())
+ if (symbol_linkage != symbol_linkage::unknown && m_block_index.has_value ())
{
const bool want_static = *m_block_index == STATIC_BLOCK;
- if (want_static != *is_static)
+ const bool symbol_is_static = symbol_linkage == symbol_linkage::static_;
+ if (want_static != symbol_is_static)
goto again;
}