Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit a746657

Browse files
committed
scan-build: Add an option to show the description in the list of defect
Summary: This patch adds an option //--show-description// to add the defect description to the list of defect. This helps to get a better understanding of the defect without opening the page. For example, this is used for Firefox: https://people.mozilla.org/~sledru/reports/fx-scan-build/ Reviewers: rizsotto.mailinglist, zaks.anna Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D22810 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277328 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 331c3de commit a746657

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

tools/scan-build/bin/scan-build

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ my %Options = (
5353
IgnoreErrors => 0, # Ignore build errors.
5454
ViewResults => 0, # View results when the build terminates.
5555
ExitStatusFoundBugs => 0, # Exit status reflects whether bugs were found
56+
ShowDescription => 0, # Display the description of the defect in the list
5657
KeepEmpty => 0, # Don't remove output directory even with 0 results.
5758
EnableCheckers => {},
5859
DisableCheckers => {},
@@ -453,6 +454,10 @@ sub ScanFile {
453454

454455
push @$Index,[ $FName, $BugCategory, $BugType, $BugFile, $BugFunction, $BugLine,
455456
$BugPathLength ];
457+
458+
if ($Options{ShowDescription}) {
459+
push @{ $Index->[-1] }, $BugDescription
460+
}
456461
}
457462

458463
##----------------------------------------------------------------------------##
@@ -746,6 +751,15 @@ print OUT <<ENDTEXT;
746751
<td>Function/Method</td>
747752
<td class="Q">Line</td>
748753
<td class="Q">Path Length</td>
754+
ENDTEXT
755+
756+
if ($Options{ShowDescription}) {
757+
print OUT <<ENDTEXT;
758+
<td class="Q">Description</td>
759+
ENDTEXT
760+
}
761+
762+
print OUT <<ENDTEXT;
749763
<td class="sorttable_nosort"></td>
750764
<!-- REPORTBUGCOL -->
751765
</tr></thead>
@@ -771,10 +785,10 @@ ENDTEXT
771785

772786
print OUT "<tr class=\"bt_$x\">";
773787
print OUT "<td class=\"DESC\">";
774-
print OUT $row->[1];
788+
print OUT $row->[1]; # $BugCategory
775789
print OUT "</td>";
776790
print OUT "<td class=\"DESC\">";
777-
print OUT $row->[2];
791+
print OUT $row->[2]; # $BugType
778792
print OUT "</td>";
779793

780794
# Update the file prefix.
@@ -802,11 +816,11 @@ ENDTEXT
802816
print OUT "</td>";
803817

804818
print OUT "<td class=\"DESC\">";
805-
print OUT $row->[4];
819+
print OUT $row->[4]; # Function
806820
print OUT "</td>";
807821

808822
# Print out the quantities.
809-
for my $j ( 5 .. 6 ) {
823+
for my $j ( 5 .. 6 ) { # Line & Path length
810824
print OUT "<td class=\"Q\">$row->[$j]</td>";
811825
}
812826

@@ -1150,6 +1164,10 @@ OPTIONS:
11501164
Specify the title used on generated HTML pages. If not specified, a default
11511165
title will be used.
11521166
1167+
--show-description
1168+
1169+
Display the description of defects in the list
1170+
11531171
-plist
11541172
11551173
By default the output of scan-build is a set of HTML files. This option
@@ -1586,6 +1604,12 @@ sub ProcessArgs {
15861604
next;
15871605
}
15881606

1607+
if ($arg eq "--show-description") {
1608+
shift @$Args;
1609+
$Options{ShowDescription} = 1;
1610+
next;
1611+
}
1612+
15891613
if ($arg eq "-store") {
15901614
shift @$Args;
15911615
$Options{StoreModel} = shift @$Args;

0 commit comments

Comments
 (0)