From patchwork Fri Jul 21 23:08:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 1811169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=yJXJ46UC; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R74y06Btmz20Fh for ; Sat, 22 Jul 2023 09:09:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC07A3851AB8 for ; Fri, 21 Jul 2023 23:09:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC07A3851AB8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689980962; bh=dX2+xzTpqWtDJe91dl4pvitSpi3wqch6kv1wkVj4YOU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yJXJ46UCexRjdwdSQWl3Mh99pBoP7oo2QNWRTi6B5CAJPqiUlYn4oWRz8lXNP/Jyl tqgl7evkuHkqFH7mNMGCNlUPt/Ew4QsEd291e/LKCvHR2nbiij26bqQmVZvQcf7OHh izQQN2d7yD44p/HrosnXsMHRJEWo+j+tT4sLPQ2s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 209C9385DC0C for ; Fri, 21 Jul 2023 23:09:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 209C9385DC0C Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-4046cdbff16so20653511cf.1 for ; Fri, 21 Jul 2023 16:09:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689980940; x=1690585740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dX2+xzTpqWtDJe91dl4pvitSpi3wqch6kv1wkVj4YOU=; b=KLBSVWRrXUcnatqIz8m5zn7Ln2fN8bkgTU6y9TYudxFvkyFSsuHGblFAg2pIHYFvFs qrONzlu4P5lHYcpcmJOG2csbYOOZkkn49CohrGnd2UW/l4oiKMIX6XbmchUxbFBPISGC UcmI5d/BOqpRRllLCIJUfiXb2tVP8Y+mvahVTFsG1asKCWR6fByvTM0aDqznZ4dnV0wh DtPcKIn6+JCR4YzpuYFr5FMZygso55DPod1I9R1oqAbctFkr46cVK2zTNMJhYdVHksRS 8KQvtraOYaQy9VSSD0/Tk/ziQ+eeCCnwkMnupAMPtJ0C4F/eqrqsGY6XmbKvv/5LGEjr 5lpQ== X-Gm-Message-State: ABy/qLa099Y9obkRpTwzvYPi9+8ZhRZEqUkM6W6IrIWaBbQDE/j0oGlz Cl0HuwbqmIHPqjEzPZNEKAwghitQG1c= X-Google-Smtp-Source: APBJJlEpF0pvq0oyfPa+3Z5L75/o4JVvrFctYwF4fiANHybdKeS8fk1kj9cahXFznKjjmhrtLAuXBw== X-Received: by 2002:a05:622a:11c2:b0:400:797e:d690 with SMTP id n2-20020a05622a11c200b00400797ed690mr2189075qtk.1.1689980939910; Fri, 21 Jul 2023 16:08:59 -0700 (PDT) Received: from localhost.localdomain (96-67-140-173-static.hfc.comcastbusiness.net. [96.67.140.173]) by smtp.gmail.com with ESMTPSA id r26-20020ac8521a000000b00402ed9adfa1sm1586754qtn.87.2023.07.21.16.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 16:08:59 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: David Malcolm , Lewis Hyatt Subject: [PATCH v3 2/4] diagnostics: Handle generated data locations in edit_context Date: Fri, 21 Jul 2023 19:08:49 -0400 Message-Id: <20230721230851.1981434-3-lhyatt@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230721230851.1981434-1-lhyatt@gmail.com> References: <20230721230851.1981434-1-lhyatt@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3038.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Lewis Hyatt via Gcc-patches From: Lewis Hyatt Reply-To: Lewis Hyatt Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Class edit_context handles outputting fixit hints in diff form that could be manually or automatically applied by the user. This will not make sense for generated data locations, such as the contents of a _Pragma string, because the text to be modified does not appear in the user's input files. We do not currently ever generate fixit hints in such a context, but for future-proofing purposes, ignore such locations in edit context now. gcc/ChangeLog: * edit-context.cc (edit_context::apply_fixit): Ignore locations in generated data. --- gcc/edit-context.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/edit-context.cc b/gcc/edit-context.cc index 6f5bc6b9d8f..ae11b6f2e00 100644 --- a/gcc/edit-context.cc +++ b/gcc/edit-context.cc @@ -301,8 +301,12 @@ edit_context::apply_fixit (const fixit_hint *hint) return false; if (start.column == 0) return false; + if (start.generated_data) + return false; if (next_loc.column == 0) return false; + if (next_loc.generated_data) + return false; edited_file &file = get_or_insert_file (start.file); if (!m_valid)