From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id CE1A8385842A; Tue, 2 Apr 2024 17:35:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE1A8385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712079352; bh=rm07/ZvJIyQPuMuwyudRstnzvFic/H205H/qu0U2y74=; h=From:To:Subject:Date:From; b=TZBpmSI6fp+CYn+qcGXrO636SAqBBaLSYsyrmUmZ+yLLdKdhbzdUDtYVcCs4t0odQ uKhKkfjZSiwNxCkH41skQS5tkyh5XdbRmPtH3ppjjRHvPHKRP8u5wOrS0VXbicc+4g 9coH/WsyWzQ+ExQU50uN1x4fKRvNKTKiMyAV4rss= 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 "components" and "associations" into ada_parse_state X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 48497d85e3b839b65d3376fcb8d345680ba68926 X-Git-Newrev: 68d7f5b02f2e2d1eba7dca8701d340674f64329d Message-Id: <20240402173552.CE1A8385842A@sourceware.org> Date: Tue, 2 Apr 2024 17:35:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D68d7f5b02f2e= 2d1eba7dca8701d340674f64329d commit 68d7f5b02f2e2d1eba7dca8701d340674f64329d Author: Tom Tromey Date: Thu Mar 14 12:16:43 2024 -0600 Move "components" and "associations" into ada_parse_state =20 This patch moves the "components" and "associations" globals into ada_parse_state. Diff: --- gdb/ada-exp.y | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index cb0618c2200..be726eccbe2 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -64,6 +64,8 @@ struct name_info { =20 static struct parser_state *pstate =3D NULL; =20 +using namespace expr; + /* Data that must be held for the duration of a parse. */ =20 struct ada_parse_state @@ -81,6 +83,12 @@ struct ada_parse_state return result.get (); } =20 + /* The components being constructed during this parse. */ + std::vector components; + + /* The associations being constructed during this parse. */ + std::vector associations; + private: =20 /* We don't have a good way to manage non-POD data in Yacc, so store @@ -125,8 +133,6 @@ static struct type *type_for_char (struct parser_state = *, ULONGEST); =20 static struct type *type_system_address (struct parser_state *); =20 -using namespace expr; - /* Handle Ada type resolution for OP. DEPROCEDURE_P and CONTEXT_TYPE are passed to the resolve method, if called. */ static operation_up @@ -335,16 +341,13 @@ ada_funcall (int nargs) pstate->push (std::move (funcall)); } =20 -/* The components being constructed during this parse. */ -static std::vector components; - /* Create a new ada_component_up of the indicated type and arguments, and push it on the global 'components' vector. */ template void push_component (Arg... args) { - components.emplace_back (new T (std::forward (args)...)); + ada_parser->components.emplace_back (new T (std::forward (args)...)= ); } =20 /* Examine the final element of the 'components' vector, and return it @@ -354,7 +357,7 @@ push_component (Arg... args) static ada_choices_component * choice_component () { - ada_component *last =3D components.back ().get (); + ada_component *last =3D ada_parser->components.back ().get (); return gdb::checked_static_cast (last); } =20 @@ -363,8 +366,8 @@ choice_component () static ada_component_up pop_component () { - ada_component_up result =3D std::move (components.back ()); - components.pop_back (); + ada_component_up result =3D std::move (ada_parser->components.back ()); + ada_parser->components.pop_back (); return result; } =20 @@ -379,16 +382,13 @@ pop_components (int n) return result; } =20 -/* The associations being constructed during this parse. */ -static std::vector associations; - /* Create a new ada_association_up of the indicated type and arguments, and push it on the global 'associations' vector. */ template void push_association (Arg... args) { - associations.emplace_back (new T (std::forward (args)...)); + ada_parser->associations.emplace_back (new T (std::forward (args)..= .)); } =20 /* Pop the most recent association from the global stack, and return @@ -396,8 +396,8 @@ push_association (Arg... args) static ada_association_up pop_association () { - ada_association_up result =3D std::move (associations.back ()); - associations.pop_back (); + ada_association_up result =3D std::move (ada_parser->associations.back (= )); + ada_parser->associations.pop_back (); return result; } =20 @@ -1256,8 +1256,6 @@ ada_parse (struct parser_state *par_state) lexer_init (yyin); /* (Re-)initialize lexer. */ obstack_free (&temp_parse_space, NULL); obstack_init (&temp_parse_space); - components.clear (); - associations.clear (); assignments.clear (); iterated_associations.clear ();