From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id B398D3858412; Tue, 2 Apr 2024 17:35:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B398D3858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712079347; bh=JAhfWFT0DyDqy26w5dVyVcZnzLv39xGqBo3du2XQe7g=; h=From:To:Subject:Date:From; b=MjkzUIF7GIScIxnTr/TvpqQSvXX1og8sBTqotPykV4YlfRyvGv9XDlltebBJ1yBOe vdNcboQNqWHxUkS34rzTEu/M9amHxklJyzmKjd9/L+xGbas4g/+kAiAUNL1b0AQ/t0 D6av5ONHVYGFymx/LX8+rnXNUDPDcy289STlSIeg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Move "int_storage" global into ada_parse_state X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: b64e3e1c36eec33cd535cee7ff65de0e3e826e31 X-Git-Newrev: 48497d85e3b839b65d3376fcb8d345680ba68926 Message-Id: <20240402173547.B398D3858412@sourceware.org> Date: Tue, 2 Apr 2024 17:35:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D48497d85e3b8= 39b65d3376fcb8d345680ba68926 commit 48497d85e3b839b65d3376fcb8d345680ba68926 Author: Tom Tromey Date: Thu Mar 14 12:13:30 2024 -0600 Move "int_storage" global into ada_parse_state =20 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 =20 std::string find_completion_bounds (); =20 + const gdb_mpz *push_integer (gdb_mpz &&val) + { + auto &result =3D m_int_storage.emplace_back (new gdb_mpz (std::move (v= al))); + return result.get (); + } + private: =20 + /* 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> m_int_storage; + /* The original expression string. */ const char *m_original_expr; }; @@ -85,11 +96,6 @@ private: =20 static ada_parse_state *ada_parser; =20 -/* 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> int_storage; - int yyparse (void); =20 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 (); =20 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; } =20 - const gdb_mpz *value - =3D int_storage.emplace_back (new gdb_mpz (std::move (result))).get (); + const gdb_mpz *value =3D ada_parser->push_integer (std::move (result)); =20 int int_bits =3D gdbarch_int_bit (par_state->gdbarch ()); int long_bits =3D gdbarch_long_bit (par_state->gdbarch ());