From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by sourceware.org (Postfix) with ESMTPS id 787A8382D45B for ; Fri, 27 May 2022 18:03:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 787A8382D45B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f54.google.com with SMTP id c9-20020a7bc009000000b0039750ec5774so3125796wmb.5 for ; Fri, 27 May 2022 11:03:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jz77euorOQ+3wmzt8y2Kl6V5Z2Ouj5xu+/5+eKdt1PQ=; b=s1dK9xVpJfUxevzoNUhAQoHrziTZHgAZ2xznNSqDswSSa5a7nYQ9fY3tB12hLFhp3z 9aN90/42RyftbYWRJC52eMhY2o03PCr4ZcQ15mATdhrQZSB16VGoIAupI4/HopL/ugc/ Jeq21hjAA2F8au+vPYyYlAni+WWnoN1IC7qBD4SQj77QDrjAxiDgP1JcIO7guEqV+FHn 2ZWm+1iX+dJ219QOUuuZLL7GogMWN2q+mzzrHKWAxtx6fb8SS2/oEdJ7q78o0awlCrxu gyHALAUTtqxxbBAdXaOkCMSodC4GsbwqYsxzoBxOQzZwc2QlUaoseSrWZ4xvSVuCoGZR VKbw== X-Gm-Message-State: AOAM533jqjSKGdFrG+TfIgeV6cXD5O7WTEkvW6xxNIvg2PbpGV60NU43 LfgE39MtJueGonxJ5HeEVYnwH7O/76Q= X-Google-Smtp-Source: ABdhPJz05mVRPmfETUjLTZ8b4jUKg7+EwREGsxnd/72QgKQi/N5dieRqbjsTIOo6Hb7/VsRgmkkmwA== X-Received: by 2002:a05:600c:1c9f:b0:397:7ac4:b29c with SMTP id k31-20020a05600c1c9f00b003977ac4b29cmr7857980wms.155.1653674591605; Fri, 27 May 2022 11:03:11 -0700 (PDT) Received: from localhost ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id i7-20020a5d5847000000b002101ed6e70fsm1412807wrf.37.2022.05.27.11.03.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 May 2022 11:03:10 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 7/7] Convert set_location_spec_string to a method Date: Fri, 27 May 2022 19:02:48 +0100 Message-Id: <20220527180248.2990723-8-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220527180248.2990723-1-pedro@palves.net> References: <20220527180248.2990723-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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-List-Received-Date: Fri, 27 May 2022 18:03:15 -0000 This converts set_location_spec_string to a method of location_spec, and makes the location_spect::as_string field protected, renaming it it to m_as_string along the way. Change-Id: Iccfb1654e9fa7808d0512df89e775f9eacaeb9e0 --- gdb/linespec.c | 2 +- gdb/location.c | 13 ++----------- gdb/location.h | 29 +++++++++++++++-------------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 5c75e2ec979..e45c606d661 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2015,7 +2015,7 @@ canonicalize_linespec (struct linespec_state *state, const linespec *ls) /* If this location originally came from a linespec, save a string representation of it for display and saving to file. */ if (state->is_linespec) - set_location_spec_string (explicit_loc, explicit_loc->to_linespec ()); + explicit_loc->set_spec_string (explicit_loc->to_linespec ()); } /* Given a line offset in LS, construct the relevant SALs. */ diff --git a/gdb/location.c b/gdb/location.c index e22ee414070..2b31baa4c85 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -60,7 +60,7 @@ probe_location_spec::empty_p () const std::string probe_location_spec::compute_string () const { - return std::move (as_string); + return std::move (m_as_string); } /* A "normal" linespec. */ @@ -131,7 +131,7 @@ address_location_spec::address_location_spec (CORE_ADDR addr, address (addr) { if (addr_string != nullptr) - as_string = std::string (addr_string, addr_string_len); + m_as_string = std::string (addr_string, addr_string_len); } location_spec_up @@ -857,12 +857,3 @@ string_to_location_spec (const char **stringp, spec. */ return string_to_location_spec_basic (stringp, language, match_type); } - -/* See description in location.h. */ - -void -set_location_spec_string (struct location_spec *locspec, - std::string &&string) -{ - locspec->as_string = std::move (string); -} diff --git a/gdb/location.h b/gdb/location.h index 69524713402..66ace484f5e 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -91,11 +91,11 @@ struct location_spec The result is cached in the locspec. */ const char *to_string () const { - if (as_string.empty ()) - as_string = compute_string (); - if (as_string.empty ()) + if (m_as_string.empty ()) + m_as_string = compute_string (); + if (m_as_string.empty ()) return nullptr; - return as_string.c_str (); + return m_as_string.c_str (); } /* Return this location spec's type. */ @@ -104,9 +104,11 @@ struct location_spec return m_type; } - /* Cached string representation of this location spec. This is - used, e.g., to save location specs to file. */ - mutable std::string as_string; + /* Set the location specs's string representation. */ + void set_spec_string (std::string &&string) + { + m_as_string = std::move (string); + } protected: @@ -116,13 +118,13 @@ struct location_spec } location_spec (enum location_spec_type t, std::string &&str) - : as_string (std::move (str)), + : m_as_string (std::move (str)), m_type (t) { } location_spec (const location_spec &other) - : as_string (other.as_string), + : m_as_string (other.m_as_string), m_type (other.m_type) { } @@ -131,6 +133,10 @@ struct location_spec by to_string when needed. */ virtual std::string compute_string () const = 0; + /* Cached string representation of this location spec. This is + used, e.g., to save location specs to file. */ + mutable std::string m_as_string; + private: /* The type of this location specification. */ enum location_spec_type m_type; @@ -361,9 +367,4 @@ extern location_spec_up const struct language_defn *language, explicit_completion_info *completion_info); -/* Set the location specs's string representation. */ - -extern void set_location_spec_string (struct location_spec *locspec, - std::string &&string); - #endif /* LOCATION_H */ -- 2.36.0