From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aLPFHvqE/GW5lxAAWB0awg (envelope-from ) for ; Thu, 21 Mar 2024 15:05:30 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=GbN7UVzU; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7883E1E0C1; Thu, 21 Mar 2024 15:05:30 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5A9AE1E08C for ; Thu, 21 Mar 2024 15:05:28 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E10C4385829E for ; Thu, 21 Mar 2024 19:05:27 +0000 (GMT) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id 91D133858C24 for ; Thu, 21 Mar 2024 19:03:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91D133858C24 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 91D133858C24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; cv=none; b=jdAb8Cf0wdNl9EiZKy492oYbVV1ctNDoVNcCUfQbhi1IL+ZcTsZih8MqHTr6NvNW7a5wFz7UtM4X5C/luyl5D81ckguAwm7vsyDj4Ntt4A+L0Mz7wknjNwuDkg4ha9ufahlhlNfjeoe9BbuDAk31/AlFbP3ZfI9emxBa7I361Ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711047816; c=relaxed/simple; bh=XqDI63ct79j3ZlcmyzkEnUGfhRnDIVf8nv04a/DqvwE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ejOcLHzZHSWDQ5RkQ3Ixp3uwy1NQ0R5CULiIqR4XULrXjJ7pwKOh52Kt2H5iVNUSkCNE3+9dEOxDe3O/y4LERvyeWQbDfw2ZudznKkPZawibO5XvuyXVrm/dauJF/OId6P4ahE2ulKLrORWNrEm9qbQ5vHQ12qAUBzkHy96Ik20= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7c8713acecfso36163739f.0 for ; Thu, 21 Mar 2024 12:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1711047812; x=1711652612; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=PJyUt0tS67tCdvtMPYZHpwtTyARkRMp277BRGQmdKRk=; b=GbN7UVzUoenK6cA8UfY5KSYeD9K/TpzPEVMZUomMUAjS8U+UQzrwPhYaUD5TxglHhd YqVJJRnRMG1ZnLks6SU0dHWMzOWbAATkI5sqbc3yVI/U5ftkv62DcvGxkqMZuMPSkJeL Kirc2cYXFP9UP53/v4FKSu22Ob60p8J192fvHb1gn4eGJA8wK6mCss6YaZb9rTIlQKFR jQ11qynGm69DO1BNQzPYqrPYRA28emjZ/Enati7zeK7l5j3b2LJZ4Faf5gY3qk7auTm5 IrdkW65jC/EmxIBwjMN7zKdfLGMJwBrIccgQzSwE7KqhY+FAh3IBxh9OZ+2GVFr7pxO/ jH0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711047812; x=1711652612; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PJyUt0tS67tCdvtMPYZHpwtTyARkRMp277BRGQmdKRk=; b=YSYFXmsB5KlRqEiaIIe4p2ya7NH+SQT8N3/ccWhSU2GrDq38zLSkVA3ROeysvWIVeO 3jBgEfjhTnMhb3r6bbrq0o8fy0DEQqsK+RT4F5ZbC5MEOWH9ciDKRhvk/2iVwMGUybZ2 zeW4+l5m/jyQbleUg5otCv7hZ4zIY1CmrlxV/pZekdFxQ3d3jLW0kvzkBNPPCLbKoGsX XrlgQiTnvL3b5INqXHOvzNT6Lun6aSPrA+m7Z8jEPeTpsT+ojG65M9Yge9Ua0p3WJnDF VXX3wZNChz1yb4P43lTUy/gCTIuQA9KaNXwKrwQpDRXW615caWdA/NcJva+02xtBsS5M fK9A== X-Gm-Message-State: AOJu0Yw2ZUBjeSBgUtSay6ZDt5rA7aDNpoEBmAZgoNVXFjJCOxM+Gmw1 xnmvzbqoKEJWz6yVUDFKBH/r1EgWDBG68gZa0gzKoJHWN6+1JCN8yxrJ0jkYKVle/9HJfRCB+cA = X-Google-Smtp-Source: AGHT+IG5d6TCceb4Ha+3UgUf6k0FhVBZFLexmuc4XceivTMmOIuiXawogGwj8le5XjJJnmYkzzSNjA== X-Received: by 2002:a5e:c907:0:b0:7c8:ae00:1e71 with SMTP id z7-20020a5ec907000000b007c8ae001e71mr387893iol.5.1711047811739; Thu, 21 Mar 2024 12:03:31 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dp10-20020a0566381c8a00b00476f2bfc3f8sm53358jab.87.2024.03.21.12.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 12:03:31 -0700 (PDT) From: Tom Tromey Date: Thu, 21 Mar 2024 13:03:33 -0600 Subject: [PATCH 05/12] Move "components" and "associations" into ada_parse_state MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240321-ada-iterated-assign-v1-5-925cdd4f1f4a@adacore.com> References: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org This patch moves the "components" and "associations" globals into ada_parse_state. --- 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 a8066414468..25809b6aa24 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -65,6 +65,8 @@ struct name_info { static struct parser_state *pstate = NULL; +using namespace expr; + /* Data that must be held for the duration of a parse. */ struct ada_parse_state @@ -82,6 +84,12 @@ struct ada_parse_state return result.get (); } + /* The components being constructed during this parse. */ + std::vector components; + + /* The associations being constructed during this parse. */ + std::vector associations; + private: /* We don't have a good way to manage non-POD data in Yacc, so store @@ -126,8 +134,6 @@ static struct type *type_for_char (struct parser_state *, ULONGEST); static struct type *type_system_address (struct parser_state *); -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 @@ -336,16 +342,13 @@ ada_funcall (int nargs) pstate->push (std::move (funcall)); } -/* 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)...)); } /* Examine the final element of the 'components' vector, and return it @@ -355,7 +358,7 @@ push_component (Arg... args) static ada_choices_component * choice_component () { - ada_component *last = components.back ().get (); + ada_component *last = ada_parser->components.back ().get (); return gdb::checked_static_cast (last); } @@ -364,8 +367,8 @@ choice_component () static ada_component_up pop_component () { - ada_component_up result = std::move (components.back ()); - components.pop_back (); + ada_component_up result = std::move (ada_parser->components.back ()); + ada_parser->components.pop_back (); return result; } @@ -380,16 +383,13 @@ pop_components (int n) return result; } -/* 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)...)); } /* Pop the most recent association from the global stack, and return @@ -397,8 +397,8 @@ push_association (Arg... args) static ada_association_up pop_association () { - ada_association_up result = std::move (associations.back ()); - associations.pop_back (); + ada_association_up result = std::move (ada_parser->associations.back ()); + ada_parser->associations.pop_back (); return result; } @@ -1257,8 +1257,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 (); -- 2.43.0