public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Move "int_storage" global into ada_parse_state
@ 2024-04-02 17:35 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-04-02 17:35 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=48497d85e3b839b65d3376fcb8d345680ba68926

commit 48497d85e3b839b65d3376fcb8d345680ba68926
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Mar 14 12:13:30 2024 -0600

    Move "int_storage" global into ada_parse_state
    
    This patch moves the "int_storage" global into ada_parse_state.

Diff:
---
 gdb/ada-exp.y | 17 +++++++++++------
 gdb/ada-lex.l |  3 +--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 80c1edc792b..cb0618c2200 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -75,8 +75,19 @@ struct ada_parse_state
 
   std::string find_completion_bounds ();
 
+  const gdb_mpz *push_integer (gdb_mpz &&val)
+  {
+    auto &result = m_int_storage.emplace_back (new gdb_mpz (std::move (val)));
+    return result.get ();
+  }
+
 private:
 
+  /* We don't have a good way to manage non-POD data in Yacc, so store
+     values here.  The storage here is only valid for the duration of
+     the parse.  */
+  std::vector<std::unique_ptr<gdb_mpz>> m_int_storage;
+
   /* The original expression string.  */
   const char *m_original_expr;
 };
@@ -85,11 +96,6 @@ private:
 
 static ada_parse_state *ada_parser;
 
-/* We don't have a good way to manage non-POD data in Yacc, so store
-   values here.  The storage here is only valid for the duration of
-   the parse.  */
-static std::vector<std::unique_ptr<gdb_mpz>> int_storage;
-
 int yyparse (void);
 
 static int yylex (void);
@@ -1252,7 +1258,6 @@ ada_parse (struct parser_state *par_state)
   obstack_init (&temp_parse_space);
   components.clear ();
   associations.clear ();
-  int_storage.clear ();
   assignments.clear ();
   iterated_associations.clear ();
 
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index e1abf9adc25..109b95ccc35 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -465,8 +465,7 @@ processInt (struct parser_state *par_state, const char *base0,
       return FLOAT;
     }
 
-  const gdb_mpz *value
-    = int_storage.emplace_back (new gdb_mpz (std::move (result))).get ();
+  const gdb_mpz *value = ada_parser->push_integer (std::move (result));
 
   int int_bits = gdbarch_int_bit (par_state->gdbarch ());
   int long_bits = gdbarch_long_bit (par_state->gdbarch ());

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-02 17:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 17:35 [binutils-gdb] Move "int_storage" global into ada_parse_state Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).