From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4C34F3858D28 for ; Fri, 22 Sep 2023 20:42:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C34F3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695415355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xbzGWdKNeFV9Pmyz7JFyiVlNx2MUZ8rTdYWjtduUIEk=; b=TGRdtzV9DxWGODmfLNMBC3iQ54Q/LFYDt5H55HBntjiAMwYZOuWwpKC18Bd2VmycV/T7Uc 0E95Zu/IXyP98RcQizxfRVmwBhuUOnAWQy+rLmz8YscAhcGc0MHqv8d5F0CpEIGQsTni4j VdnzxrdH6RK42FxF3jnwDlV54uge66s= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-19jetXG7MAuCmlxKGptRjQ-1; Fri, 22 Sep 2023 16:42:33 -0400 X-MC-Unique: 19jetXG7MAuCmlxKGptRjQ-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-59c07ca1b44so41635767b3.3 for ; Fri, 22 Sep 2023 13:42:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695415353; x=1696020153; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xbzGWdKNeFV9Pmyz7JFyiVlNx2MUZ8rTdYWjtduUIEk=; b=ZYylhMK3ru1bKdOKlKafdahRUpnjHDD39O42L/1AU7Bt4J0MSjZoHEZvC3MDdJyUQu qFFDKtBYmrT0rKLQclDOBZWMfJbdWLWLwwipHuWxnjxw+J6im5FA0bzB/jRLW97g1sWK fNidSMzIeqjtk/C3iFYG7NqaJr3HAihxRjW1iP2hfLC1GpC+O43Bj5Qrl95fcN2GjeoV 2vPJw6Da6mJa++VA8+p9nva7aPaN0IvEyiWDCmPqDV0jn7ww8RR4Uxnb2uDp5E7SQZl6 SJk3pv0yPm6Fj0pIug7hT/F0kE6P2fHF9dQwohXB8g3+Qrv5w9rmQhBmWF5PmIYg4US+ 3E9w== X-Gm-Message-State: AOJu0YwaGNbh4+P8g+V5+D6bz9AhAji9PtbTuk7Fo5xlPbIK878HOtma kPF/LnvrPifN8Nr4HrcFHdkYPU1t3oQwXQ5d0P9lsgAQUHuMkUz2FwmiBLPxcZOYOB0LUxPglaG CqBvPC0Z0RW20Jt9U4w58LBo2TlLf11bEY9GV3A== X-Received: by 2002:a0d:dec6:0:b0:59b:a2a:2131 with SMTP id h189-20020a0ddec6000000b0059b0a2a2131mr671029ywe.31.1695415353206; Fri, 22 Sep 2023 13:42:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1PFPDPt4bf9pdSiJmy0eGAGqyrpDT8AdAuMGz61twX4OxBW5O4JwTa7+ET75Y1sOhox+4Q5fyQQx5Tagib+c= X-Received: by 2002:a0d:dec6:0:b0:59b:a2a:2131 with SMTP id h189-20020a0ddec6000000b0059b0a2a2131mr671021ywe.31.1695415352954; Fri, 22 Sep 2023 13:42:32 -0700 (PDT) MIME-Version: 1.0 References: <20230921194207.2401885-1-tromey@adacore.com> In-Reply-To: <20230921194207.2401885-1-tromey@adacore.com> From: Keith Seitz Date: Fri, 22 Sep 2023 13:42:22 -0700 Message-ID: Subject: Re: [PATCH] Use string_file::release in some places To: Tom Tromey Cc: gdb-patches@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Thu, Sep 21, 2023 at 12:42=E2=80=AFPM Tom Tromey via Gdb-patches wrote: > > I found a few spots like: > > string_file f; > std::string x =3D f.string (); > > However, string_file::string returns a 'const std::string &'... so it > seems to me that this must be copying the string (? I find it hard to > reason about this in C++). I admit, you now have me doubting everything I thought I remembered on this subject! [TODO: reread the standard literature] As far as I can tell, your assessment is at least consistent with what is done elsewhere, e.g., location.c, ada-lang,c, and just about everywhere else except the two locations you've identified in this patch. Would symtab.c's symbol_to_info_string and valops.c:incomplete_type_hint also qualify for similar treatment? They use addition assignment, so maybe that alters the analogy? In any case: Reviewed-by: Keith Seitz Keith