From dc4187ed57d6cf648aa6dc4b4fceafab0a8b1a98 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 24 Nov 2025 23:04:30 -0500 Subject: [PATCH] gdb/dwarf: remove nullptr prop check in dwarf2_evaluate_property This nullptr is pointless most of the time: almost all callers either check that the prop is not nullptr or they pass the address of a local variable, which is necessarily not nullptr. I propose to remove it. I found only one call site where I needed to add a check. Change-Id: Iada84d529b8edc6b20486f3539c675dad6b364f5 Approved-By: Tom Tromey --- gdb/dwarf2/loc.c | 3 --- gdb/gdbtypes.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 73e744c8b97..9ab0c70b8f7 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1646,9 +1646,6 @@ dwarf2_evaluate_property (const dynamic_prop *prop, CORE_ADDR *value, gdb::array_view push_values) { - if (prop == NULL) - return false; - /* Evaluating a property should not change the current language. Without this here this could happen if the code below selects a frame. */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9e3c07e0ee5..6736de96c04 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2431,7 +2431,8 @@ resolve_dynamic_array_or_string (struct type *type, /* Resolve the rank property to get rank value. */ struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_RANK); - if (dwarf2_evaluate_property (prop, frame, addr_stack, &value)) + if (prop != nullptr + && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) { prop->set_const_val (value); rank = value; -- 2.47.3