From patchwork Mon Apr 24 19:04:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 68234 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 339A83858D28 for ; Mon, 24 Apr 2023 19:04:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 339A83858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682363078; bh=TrW9Qg5VM5rzUo3iKk6YGv0IYopGQaq4ipXWN+9wvHU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=u4bj0KijI65ml4SBRZ1luJWOP1KDqVu3bDfKeG9W2/oYqAghGNLkfYQT5i0HHwBL2 dhvpdMJyb61TO8dCBP4IZLKz/07JvE8z84hYYIgfUaXEmCDGvrw3P8CGeb84MZP/6W 6qaRYo2GQAyPdlbJoVmE6j29yx+K5FRb97F+5Ddg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 2B7AC3858D28 for ; Mon, 24 Apr 2023 19:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B7AC3858D28 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-763ae160c47so256390639f.3 for ; Mon, 24 Apr 2023 12:04:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682363053; x=1684955053; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TrW9Qg5VM5rzUo3iKk6YGv0IYopGQaq4ipXWN+9wvHU=; b=fDCo8oLrTya0gqouwq1LlrXMNOF/gBhJzA4SnyqSYnj9HBmYw0fjwEe4D37e7bzRMK bHNLIOWOKJU8aDiWrzQX/B0iY6ZkCe7ZrqSFV/HmrUqfw8H1n4vCRsriIEGy8etPMcyF B3rsD0z8jruyNs2S+GmYmZcF3RiaT/sbNKVH3SJxmDE671Ayjd2JL4PZoeJvUIEeZQ99 zEUR2i0SSL7tioHw++hWTfUZU6WHTe4ijW7wSOUumCPCxqm32cBOpwCb8C+0uJOJydWk 7pFqZDleMP6goCPfV42fVkMlvLeEbBstTtZeW33q0k11CeKhvQjSADL54m9sV650b7lA 5DVA== X-Gm-Message-State: AAQBX9f+45R7YotG7jGU/8caIwynoXPbPHoIWFedi5rGu20wi7ggX7sm 7baH0dpu+NVLLv5q1xAMccHoLt2pknHaXZoQ2rN4/g== X-Google-Smtp-Source: AKy350Ypu7t62hJMKjRZoNCx8OLnqr6ss9cBMN12xRLS4iIxcWBND9AApummhpZT/7pFxNleIF/n7w== X-Received: by 2002:a6b:d609:0:b0:760:b712:96d0 with SMTP id w9-20020a6bd609000000b00760b71296d0mr6116884ioa.8.1682363053441; Mon, 24 Apr 2023 12:04:13 -0700 (PDT) Received: from localhost.localdomain (71-211-191-82.hlrn.qwest.net. [71.211.191.82]) by smtp.gmail.com with ESMTPSA id a10-20020a5d980a000000b0076373f90e46sm3420245iol.33.2023.04.24.12.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 12:04:12 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove some "goto"s from parse.c Date: Mon, 24 Apr 2023 13:04:03 -0600 Message-Id: <20230424190403.1550146-1-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" parser_state::push_dollar has some unnecessary "goto"s. Replacing them cleans up the code. Regression tested on x86-64 Fedora 36. --- gdb/parse.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/gdb/parse.c b/gdb/parse.c index 0588c0618c6..85a6caf14ba 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -268,7 +268,8 @@ parser_state::push_dollar (struct stoken str) { /* Just dollars (one or two). */ i = -negate; - goto handle_last; + push_new (i); + return; } /* Is the rest of the token digits? */ for (; i < str.length; i++) @@ -279,7 +280,8 @@ parser_state::push_dollar (struct stoken str) i = atoi (str.ptr + 1 + negate); if (negate) i = -i; - goto handle_last; + push_new (i); + return; } /* Handle tokens that refer to machine registers: @@ -287,7 +289,14 @@ parser_state::push_dollar (struct stoken str) i = user_reg_map_name_to_regnum (gdbarch (), str.ptr + 1, str.length - 1); if (i >= 0) - goto handle_register; + { + str.length--; + str.ptr++; + push_new (copy_name (str)); + block_tracker->update (expression_context_block, + INNERMOST_BLOCK_FOR_REGISTERS); + return; + } /* Any names starting with $ are probably debugger internal variables. */ @@ -319,17 +328,6 @@ parser_state::push_dollar (struct stoken str) push_new (create_internalvar (copy.c_str () + 1)); - return; -handle_last: - push_new (i); - return; -handle_register: - str.length--; - str.ptr++; - push_new (copy_name (str)); - block_tracker->update (expression_context_block, - INNERMOST_BLOCK_FOR_REGISTERS); - return; }