summaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.h
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-04-19 09:40:20 -0600
committerTom Tromey <tromey@adacore.com>2023-05-12 12:30:28 -0600
commit9c0fb73485cb2c90bb10cb4d3cf1d27e36f9ff01 (patch)
tree88f1ca4555a484b28c4fcbe822ac8c925835fd8b /gdb/gdbtypes.h
parent14e8fded85efa824e6652ed876229e5c24758b72 (diff)
downloadbinutils-gdb-9c0fb73485cb2c90bb10cb4d3cf1d27e36f9ff01.tar.gz
Add dynamic_prop::is_constant
I noticed many spots checking whether a dynamic property's kind is PROP_CONST. Some spots, I think, are doing a slightly incorrect check -- checking for != PROP_UNDEFINED where == PROP_CONST is actually required, the key thing being that const_val may only be called for PROP_CONST properties. This patch adds dynamic::is_constant and then updates these checks to use it. Regression tested on x86-64 Fedora 36.
Diffstat (limited to 'gdb/gdbtypes.h')
-rw-r--r--gdb/gdbtypes.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 9254ec994e3..319a7731bca 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -340,6 +340,11 @@ struct dynamic_prop
m_data.const_val = const_val;
}
+ /* Return true if this property has a constant value, false
+ otherwise. */
+ bool is_constant () const
+ { return m_kind == PROP_CONST; }
+
const dwarf2_property_baton *baton () const
{
gdb_assert (m_kind == PROP_LOCEXPR