]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move "int_storage" global into ada_parse_state
authorTom Tromey <tromey@adacore.com>
Thu, 14 Mar 2024 18:13:30 +0000 (12:13 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 2 Apr 2024 17:24:27 +0000 (11:24 -0600)
This patch moves the "int_storage" global into ada_parse_state.

gdb/ada-exp.y
gdb/ada-lex.l

index 80c1edc792b66ea46d0f7f41da24b1c23046292a..cb0618c220003fbcb788a8329abb74544c7d608a 100644 (file)
@@ -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 ();
 
index e1abf9adc25c020f7389654518d412efb6935d63..109b95ccc352fb47db57237e3d3e99f600314c37 100644 (file)
@@ -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 ());