From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128909 invoked by alias); 4 Dec 2019 18:35:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 128896 invoked by uid 89); 4 Dec 2019 18:35:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=verbose, addon, add-on, apparent X-HELO: mail-pg1-f194.google.com Received: from mail-pg1-f194.google.com (HELO mail-pg1-f194.google.com) (209.85.215.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Dec 2019 18:35:56 +0000 Received: by mail-pg1-f194.google.com with SMTP id x8so264090pgk.8 for ; Wed, 04 Dec 2019 10:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=8O28AIQ8CpoIDzh/tEdDYIyTeZQ+eoxSTz67JgcjjOE=; b=G9D3cFuAyfRGURApRJY4Lh4Ii1J7+B6ko8haSyS4+nwr4KTtm/AamxRqyXua2Y3XbE 7JPzV5MxFb3dOFF+RRnA2IRT8kharETqTWJ2z85miiAtyIktOfc8rv7Gwsez+jYwqSJG YUrjnvwk/cy+8T6iKxQrgw41Ds+Hj5OCGSYILQinFgMBg4e3f5ii4afIl+G+l6OAYlBr 9QwGYY0SkJ6MtvicajLGh+YK1L5bNLznEoLZaeW5f9vLejHOsuNf2herE661gYH69XpV UVDakN8gfv6WP6z6WPcvoSQ7b+aR0iJ/l2LidwijZfon2/kyANF+m6gSuuHEwTc3DPmR sYSg== Return-Path: Received: from [192.168.0.41] (75-166-111-174.hlrn.qwest.net. [75.166.111.174]) by smtp.gmail.com with ESMTPSA id j16sm8444385pfi.165.2019.12.04.10.35.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2019 10:35:53 -0800 (PST) Subject: Re: [PATCH 21/49] analyzer: command-line options To: David Malcolm , gcc-patches@gcc.gnu.org References: <1573867416-55618-1-git-send-email-dmalcolm@redhat.com> <1573867416-55618-22-git-send-email-dmalcolm@redhat.com> From: Martin Sebor Message-ID: <4168689e-8c1a-8809-0d00-3fdc0690a38d@gmail.com> Date: Wed, 04 Dec 2019 18:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1573867416-55618-22-git-send-email-dmalcolm@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-12/txt/msg00233.txt.bz2 On 11/15/19 6:23 PM, David Malcolm wrote: > This patch contains the command-line options for the analyzer. > Some of the -Wanalyzer- options sounds like they control similar warnings as existing options (e.g., -Wanalyzer-null-argument sounds like -Wnonnull and -Wanalyzer-null-dereference like -Wnull-dereference). There are also options whose names suggest they are in the same class as -Wmaybe-xxx (e.g., -Wanalyzer-possible-null-argument sounds like it would correspond to -Wmaybe-null-argument if it existed). I have a more general question about the apparent overlap of functionality that I will save for later but here I wonder about the names: that introducing a new set of similar sounding options might make them confusing, and might make the analyzer seem more like an add-on rather than an integral part of GCC. I realize the existing option names don't use any particular convention so this is an opportunity to put one in place, but at a cost of divergence. Unless you expect the existing options to go away, having consistent names would make for a more cohesive feel. My other concern is the verbosity of some these options: -Wanalyzer-use-of-pointer-in-stale-stack-frame is a mouthful and will take up a lot of terminal space. It sounds like the option controls warnings about uses of dangling pointers to auto objects, similar to -Wreturn-local-addr. My impression that conventionally GCC options have tended to be brief, and I personally would prefer shorter option names. Martin > gcc/ChangeLog: > * analyzer/plugin.opt: New file. > * common.opt (--analyzer): New driver option. > --- > gcc/analyzer/plugin.opt | 161 ++++++++++++++++++++++++++++++++++++++++++++++++ > gcc/common.opt | 3 + > 2 files changed, 164 insertions(+) > create mode 100644 gcc/analyzer/plugin.opt > > diff --git a/gcc/analyzer/plugin.opt b/gcc/analyzer/plugin.opt > new file mode 100644 > index 0000000..55f54bb > --- /dev/null > +++ b/gcc/analyzer/plugin.opt > @@ -0,0 +1,161 @@ > +; plugin.opt -- Options for the analyzer. > + > +; Copyright (C) 2019 Free Software Foundation, Inc. > +; > +; This file is part of GCC. > +; > +; GCC is free software; you can redistribute it and/or modify it under > +; the terms of the GNU General Public License as published by the Free > +; Software Foundation; either version 3, or (at your option) any later > +; version. > +; > +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY > +; WARRANTY; without even the implied warranty of MERCHANTABILITY or > +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License > +; for more details. > +; > +; You should have received a copy of the GNU General Public License > +; along with GCC; see the file COPYING3. If not see > +; . > + > +; See the GCC internals manual for a description of this file's format. > + > +; Please try to keep this file in ASCII collating order. > + > +Wanalyzer-double-fclose > +Common Var(warn_analyzer_double_fclose) Init(1) Warning > +Warn about code paths in which a stdio FILE can be closed more than once. > + > +Wanalyzer-double-free > +Common Var(warn_analyzer_double_free) Init(1) Warning > +Warn about code paths in which a pointer can be freed more than once. > + > +Wanalyzer-exposure-through-output-file > +Common Var(warn_analyzer_exposure_through_output_file) Init(1) Warning > +Warn about code paths in which sensitive data is written to a file. > + > +Wanalyzer-file-leak > +Common Var(warn_analyzer_file_leak) Init(1) Warning > +Warn about code paths in which a stdio FILE is not closed. > + > +Wanalyzer-free-of-non-heap > +Common Var(warn_analyzer_free_of_non_heap) Init(1) Warning > +Warn about code paths in which a non-heap pointer is freed. > + > +Wanalyzer-malloc-leak > +Common Var(warn_analyzer_malloc_leak) Init(1) Warning > +Warn about code paths in which a heap-allocated pointer leaks. > + > +Wanalyzer-possible-null-argument > +Common Var(warn_analyzer_possible_null_argument) Init(1) Warning > +Warn about code paths in which a possibly-NULL value is passed to a must-not-be-NULL function argument. > + > +Wanalyzer-possible-null-dereference > +Common Var(warn_analyzer_possible_null_dereference) Init(1) Warning > +Warn about code paths in which a possibly-NULL pointer is dereferenced. > + > +Wanalyzer-null-argument > +Common Var(warn_analyzer_null_argument) Init(1) Warning > +Warn about code paths in which NULL is passed to a must-not-be-NULL function argument. > + > +Wanalyzer-null-dereference > +Common Var(warn_analyzer_null_dereference) Init(1) Warning > +Warn about code paths in which a NULL pointer is dereferenced. > + > +Wanalyzer-stale-setjmp-buffer > +Common Var(warn_analyzer_stale_setjmp_buffer) Init(1) Warning > +Warn about code paths in which a longjmp rewinds to a jmp_buf saved in a stack frame that has returned. > + > +Wanalyzer-tainted-array-index > +Common Var(warn_analyzer_tainted_array_index) Init(1) Warning > +Warn about code paths in which an unsanitized value is used as an array index. > + > +Wanalyzer-use-after-free > +Common Var(warn_analyzer_use_after_free) Init(1) Warning > +Warn about code paths in which a freed value is used. > + > +Wanalyzer-use-of-pointer-in-stale-stack-frame > +Common Var(warn_analyzer_use_of_pointer_in_stale_stack_frame) Init(1) Warning > +Warn about code paths in which a pointer to a stale stack frame is used. > + > +Wanalyzer-use-of-uninitialized-value > +Common Var(warn_analyzer_use_of_uninitialized_value) Init(1) Warning > +Warn about code paths in which an initialized value is used. > + > +Wanalyzer-too-complex > +Common Var(warn_analyzer_too_complex) Init(0) Warning > +Warn if the code is too complicated for the analyzer to fully explore. > + > +fanalyzer-checker= > +Common Joined RejectNegative Var(flag_analyzer_checker) > +Restrict the analyzer to run just the named checker. > + > +fanalyzer-fine-grained > +Common Var(flag_analyzer_fine_grained) Init(0) > +Avoid combining multiple statements into one exploded edge. > + > +fanalyzer-state-purge > +Common Var(flag_analyzer_state_purge) Init(1) > +Purge unneeded state during analysis. > + > +fanalyzer-state-merge > +Common Var(flag_analyzer_state_merge) Init(1) > +Merge similar-enough states during analysis. > + > +fanalyzer-transitivity > +Common Var(flag_analyzer_transitivity) Init(0) > +Enable transitivity of constraints during analysis. > + > +fanalyzer-call-summaries > +Common Var(flag_analyzer_call_summaries) Init(0) > +Approximate the effect of function calls to simplify analysis. > + > +fanalyzer-verbose-edges > +Common Var(flag_analyzer_verbose_edges) Init(0) > +Emit more verbose descriptions of control flow in diagnostics. > + > +fanalyzer-verbose-state-changes > +Common Var(flag_analyzer_verbose_state_changes) Init(0) > +Emit more verbose descriptions of state changes in diagnostics. > + > +fanalyzer-verbosity= > +Common Joined UInteger Var(analyzer_verbosity) Init(2) > +Control which events are displayed in diagnostic paths. > + > +fdump-analyzer > +Common RejectNegative Var(flag_dump_analyzer) > +Dump internal details about what the analyzer is doing to SRCFILE.analyzer.txt. > + > +fdump-analyzer-stderr > +Common RejectNegative Var(flag_dump_analyzer_stderr) > +Dump internal details about what the analyzer is doing to stderr. > + > +fdump-analyzer-callgraph > +Common RejectNegative Var(flag_dump_analyzer_callgraph) > +Dump the analyzer supergraph to a SRCFILE.callgraph.dot file. > + > +fdump-analyzer-exploded-graph > +Common RejectNegative Var(flag_dump_analyzer_exploded_graph) > +Dump the analyzer exploded graph to a SRCFILE.eg.dot file. > + > +fdump-analyzer-exploded-nodes > +Common RejectNegative Var(flag_dump_analyzer_exploded_nodes) > +Emit diagnostics showing the location of nodes in the exploded graph. > + > +fdump-analyzer-exploded-nodes-2 > +Common RejectNegative Var(flag_dump_analyzer_exploded_nodes_2) > +Dump a textual representation of the exploded graph to SRCFILE.eg.txt. > + > +fdump-analyzer-exploded-nodes-3 > +Common RejectNegative Var(flag_dump_analyzer_exploded_nodes_3) > +Dump a textual representation of the exploded graph to SRCFILE.eg-ID.txt. > + > +fdump-analyzer-state-purge > +Common RejectNegative Var(flag_dump_analyzer_state_purge) > +Dump state-purging information to a SRCFILE.state-purge.dot file. > + > +fdump-analyzer-supergraph > +Common RejectNegative Var(flag_dump_analyzer_supergraph) > +Dump the analyzer supergraph to a SRCFILE.supergraph.dot file. > + > +; This comment is to ensure we retain the blank line above. > diff --git a/gcc/common.opt b/gcc/common.opt > index adc9931..0c352a3 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -269,6 +269,9 @@ Driver Joined Alias(e) > -extra-warnings > Common Warning Alias(Wextra) > > +-analyzer > +Driver Var(analyzer_flag) > + > -for-assembler > Driver Separate Alias(Xassembler) > >