From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BC2783858D35; Tue, 4 Jul 2023 13:07:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC2783858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688476043; bh=TQxCspY4jbDV6U5I2I/3pab62E4eGUcd2o3ARhtA3Es=; h=From:To:Subject:Date:From; b=G9xEiF/URNnRYkvmdG1YRihgefpg4LBbbNiv/UvrbWOHLvmp1SFzMcXaT4kLBFCMo cG+VGcRKwOo9DNHv9nC82KuqxemWU6W6vM4wHN/3cOO3YsuJb1CuicS+HBaXiUwarU tQiGrf2EWkgWuOBCXmDRIdV0fbjV8TcGsDJ2QJLk= From: "vultkayn at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/110543] New: RFE: Add optional trim of the analyzer diagnostics through system headers. Date: Tue, 04 Jul 2023 13:07:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vultkayn at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110543 Bug ID: 110543 Summary: RFE: Add optional trim of the analyzer diagnostics through system headers. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: vultkayn at gcc dot gnu.org Target Milestone: --- See https://godbolt.org/z/sb9dM9Gqa for a reproducer on trunk. Given an issue on std::shared_ptr<>, the analyzer emits a path that I'd lik= e to optionally shorten, by trimming it. Looking at the reproducer, I believe it would be desirable the analyzer emi= ts similar diagnostics for smart pointers as it is for raw pointers, i.e. the diagnostic should not dive into the standard library, but rather stop at the faulting frame. Thus behaves as follow, _by default_: : In function 'int main()': :5:8: warning: dereference of NULL 'a' [CWE-476] [-Wanalyzer-null-dereference] 5 | a->x =3D 4; /* Diagnostic would path should stop here rather than= going to shared_ptr_base.h */ | ~~~~~^~~ 'int main()': events 1-2 | | 4 | std::shared_ptr a; | | ^ | | | | | (1) 'a' is NULL | 5 | a->x =3D 4; /* Diagnostic path should stop here rather than = going to shared_ptr_base.h */ | | ~~~~~~~~ | | | | | (2) dereference of NULL 'a' |=20 A flag akin to -fanalyzer-trim-diagnostic-path=3D|std would then = be introduced to do so, with a default value of std. Such option would be useful for future support of C++, but could be extende= d to any "system header", thus also be used in C. A slight variation would be to trim all but the last exceeding event, so th= at the user would still get feedback on template deducted types. What do you think ?=