]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
analyzer: don't print the duplicate count by default
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 28 Feb 2020 15:06:57 +0000 (10:06 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 2 Mar 2020 21:45:04 +0000 (16:45 -0500)
The note about duplicates attached to analyzer diagnostics feels like an
implementation detail; it's likely just noise from the perspective of an
end-user.

This patch disables it by default, introducing a flag to re-enable it.

gcc/analyzer/ChangeLog:
* analyzer.opt (fanalyzer-show-duplicate-count): New option.
* diagnostic-manager.cc
(diagnostic_manager::emit_saved_diagnostic): Use the above to
guard the printing of the duplicate count.

gcc/ChangeLog:
* doc/invoke.texi (-fanalyzer-show-duplicate-count): New.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/CVE-2005-1689-dedupe-issue.c: Add
-fanalyzer-show-duplicate-count.

gcc/ChangeLog
gcc/analyzer/ChangeLog
gcc/analyzer/analyzer.opt
gcc/analyzer/diagnostic-manager.cc
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/analyzer/CVE-2005-1689-dedupe-issue.c

index 2944f8f4c50844924634a06242d684b2e6e98ae2..d8ac9f8c57754cfce4660ffdd7d2daa28fbcf411 100644 (file)
@@ -1,3 +1,7 @@
+2020-03-02  David Malcolm  <dmalcolm@redhat.com>
+
+       * doc/invoke.texi (-fanalyzer-show-duplicate-count): New.
+
 2020-03-02  David Malcolm  <dmalcolm@redhat.com>
 
        * doc/invoke.texi (Static Analyzer Options): Add
index e5d7bdbbf7e0458cbe7db83254bc51d68cf8e5e9..fa0fbcd195955cffcd0cfd9246b7a14db6892bee 100644 (file)
@@ -1,3 +1,10 @@
+2020-03-02  David Malcolm  <dmalcolm@redhat.com>
+
+       * analyzer.opt (fanalyzer-show-duplicate-count): New option.
+       * diagnostic-manager.cc
+       (diagnostic_manager::emit_saved_diagnostic): Use the above to
+       guard the printing of the duplicate count.
+
 2020-03-02  David Malcolm  <dmalcolm@redhat.com>
 
        PR analyzer/93959
index 4d122f3593af93ae07691442c500d733447ddf68..22cf4b0ad3b8a9792d4775cec21c78a05d560a73 100644 (file)
@@ -114,6 +114,10 @@ fanalyzer-fine-grained
 Common Var(flag_analyzer_fine_grained) Init(0)
 Avoid combining multiple statements into one exploded edge.
 
+fanalyzer-show-duplicate-count
+Common Var(flag_analyzer_show_duplicate_count) Init(0)
+Issue a note when diagnostics are deduplicated.
+
 fanalyzer-state-purge
 Common Var(flag_analyzer_state_purge) Init(1)
 Purge unneeded state during analysis.
index b8e5933437495b1bc050762609219962daf190ba..7435092e2d75f04edc12fce6619fb0c635d70afa 100644 (file)
@@ -541,7 +541,7 @@ diagnostic_manager::emit_saved_diagnostic (const exploded_graph &eg,
   auto_cfun sentinel (sd.m_snode->m_fun);
   if (sd.m_d->emit (&rich_loc))
     {
-      if (num_dupes > 0)
+      if (flag_analyzer_show_duplicate_count && num_dupes > 0)
        inform_n (stmt->location, num_dupes,
                  "%i duplicate", "%i duplicates",
                  num_dupes);
index dc7440db1033992f0ee154058ff385d274516517..54375ebd6799447bf468a56b03d044ac997fb842 100644 (file)
@@ -8477,6 +8477,14 @@ By default, an edge in this graph can contain the effects of a run
 of multiple statements within a basic block.  With
 @option{-fanalyzer-fine-grained}, each statement gets its own edge.
 
+@item -fanalyzer-show-duplicate-count
+@opindex fanalyzer-show-duplicate-count
+@opindex fno-analyzer-show-duplicate-count
+This option is intended for analyzer developers: if multiple diagnostics
+have been detected as being duplicates of each other, it emits a note when
+reporting the best diagnostic, giving the number of additional diagnostics
+that were suppressed by the deduplication logic.
+
 @item -fno-analyzer-state-merge
 @opindex fanalyzer-state-merge
 @opindex fno-analyzer-state-merge
index 33fa9bc972b40085ee8cc1fecd30e88224a8e0fa..5eae7d8173c46bb9f45e2eba2da1d27d7c50e5f7 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-02  David Malcolm  <dmalcolm@redhat.com>
+
+       * gcc.dg/analyzer/CVE-2005-1689-dedupe-issue.c: Add
+       -fanalyzer-show-duplicate-count.
+
 2020-03-02  David Malcolm  <dmalcolm@redhat.com>
 
        PR analyzer/93959
index 53c046ed12f0af79dc7321be5d896a60ea0cd882..b43148cb4a7bf31f3d413e96f8c3aefde3782bc9 100644 (file)
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fanalyzer-show-duplicate-count" } */
+
 #include <stdlib.h>
 
 typedef struct _krb5_data {