From patchwork Thu Jan 13 22:08:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 50002 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B23A385781B for ; Thu, 13 Jan 2022 22:09:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B23A385781B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642111750; bh=6f9xyJ0v9HPau84qhJMVexzkWhzsOw96ZzLVZn9o0yI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J2jMVqPKhUJJqYYcq//tAHHDIXqRKLvxbbGLGji+FULbEoPGsM5nHu+gMRcaFIJG+ QJK1sJuqv92V1i9faiZazdieGnaX/Wn17sFy5YFmrqaMPbLLTj+CayxAwzsx/eKpsH bY/cqsf6EDBAk+OUx1dGAkEkGCfuf/Ps/fJ7jbFE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 00374385840D for ; Thu, 13 Jan 2022 22:08:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 00374385840D Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-Rh2cE3rSN6em5B_0BcZ81w-1; Thu, 13 Jan 2022 17:08:39 -0500 X-MC-Unique: Rh2cE3rSN6em5B_0BcZ81w-1 Received: by mail-qt1-f200.google.com with SMTP id o5-20020ac84285000000b002c7aa152905so5108778qtl.18 for ; Thu, 13 Jan 2022 14:08:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6f9xyJ0v9HPau84qhJMVexzkWhzsOw96ZzLVZn9o0yI=; b=JxXmvWjpvFw9H/iBatExJCWhg912TZnJIHeu9i8acKPJ0wOjBmopJJZXMSrX+OoUig NMeU6VnIGX18OFf78UzRKwjikXhCkmqoOY8cI6NI0kgXfh7+8NC0eaGDtS2MQsqk9x1U 1NsmkXrbSNLr6Q85nIxLB/NVMWYItN1wwKk9TDnwycq7mMv+bh/yfP2cDaW46mUO0wXL aMpz/wtSBT0JhnV/4s9+4GmeyFDYvyAWgR+QVhlVw03/+CFCUDmPXFOPaixZyNT4EwlP QZ/Ddltux3aNa8gJFNOdTOpRB6GwYANACDmwo+lheUGcX1IthBPIZuU9TqKPCJesGlq3 lc4w== X-Gm-Message-State: AOAM531+HQPK3wDOaGoLxD7Pw0LQZBaEjQAAnqFUBe5C9oVKDvt+ntE6 urqnlW6A5ysGbnLrUOSmsQbYhtbHVCQpvzaiSDf/SovMf/kiZypZJQOMA3ZfxAJFQPTgPBG6S9M kJsCPNQOZYaz8c4+oDM4BHg3r36JOB4cuh2PfBWO8HTJplIjBbej/CgDI9OA0CxSZFw== X-Received: by 2002:ac8:7fcc:: with SMTP id b12mr5618249qtk.164.1642111718526; Thu, 13 Jan 2022 14:08:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJznuaUxDDpoE9S89V528pjd0F8SEFGuIb+ejvNq7qn4e2sHeD7ai3qGJjOTuwAmBrOmph7khw== X-Received: by 2002:ac8:7fcc:: with SMTP id b12mr5618216qtk.164.1642111718077; Thu, 13 Jan 2022 14:08:38 -0800 (PST) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id m14sm2682083qkp.112.2022.01.13.14.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jan 2022 14:08:37 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH RFA] diagnostic: avoid repeating include path Date: Thu, 13 Jan 2022 17:08:36 -0500 Message-Id: <20220113220836.3781146-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" When a sequence of diagnostic messages bounces back and forth repeatedly between two includes, as with #include std::map m ("123", "456"); The output is quite a bit longer than necessary because we dump the include path each time it changes. I'd think we could print the include path once for each header file, and then expect that the user can look earlier in the output if they're wondering. Tested x86_64-pc-linux-gnu, OK for trunk? gcc/ChangeLog: * diagnostic.c (includes_seen): New. (diagnostic_report_current_module): Use it. --- gcc/diagnostic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) base-commit: b8ffa71e4271ae562c2d315b9b24c4979bbf8227 prerequisite-patch-id: e45065ef320968d982923dd44da7bed07e3326ef diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 58139427d01..e56441a2dbf 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -700,6 +700,16 @@ set_last_module (diagnostic_context *context, const line_map_ordinary *map) context->last_module = map; } +/* Only dump the "In file included from..." stack once for each file. */ + +static bool +includes_seen (const line_map_ordinary *map) +{ + using hset = hash_set; + static hset *set = new hset; + return set->add (map); +} + void diagnostic_report_current_module (diagnostic_context *context, location_t where) { @@ -721,7 +731,7 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where) if (map && last_module_changed_p (context, map)) { set_last_module (context, map); - if (! MAIN_FILE_P (map)) + if (! MAIN_FILE_P (map) && !includes_seen (map)) { bool first = true, need_inc = true, was_module = MAP_MODULE_P (map); expanded_location s = {};