From patchwork Thu Jan 5 22:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 39824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp526091wrt; Thu, 5 Jan 2023 14:38:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXumHH7ZLl1llbZ8/jtaNpH83XsTJl8p8AzaCrdIoV2cp2v1IO2D/TVnEyugaA7xdOJpWg5E X-Received: by 2002:a17:906:99c7:b0:7b5:860d:7039 with SMTP id s7-20020a17090699c700b007b5860d7039mr45992340ejn.10.1672958299217; Thu, 05 Jan 2023 14:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672958299; cv=none; d=google.com; s=arc-20160816; b=u3uVDEKtAhA27jjgFUC5mP2BnHbi4bPFfiv1OZZkTukcHJi6bqwFPSBMkiRZstGK0U zVX0+mhXukIc23xRkyTVAsSJHh/Cz4Ub+CKmFebhQysvZzVa8csXEb8pV66oWeCFEN7/ BnwGb44IR9FG3D6ZCQqykOw0DZJDHL+7spRzRizY1Yt8Wlm+X7fSrMW72a1uixvQgFmC TtVAVMYVWzvNtDMvd8wDnWjHKcFAsp+EJ/um50t6x+38D9tCxMR7/dKLyxfYKVlZ8oKE XJg2wo592/Qv3VE5ltvbeSzOh5Cc3fixn4KxqWH2F6uetDNcU3I+od6ITfJl5h8ohpWD sHxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=dX2+xzTpqWtDJe91dl4pvitSpi3wqch6kv1wkVj4YOU=; b=fBV0qgWMBP/r8vAJK7mv/+6DbkDACBLalXlmf/7et1e9zWoFmV65J9NFkluPvYCH5f yFwp+8Gv9hyyyYTYP1KtnEJZ+x5HuTeq3uuGDiMGbqmkE8IVYgQyDPhOQRTbyilvyZBE ZbRIJFiAKPxAlNDKJ7wsU3BLLEfS0n1mwBKkUjeYuz5D4XuosT5qQrxF+hUtfH2qAyDt m8cw0A+43imHgVcnP9ArRt4fg/kr/Dwdqree0yXT/blgkbClW1zHwWDtyA/YX6bmeLHW zp4lJ6dUUrc94lk+x3tQ8LIkE5lG3YiYemRcNmKtT65VRLubwJxZM7i5s15Lg9rxi27y /+4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=NFVKuhso; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hz2-20020a1709072ce200b0084b9ac8f8a9si15655736ejc.959.2023.01.05.14.38.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 14:38:19 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=NFVKuhso; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 699553858033 for ; Thu, 5 Jan 2023 22:38:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 699553858033 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672958286; 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=NFVKuhsozLWy+weKuuTeH4FKhxUq26yY5lEj4nY5XgJn53YPWlM6eM/N8Zn4OFWvL N1qCwwh02viUiBwEWeM1sHUyKJ/cSQ74ZZeX9isG2BOFvi5/5BqRq+WydcvYGKhqnU 9KPTNut8K+ZkjYwi5AXA1CxD0XBLdo5qolBRL8h8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by sourceware.org (Postfix) with ESMTPS id 4DB943858D33 for ; Thu, 5 Jan 2023 22:36:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DB943858D33 Received: by mail-qv1-xf2f.google.com with SMTP id t7so1073333qvv.3 for ; Thu, 05 Jan 2023 14:36:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=LCEhV3lIoEB0lzaX7gk8tyNtiOVwKH5V0lqoXcGwW8SI9tjq2kfIu9rFyCxn8gfnya DLPwLPMorI+XtasWowzCCMkwK1gN8nvXMuNdwBtHFzoP1xUomjgfnyamcXYiYWQoxqNq 8t3vNIO8oq3UlaLlKhsn0dNMMUa4XxQ9yecluDpRJCeeuwtlgirucN1B+2VWE7OHaXC0 8+qok18iwAeIb2Bg7GHLN3hV2OGoNks9VT6TXB73vBsWephgMrJGVr4QJszEHYELqwCO 3Fw4TIBuAzwWwaVe9sfg8C583ZT3VO0b22d1v3YHfJ+PXwB4BfbuFRksGEWLN08G2NvF TRzA== X-Gm-Message-State: AFqh2kpfoazFxs7ZK+1GJ1FOjsRTSrzKjfvEESudm/oPaww1POClw94x Hy0izXa4JgTJ2i4KpQCvWLsDCCT+lWo= X-Received: by 2002:ad4:551d:0:b0:4d1:e110:1621 with SMTP id pz29-20020ad4551d000000b004d1e1101621mr70881837qvb.0.1672958194681; Thu, 05 Jan 2023 14:36:34 -0800 (PST) Received: from localhost.localdomain (96-67-140-173-static.hfc.comcastbusiness.net. [96.67.140.173]) by smtp.gmail.com with ESMTPSA id dm28-20020a05620a1d5c00b006e702033b15sm26289185qkb.66.2023.01.05.14.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 14:36:34 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: David Malcolm , Lewis Hyatt Subject: [PATCH v2 2/4] diagnostics: Handle generated data locations in edit_context Date: Thu, 5 Jan 2023 17:36:06 -0500 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-3038.9 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 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754223921788940405?= X-GMAIL-MSGID: =?utf-8?q?1754223921788940405?= 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)