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.129.124]) by sourceware.org (Postfix) with ESMTPS id 96DAB3858D20 for ; Sat, 5 Nov 2022 02:00:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96DAB3858D20 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=1667613617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FKoScuFQeVqqMaF5xTj+O6uFprq7140TP2V2RFlbD94=; b=Sip2IkuN+DE5zibr78FwTZCAf370dDAHvjvvxw4AeLd3BphTBcJhxlJ18qUUdfFAYJtRHQ ePhUrJtDf95T8aExnYHmbBIivKC9oV586GcXug4OK5Tr0VBkEJRDUVPcWJvvWw7QFtrE+b M3JdjO4cpZN2Xge5bKDJJEJFMYev8vw= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-57-l7bPf1FSPL2BoEWGqH1FdQ-1; Fri, 04 Nov 2022 22:00:15 -0400 X-MC-Unique: l7bPf1FSPL2BoEWGqH1FdQ-1 Received: by mail-qv1-f70.google.com with SMTP id ng1-20020a0562143bc100b004bb706b3a27so4385224qvb.20 for ; Fri, 04 Nov 2022 19:00:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FKoScuFQeVqqMaF5xTj+O6uFprq7140TP2V2RFlbD94=; b=LHmrNY19zKxEvRwU6GhjcqcpXZdwWK/RkZwrJw9DS9WLbQJ/FGjiwxOu3dzrK7Tb2x NzHsJm641Cle3W0P41HLYShLYcEo7eVB5Kye4Kzr9scHbnHcyVVkECSiDxkHA1E25RGJ ZptWyeRSy6Bn0RmlNNz8SbOPXEUQNeJXdb4aY2ZbAT+u+WqDiBuqxvERqLUBFRifYjIH Jg9v73puybYH4bpRvlSBzBGdvR/ZBCgYfnzFtvWhLY+wYPcE+D6pkSE4DbKmC0kie9Ql CjCF/RwcVYF0gS4YL7wNzTaFP/cmAAOFqWgCIaTZoremCO8FwHQE2Nuz2UOyCjjzxMkM Ey7w== X-Gm-Message-State: ACrzQf1TJtQu2UdadpUja+SgKXt8PAKiKmz6zpFrpGLt3bQKVhbibnPa d5wJhntzsKIRqD/qL2av6Mr0mpI29k40Ws0edp0kjeK7F26tgGIMu94OSBtPugRdh+mscs9ynik oTaxEYfy/5Kd4SUWVcw== X-Received: by 2002:a05:6214:508c:b0:4bb:b2b1:c0b6 with SMTP id kk12-20020a056214508c00b004bbb2b1c0b6mr34877576qvb.109.1667613615415; Fri, 04 Nov 2022 19:00:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5xDPt0gd/fQ4XsXOmnvlOd6G3yjF0yWbgE12PVLvSFIxOPHVAYB7AHQHIq0bQzrRMk4gch0w== X-Received: by 2002:a05:6214:508c:b0:4bb:b2b1:c0b6 with SMTP id kk12-20020a056214508c00b004bbb2b1c0b6mr34877561qvb.109.1667613615187; Fri, 04 Nov 2022 19:00:15 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id fz27-20020a05622a5a9b00b0038b684a1642sm755302qtb.32.2022.11.04.19.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 19:00:14 -0700 (PDT) Message-ID: <0166aa743765270a1a5515472e6191a24a16fdb4.camel@redhat.com> Subject: Re: [PATCH RFA] input: add get_source_text_between From: David Malcolm To: Jason Merrill , gcc-patches@gcc.gnu.org Date: Fri, 04 Nov 2022 22:00:14 -0400 In-Reply-To: <45256879-92f2-6a99-40a9-4f2be0ecfe96@redhat.com> References: <20221103195902.2114479-1-jason@redhat.com> <906b1326bd95c094331f7a5ff46723986215e3cf.camel@redhat.com> <22136833-3ba8-686b-4eae-a709f2c1780d@redhat.com> <41648997dfcb55920d54e93622501d4264068911.camel@redhat.com> <45256879-92f2-6a99-40a9-4f2be0ecfe96@redhat.com> User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 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=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 Fri, 2022-11-04 at 13:06 -0400, Jason Merrill wrote: > On 11/4/22 11:16, David Malcolm wrote: > > On Fri, 2022-11-04 at 10:27 -0400, Jason Merrill wrote: > > > On 11/3/22 19:06, David Malcolm wrote: > > > > On Thu, 2022-11-03 at 15:59 -0400, Jason Merrill via Gcc- > > > > patches > > > > wrote: > >=20 > > [...snip...] > >=20 > > > >=20 > > > >=20 > > > > Do you have test coverage for this from the DejaGnu side?=C2=A0 If > > > > not, > > > > you > > > > could add selftest coverage for this; see input.cc's > > > > test_reading_source_line for something similar. > > >=20 > > > There is test coverage for the output of the the contract > > > violation > > > handler, which involves printing the result of this function. > >=20 > > Thanks. =C2=A0 Is this test posted somwehere?=C2=A0 I was looking in: > > =C2=A0 > > https://gcc.gnu.org/pipermail/gcc-patches/2022-November/604974.html > > but I'm not seeing it.=C2=A0 Sorry if I'm missing something here. >=20 > The tests are in the newer message >=20 > =C2=A0=C2=A0 > https://gcc.gnu.org/pipermail/gcc-patches/2022-November/605072.html >=20 > > Ideally we should have coverage for the three cases of: > > (a) bails out and returns NULL >=20 > This isn't tested because it should never happen. I'm guessing someone will run into it in the wild at some point. With very large files we eventually give up on tracking column numbers, and so we get location_t values with column number =3D=3D 0, and FWIW gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c makes it feasible to test such cases. But obviously that's low priority. Dave >=20 > > (b) single-line case >=20 > contracts-tmpl-spec3.C etc. >=20 > > (c) multi-line case >=20 > contracts-multiline1.C >=20 > > > index a28abfac5ac..04d0809bfdf 100644 > > > --- a/gcc/input.cc > > > +++ b/gcc/input.cc > > > @@ -949,6 +949,97 @@ location_get_source_line (const char > > > *file_path, int line) > > > =C2=A0=C2=A0=C2=A0 return char_span (buffer, len); > > > =C2=A0 } > >=20 > > Strings in input.cc are not always NUL-terminated, so... > >=20 > > > =C2=A0=20 > > > +/* Return a copy of the source text between two locations.=C2=A0 The > > > caller is > > > +=C2=A0=C2=A0 responsible for freeing the return value.=C2=A0 */ > >=20 > > ...please note in the comment that if non-NULL, the copy is NUL- > > terminated (I checked both exit paths that can return non-NULL, and > > they do NUL-terminate their buffers). > >=20 > > OK with that nit fixed. >=20 > Thanks, pushing this: