[3/7] gdb: convert d_left and d_right macros into functions

Message ID 20261001203105.1379971-4-simon.marchi@efficios.com
State New
Headers
Series Leftovers from parsers cleanup |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed

Commit Message

Simon Marchi Oct. 1, 2026, 8:30 p.m. UTC
  Replace the d_left and d_right macros with static inline functions.
They need to return a reference, because some callers assign to the
result:

  d_right ($1.last) = $2;

and some take the address:

  $$.last = &d_right ($$.comp);

Change-Id: I7d8bd71ffde82a0fdfd2e2dcb87461043f82ef4f
---
 gdb/cp-name-parser.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gdb/cp-name-parser.h b/gdb/cp-name-parser.h
index 083631f20a67..f9d3a6968f9d 100644
--- a/gdb/cp-name-parser.h
+++ b/gdb/cp-name-parser.h
@@ -26,8 +26,21 @@ 
 union cp_name_parser_YYSTYPE;
 struct demangle_parse_info;
 
-#define d_left(dc) (dc)->u.s_binary.left
-#define d_right(dc) (dc)->u.s_binary.right
+/* Return a reference to the left child of binary component DC.  */
+
+static inline struct demangle_component *&
+d_left (struct demangle_component *dc)
+{
+  return dc->u.s_binary.left;
+}
+
+/* Return a reference to the right child of binary component DC.  */
+
+static inline struct demangle_component *&
+d_right (struct demangle_component *dc)
+{
+  return dc->u.s_binary.right;
+}
 
 namespace cp_name_parser {