]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: small simplification in dwarf2_locexpr_baton_eval
authorAndrew Burgess <aburgess@redhat.com>
Wed, 16 Mar 2022 15:32:50 +0000 (15:32 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Sun, 3 Apr 2022 16:18:20 +0000 (17:18 +0100)
While examining the dwarf expression evaluator, I noticed that in
dwarf2_locexpr_baton_eval, whenever push_initial_value is true, the
addr_stack will never be nullptr.

This allows for a small cleanup, replacing an if/then/else with an
assertion.

There should be no user visible changes after this commit.

gdb/dwarf2/loc.c

index 73de311287662a3ba368db3dbdcb2f97b37bb24d..634b51ef279f69ecbc76dfa74ed4ad215f2b9adc 100644 (file)
@@ -1569,11 +1569,13 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
    CORE_ADDR.  FRAME is the frame in which the expression is
    evaluated.  ADDR_STACK is a context (location of a variable) and
    might be needed to evaluate the location expression.
-   PUSH_INITIAL_VALUE is true if the address (either from ADDR_STACK,
-   or the default of 0) should be pushed on the DWARF expression
-   evaluation stack before evaluating the expression; this is required
-   by certain forms of DWARF expression.  Returns 1 on success, 0
-   otherwise.  */
+
+   PUSH_INITIAL_VALUE is true if the first address from ADDR_STACK, should
+   be pushed on the DWARF expression evaluation stack before evaluating the
+   expression; this is required by certain forms of DWARF expression.  When
+   PUSH_INITIAL_VALUE is true ADDR_STACK can't be nullptr.
+
+   Returns 1 on success, 0 otherwise.  */
 
 static int
 dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
@@ -1595,10 +1597,8 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
 
   if (push_initial_value)
     {
-      if (addr_stack != nullptr)
-       ctx.push_address (addr_stack->addr, false);
-      else
-       ctx.push_address (0, false);
+      gdb_assert (addr_stack != nullptr);
+      ctx.push_address (addr_stack->addr, false);
     }
 
   try