From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 2/7] Move ada_tick_completer to ada-exp-parser.c
Date: Thu, 19 Nov 2026 10:58:17 -0700 [thread overview]
Message-ID: <20261119-more-parser-cleanups-v1-2-d85241f3fede@adacore.com> (raw)
In-Reply-To: <20261119-more-parser-cleanups-v1-0-d85241f3fede@adacore.com>
There's no need to declare ada_tick_completer in the header file, so
move it to ada-exp-parser.c. This also changes it to use
make_unique_xstrdup.
---
gdb/ada-exp-parser.c | 85 +++++++++++++++++++++++++++++-----------------------
gdb/ada-exp-parser.h | 16 ----------
2 files changed, 48 insertions(+), 53 deletions(-)
diff --git a/gdb/ada-exp-parser.c b/gdb/ada-exp-parser.c
index dbea55abba6..2757877b605 100644
--- a/gdb/ada-exp-parser.c
+++ b/gdb/ada-exp-parser.c
@@ -113,6 +113,54 @@ struct code_entry
int code;
};
+static const struct code_entry attributes[] =
+{
+ { "address", TICK_ADDRESS },
+ { "unchecked_access", TICK_ACCESS },
+ { "unrestricted_access", TICK_ACCESS },
+ { "access", TICK_ACCESS },
+ { "first", TICK_FIRST },
+ { "last", TICK_LAST },
+ { "length", TICK_LENGTH },
+ { "max", TICK_MAX },
+ { "min", TICK_MIN },
+ { "modulus", TICK_MODULUS },
+ { "object_size", TICK_OBJECT_SIZE },
+ { "pos", TICK_POS },
+ { "range", TICK_RANGE },
+ { "size", TICK_SIZE },
+ { "tag", TICK_TAG },
+ { "val", TICK_VAL },
+ { "enum_rep", TICK_ENUM_REP },
+ { "enum_val", TICK_ENUM_VAL },
+};
+
+/* Expression completer for attributes. */
+struct ada_tick_completer : public expr_completion_base
+{
+ explicit ada_tick_completer (std::string &&name)
+ : m_name (std::move (name))
+ {
+ }
+
+ bool complete (struct expression *exp,
+ completion_tracker &tracker) override
+ {
+ completion_list output;
+ for (const auto &item : attributes)
+ {
+ if (strncasecmp (item.name, m_name.c_str (), m_name.length ()) == 0)
+ output.push_back (make_unique_xstrdup (item.name));
+ }
+ tracker.add_completions (std::move (output));
+ return true;
+ }
+
+private:
+
+ std::string m_name;
+};
+
/* See ada-exp-parser.h. */
struct parser_state *pstate;
@@ -384,29 +432,6 @@ subseqMatch (const char *subseq, const char *str)
return subseqMatch (subseq, str+1);
}
-
-static const struct code_entry attributes[] =
-{
- { "address", TICK_ADDRESS },
- { "unchecked_access", TICK_ACCESS },
- { "unrestricted_access", TICK_ACCESS },
- { "access", TICK_ACCESS },
- { "first", TICK_FIRST },
- { "last", TICK_LAST },
- { "length", TICK_LENGTH },
- { "max", TICK_MAX },
- { "min", TICK_MIN },
- { "modulus", TICK_MODULUS },
- { "object_size", TICK_OBJECT_SIZE },
- { "pos", TICK_POS },
- { "range", TICK_RANGE },
- { "size", TICK_SIZE },
- { "tag", TICK_TAG },
- { "val", TICK_VAL },
- { "enum_rep", TICK_ENUM_REP },
- { "enum_val", TICK_ENUM_VAL },
-};
-
/* See ada-exp-parser.h. */
int
@@ -439,20 +464,6 @@ ada_parse_state::process_attribute (const std::string &str, bool completing)
return *found;
}
-bool
-ada_tick_completer::complete (struct expression *exp,
- completion_tracker &tracker)
-{
- completion_list output;
- for (const auto &item : attributes)
- {
- if (strncasecmp (item.name, m_name.c_str (), m_name.length ()) == 0)
- output.emplace_back (xstrdup (item.name));
- }
- tracker.add_completions (std::move (output));
- return true;
-}
-
int
ada_parse_state::lex_number ()
{
diff --git a/gdb/ada-exp-parser.h b/gdb/ada-exp-parser.h
index 682d868d528..4de2263ed6c 100644
--- a/gdb/ada-exp-parser.h
+++ b/gdb/ada-exp-parser.h
@@ -159,22 +159,6 @@ struct ada_parse_state
bool m_before_qual_quote = false;
};
-/* Expression completer for attributes. */
-struct ada_tick_completer : public expr_completion_base
-{
- explicit ada_tick_completer (std::string &&name)
- : m_name (std::move (name))
- {
- }
-
- bool complete (struct expression *exp,
- completion_tracker &tracker) override;
-
-private:
-
- std::string m_name;
-};
-
/* The current state of the parser, used internally when parsing an
expression. */
--
2.56.0
next prev parent reply other threads:[~2026-11-19 17:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 17:58 [PATCH 0/7] More minor parser-related cleanups Tom Tromey
2026-11-19 17:58 ` [PATCH 1/7] Use compiled_regex in rust-parse.c Tom Tromey
2026-11-19 17:58 ` Tom Tromey [this message]
2026-11-19 17:58 ` [PATCH 3/7] Change some Ada parser functions into methods Tom Tromey
2026-11-19 18:48 ` Simon Marchi
2026-11-20 20:57 ` Tom Tromey
2026-11-19 17:58 ` [PATCH 4/7] Simplify post-process-parser-output.sh Tom Tromey
2026-11-19 17:58 ` [PATCH 5/7] Remove fixed-sized buffer from ada_parse_state::lex_number Tom Tromey
2026-11-19 17:58 ` [PATCH 6/7] Hoist calls to canonicalize_numeral Tom Tromey
2026-11-19 17:58 ` [PATCH 7/7] Remove canonicalize_numeral Tom Tromey
2026-11-19 18:55 ` [PATCH 0/7] More minor parser-related cleanups Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119-more-parser-cleanups-v1-2-d85241f3fede@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox