blob: 47622bfd509808c5da85c028688f67ee16806729 [file] [log] [blame]
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001#!/usr/bin/env perl
2#
3# The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8##===----------------------------------------------------------------------===##
9#
10# A script designed to wrap a build so that all calls to gcc are intercepted
11# and piped to the static analyzer.
12#
13##===----------------------------------------------------------------------===##
14
15use strict;
16use warnings;
Ted Kremenek22d6a632008-04-02 20:43:36 +000017use FindBin qw($RealBin);
Ted Kremeneka6e24812008-04-19 18:05:48 +000018use Digest::MD5;
Ted Kremenek7a4648d2008-05-02 22:04:53 +000019use File::Basename;
Ted Kremenek23cfca32008-06-16 22:40:14 +000020use Term::ANSIColor;
21use Term::ANSIColor qw(:constants);
Ted Kremenekcd25c132008-12-03 19:50:37 +000022use Cwd qw/ getcwd abs_path /;
Ted Kremenek7cba1122008-09-22 01:35:58 +000023use Sys::Hostname;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000024
25my $Verbose = 0; # Verbose output from this script.
26my $Prog = "scan-build";
Ted Kremenekf4cdf412008-05-23 18:17:05 +000027my $BuildName;
28my $BuildDate;
Ted Kremenek95aa1052008-09-04 17:52:41 +000029my $CXX; # Leave undefined initially.
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000030
Ted Kremenek0e689382008-09-11 18:17:51 +000031my $TERM = $ENV{'TERM'};
32my $UseColor = (defined $TERM and $TERM eq 'xterm-color' and -t STDOUT
33 and defined $ENV{'SCAN_BUILD_COLOR'});
Ted Kremenek23cfca32008-06-16 22:40:14 +000034
Ted Kremenek7cba1122008-09-22 01:35:58 +000035my $UserName = HtmlEscape(getpwuid($<) || 'unknown');
36my $HostName = HtmlEscape(hostname() || 'unknown');
37my $CurrentDir = HtmlEscape(getcwd());
38my $CurrentDirSuffix = basename($CurrentDir);
39
40my $CmdArgs;
41
42my $HtmlTitle;
43
44my $Date = localtime();
45
Ted Kremenekb7770c02008-07-15 17:06:13 +000046##----------------------------------------------------------------------------##
47# Diagnostics
48##----------------------------------------------------------------------------##
49
Ted Kremenek23cfca32008-06-16 22:40:14 +000050sub Diag {
51 if ($UseColor) {
52 print BOLD, MAGENTA "$Prog: @_";
53 print RESET;
54 }
55 else {
56 print "$Prog: @_";
57 }
58}
59
Ted Kremenek991c54b2008-08-08 20:46:42 +000060sub DiagCrashes {
61 my $Dir = shift;
Ted Kremenek938eef12009-02-17 23:31:05 +000062 Diag ("The analyzer encountered problems on some source files.\n");
63 Diag ("Preprocessed versions of these sources were deposited in '$Dir/failures'.\n");
Ted Kremenek991c54b2008-08-08 20:46:42 +000064 Diag ("Please consider submitting a bug report using these files:\n");
65 Diag (" http://clang.llvm.org/StaticAnalysisUsage.html#filingbugs\n")
66}
67
Ted Kremenek23cfca32008-06-16 22:40:14 +000068sub DieDiag {
69 if ($UseColor) {
70 print BOLD, RED "$Prog: ";
71 print RESET, RED @_;
72 print RESET;
73 }
74 else {
75 print "$Prog: ", @_;
76 }
77 exit(0);
78}
79
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +000080##----------------------------------------------------------------------------##
Ted Kremenekb7770c02008-07-15 17:06:13 +000081# Some initial preprocessing of Clang options.
82##----------------------------------------------------------------------------##
83
Ted Kremenek2d62ab12009-02-23 23:01:06 +000084my $ClangSB = Cwd::realpath("$RealBin/bin/clang");
Ted Kremenek43b7bd32009-03-09 23:14:38 +000085
86# Also look for 'clang' in the same directory as scan-build.
87if (!defined $ClangSB || ! -x $ClangSB) {
88 $ClangSB = Cwd::realpath("$RealBin/clang");
89}
90
Ted Kremenekb7770c02008-07-15 17:06:13 +000091my $Clang = $ClangSB;
92
Ted Kremenek8d10cdd2009-02-20 04:34:29 +000093if (!defined $ClangSB || ! -x $ClangSB) {
Ted Kremenekb7770c02008-07-15 17:06:13 +000094 $Clang = "clang";
95}
96
97my %AvailableAnalyses;
98
99# Query clang for analysis options.
Ted Kremenek63c20172008-08-04 17:34:06 +0000100open(PIPE, "-|", $Clang, "--help") or
Ted Kremenek445fa772008-10-10 00:17:08 +0000101 DieDiag("Cannot execute '$Clang'\n");
Ted Kremenek63c20172008-08-04 17:34:06 +0000102
Ted Kremenekb7770c02008-07-15 17:06:13 +0000103my $FoundAnalysis = 0;
104
105while(<PIPE>) {
106 if ($FoundAnalysis == 0) {
Ted Kremenek938eef12009-02-17 23:31:05 +0000107 if (/Checks and Analyses/) {
Ted Kremenekb7770c02008-07-15 17:06:13 +0000108 $FoundAnalysis = 1;
109 }
Ted Kremenekb7770c02008-07-15 17:06:13 +0000110 next;
111 }
112
113 if (/^\s\s\s\s([^\s]+)\s(.+)$/) {
114 next if ($1 =~ /-dump/ or $1 =~ /-view/
115 or $1 =~ /-checker-simple/ or $1 =~ /-warn-uninit/);
116
117 $AvailableAnalyses{$1} = $2;
118 next;
Ted Kremenek938eef12009-02-17 23:31:05 +0000119 }
Ted Kremenekb7770c02008-07-15 17:06:13 +0000120 last;
121}
122
123close (PIPE);
124
125my %AnalysesDefaultEnabled = (
126 '-warn-dead-stores' => 1,
127 '-checker-cfref' => 1,
Ted Kremenek90125992008-07-15 23:41:32 +0000128 '-warn-objc-methodsigs' => 1,
Ted Kremenekd76c6a32009-02-25 21:08:30 +0000129 # Do not enable the missing -dealloc check by default.
130 # '-warn-objc-missing-dealloc' => 1,
Ted Kremenek5d443492008-09-18 06:34:16 +0000131 '-warn-objc-unused-ivars' => 1,
Ted Kremenekb7770c02008-07-15 17:06:13 +0000132);
133
134##----------------------------------------------------------------------------##
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000135# GetHTMLRunDir - Construct an HTML directory name for the current sub-run.
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000136##----------------------------------------------------------------------------##
137
Sam Bishopa0e22662008-04-02 03:35:43 +0000138sub GetHTMLRunDir {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000139
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000140 die "Not enough arguments." if (@_ == 0);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000141 my $Dir = shift @_;
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000142
143 my $TmpMode = 0;
144 if (!defined $Dir) {
Ted Kremenekffda0b42008-10-31 05:48:42 +0000145 if (`uname` =~ /Darwin/) {
146 $Dir = $ENV{'TMPDIR'};
147 if (!defined $Dir) { $Dir = "/tmp"; }
148 }
149 else {
150 $Dir = "/tmp";
151 }
152
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000153 $TmpMode = 1;
154 }
Ted Kremenekbf762c92009-02-24 02:38:02 +0000155
156 # Chop off any trailing '/' characters.
157 while ($Dir =~ /\/$/) { chop $Dir; }
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000158
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000159 # Get current date and time.
160
161 my @CurrentTime = localtime();
162
163 my $year = $CurrentTime[5] + 1900;
164 my $day = $CurrentTime[3];
165 my $month = $CurrentTime[4] + 1;
166
Ted Kremenek9d7405f2008-05-14 17:23:56 +0000167 my $DateString = sprintf("%d-%02d-%02d", $year, $month, $day);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000168
169 # Determine the run number.
170
171 my $RunNumber;
172
173 if (-d $Dir) {
174
175 if (! -r $Dir) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000176 DieDiag("directory '$Dir' exists but is not readable.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000177 }
178
179 # Iterate over all files in the specified directory.
180
181 my $max = 0;
182
183 opendir(DIR, $Dir);
Ted Kremenek29da6c52008-08-07 17:57:34 +0000184 my @FILES = grep { -d "$Dir/$_" } readdir(DIR);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000185 closedir(DIR);
186
187 foreach my $f (@FILES) {
188
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000189 # Strip the prefix '$Prog-' if we are dumping files to /tmp.
190 if ($TmpMode) {
191 next if (!($f =~ /^$Prog-(.+)/));
192 $f = $1;
193 }
194
Ted Kremenekebb74132008-09-21 06:58:09 +0000195
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000196 my @x = split/-/, $f;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000197 next if (scalar(@x) != 4);
198 next if ($x[0] != $year);
199 next if ($x[1] != $month);
200 next if ($x[2] != $day);
201
202 if ($x[3] > $max) {
203 $max = $x[3];
204 }
205 }
206
207 $RunNumber = $max + 1;
208 }
209 else {
210
211 if (-x $Dir) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000212 DieDiag("'$Dir' exists but is not a directory.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000213 }
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000214
215 if ($TmpMode) {
Ted Kremenek445fa772008-10-10 00:17:08 +0000216 DieDiag("The directory '/tmp' does not exist or cannot be accessed.\n");
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000217 }
218
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000219 # $Dir does not exist. It will be automatically created by the
220 # clang driver. Set the run number to 1.
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000221
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000222 $RunNumber = 1;
223 }
224
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000225 die "RunNumber must be defined!" if (!defined $RunNumber);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000226
227 # Append the run number.
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000228 my $NewDir;
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000229 if ($TmpMode) {
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000230 $NewDir = "$Dir/$Prog-$DateString-$RunNumber";
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000231 }
232 else {
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000233 $NewDir = "$Dir/$DateString-$RunNumber";
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000234 }
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000235 system 'mkdir','-p',$NewDir;
236 return $NewDir;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000237}
238
Sam Bishopa0e22662008-04-02 03:35:43 +0000239sub SetHtmlEnv {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000240
241 die "Wrong number of arguments." if (scalar(@_) != 2);
242
243 my $Args = shift;
244 my $Dir = shift;
245
246 die "No build command." if (scalar(@$Args) == 0);
247
248 my $Cmd = $$Args[0];
249
250 if ($Cmd =~ /configure/) {
251 return;
252 }
253
254 if ($Verbose) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000255 Diag("Emitting reports for this run to '$Dir'.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000256 }
257
258 $ENV{'CCC_ANALYZER_HTML'} = $Dir;
259}
260
261##----------------------------------------------------------------------------##
Ted Kremenek57cf4462008-04-18 15:09:30 +0000262# ComputeDigest - Compute a digest of the specified file.
263##----------------------------------------------------------------------------##
264
265sub ComputeDigest {
266 my $FName = shift;
Ted Kremenek23cfca32008-06-16 22:40:14 +0000267 DieDiag("Cannot read $FName to compute Digest.\n") if (! -r $FName);
Ted Kremeneka6e24812008-04-19 18:05:48 +0000268
269 # Use Digest::MD5. We don't have to be cryptographically secure. We're
Ted Kremenek7ea02e62008-04-19 18:07:44 +0000270 # just looking for duplicate files that come from a non-malicious source.
271 # We use Digest::MD5 because it is a standard Perl module that should
Ted Kremenek63c20172008-08-04 17:34:06 +0000272 # come bundled on most systems.
Ted Kremenek23cfca32008-06-16 22:40:14 +0000273 open(FILE, $FName) or DieDiag("Cannot open $FName when computing Digest.\n");
Ted Kremeneka6e24812008-04-19 18:05:48 +0000274 binmode FILE;
275 my $Result = Digest::MD5->new->addfile(*FILE)->hexdigest;
276 close(FILE);
277
Ted Kremenek63c20172008-08-04 17:34:06 +0000278 # Return the digest.
Ted Kremeneka6e24812008-04-19 18:05:48 +0000279 return $Result;
Ted Kremenek57cf4462008-04-18 15:09:30 +0000280}
281
282##----------------------------------------------------------------------------##
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000283# UpdatePrefix - Compute the common prefix of files.
284##----------------------------------------------------------------------------##
285
286my $Prefix;
287
288sub UpdatePrefix {
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000289 my $x = shift;
290 my $y = basename($x);
291 $x =~ s/\Q$y\E$//;
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000292
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000293 if (!defined $Prefix) {
294 $Prefix = $x;
295 return;
296 }
297
Ted Kremenek20b2bae2008-09-11 21:15:10 +0000298 chop $Prefix while (!($x =~ /^\Q$Prefix/));
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000299}
300
301sub GetPrefix {
302 return $Prefix;
303}
304
305##----------------------------------------------------------------------------##
306# UpdateInFilePath - Update the path in the report file.
307##----------------------------------------------------------------------------##
308
309sub UpdateInFilePath {
310 my $fname = shift;
311 my $regex = shift;
312 my $newtext = shift;
Ted Kremenek63c20172008-08-04 17:34:06 +0000313
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000314 open (RIN, $fname) or die "cannot open $fname";
Ted Kremenek63c20172008-08-04 17:34:06 +0000315 open (ROUT, ">", "$fname.tmp") or die "cannot open $fname.tmp";
316
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000317 while (<RIN>) {
318 s/$regex/$newtext/;
319 print ROUT $_;
320 }
Ted Kremenek63c20172008-08-04 17:34:06 +0000321
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000322 close (ROUT);
323 close (RIN);
Ted Kremenek20161e92008-07-15 20:18:21 +0000324 system("mv", "$fname.tmp", $fname);
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000325}
326
327##----------------------------------------------------------------------------##
Ted Kremenek5744dc22008-04-02 18:03:36 +0000328# ScanFile - Scan a report file for various identifying attributes.
329##----------------------------------------------------------------------------##
330
Ted Kremenek57cf4462008-04-18 15:09:30 +0000331# Sometimes a source file is scanned more than once, and thus produces
332# multiple error reports. We use a cache to solve this problem.
333
334my %AlreadyScanned;
335
Ted Kremenek5744dc22008-04-02 18:03:36 +0000336sub ScanFile {
337
338 my $Index = shift;
339 my $Dir = shift;
340 my $FName = shift;
341
Ted Kremenek57cf4462008-04-18 15:09:30 +0000342 # Compute a digest for the report file. Determine if we have already
343 # scanned a file that looks just like it.
344
345 my $digest = ComputeDigest("$Dir/$FName");
346
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000347 if (defined $AlreadyScanned{$digest}) {
Ted Kremenek57cf4462008-04-18 15:09:30 +0000348 # Redundant file. Remove it.
Ted Kremenek20161e92008-07-15 20:18:21 +0000349 system ("rm", "-f", "$Dir/$FName");
Ted Kremenek57cf4462008-04-18 15:09:30 +0000350 return;
351 }
352
353 $AlreadyScanned{$digest} = 1;
354
Ted Kremenek809709f2008-04-18 16:58:34 +0000355 # At this point the report file is not world readable. Make it happen.
Ted Kremenek20161e92008-07-15 20:18:21 +0000356 system ("chmod", "644", "$Dir/$FName");
Ted Kremenek684bb092008-04-18 15:18:20 +0000357
358 # Scan the report file for tags.
Ted Kremenek23cfca32008-06-16 22:40:14 +0000359 open(IN, "$Dir/$FName") or DieDiag("Cannot open '$Dir/$FName'\n");
Ted Kremenek5744dc22008-04-02 18:03:36 +0000360
Ted Kremeneka26ddab2009-01-27 01:53:39 +0000361 my $BugType = "";
Ted Kremenek22d6a632008-04-02 20:43:36 +0000362 my $BugFile = "";
Ted Kremenekebb74132008-09-21 06:58:09 +0000363 my $BugCategory;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000364 my $BugPathLength = 1;
365 my $BugLine = 0;
Ted Kremenekebb74132008-09-21 06:58:09 +0000366 my $found = 0;
367
Ted Kremenek5744dc22008-04-02 18:03:36 +0000368 while (<IN>) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000369
370 last if ($found == 5);
371
Ted Kremeneka26ddab2009-01-27 01:53:39 +0000372 if (/<!-- BUGTYPE (.*) -->$/) {
373 $BugType = $1;
Ted Kremenekebb74132008-09-21 06:58:09 +0000374 ++$found;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000375 }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000376 elsif (/<!-- BUGFILE (.*) -->$/) {
Ted Kremenek990c2f42008-12-03 19:19:23 +0000377 $BugFile = abs_path($1);
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000378 UpdatePrefix($BugFile);
Ted Kremenekebb74132008-09-21 06:58:09 +0000379 ++$found;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000380 }
381 elsif (/<!-- BUGPATHLENGTH (.*) -->$/) {
382 $BugPathLength = $1;
Ted Kremenekebb74132008-09-21 06:58:09 +0000383 ++$found;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000384 }
385 elsif (/<!-- BUGLINE (.*) -->$/) {
386 $BugLine = $1;
Ted Kremenekebb74132008-09-21 06:58:09 +0000387 ++$found;
388 }
389 elsif (/<!-- BUGCATEGORY (.*) -->$/) {
390 $BugCategory = $1;
391 ++$found;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000392 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000393 }
394
395 close(IN);
Ted Kremenekebb74132008-09-21 06:58:09 +0000396
397 if (!defined $BugCategory) {
398 $BugCategory = "Other";
399 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000400
Ted Kremeneka26ddab2009-01-27 01:53:39 +0000401 push @$Index,[ $FName, $BugCategory, $BugType, $BugFile, $BugLine,
Ted Kremenek81983112008-09-28 04:13:09 +0000402 $BugPathLength ];
Ted Kremenek22d6a632008-04-02 20:43:36 +0000403}
404
405##----------------------------------------------------------------------------##
Ted Kremenek3ce12072008-09-22 17:50:47 +0000406# CopyFiles - Copy resource files to target directory.
Ted Kremenek22d6a632008-04-02 20:43:36 +0000407##----------------------------------------------------------------------------##
408
Ted Kremenek3ce12072008-09-22 17:50:47 +0000409sub CopyFiles {
Ted Kremenek22d6a632008-04-02 20:43:36 +0000410
411 my $Dir = shift;
Ted Kremeneke15fa272008-10-13 21:46:42 +0000412
413 my $JS = Cwd::realpath("$RealBin/sorttable.js");
Ted Kremenek22d6a632008-04-02 20:43:36 +0000414
Ted Kremenek23cfca32008-06-16 22:40:14 +0000415 DieDiag("Cannot find 'sorttable.js'.\n")
Ted Kremeneke15fa272008-10-13 21:46:42 +0000416 if (! -r $JS);
Ted Kremenek22d6a632008-04-02 20:43:36 +0000417
Ted Kremeneke15fa272008-10-13 21:46:42 +0000418 system ("cp", $JS, "$Dir");
Ted Kremenek22d6a632008-04-02 20:43:36 +0000419
Ted Kremenek23cfca32008-06-16 22:40:14 +0000420 DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
Ted Kremenek22d6a632008-04-02 20:43:36 +0000421 if (! -r "$Dir/sorttable.js");
Ted Kremenek3ce12072008-09-22 17:50:47 +0000422
Ted Kremeneke15fa272008-10-13 21:46:42 +0000423 my $CSS = Cwd::realpath("$RealBin/scanview.css");
424
Ted Kremenek3ce12072008-09-22 17:50:47 +0000425 DieDiag("Cannot find 'scanview.css'.\n")
Ted Kremeneke15fa272008-10-13 21:46:42 +0000426 if (! -r $CSS);
Ted Kremenek3ce12072008-09-22 17:50:47 +0000427
Ted Kremeneke15fa272008-10-13 21:46:42 +0000428 system ("cp", $CSS, "$Dir");
Ted Kremenek3ce12072008-09-22 17:50:47 +0000429
430 DieDiag("Could not copy 'scanview.css' to '$Dir'.\n")
Ted Kremeneke15fa272008-10-13 21:46:42 +0000431 if (! -r $CSS);
Ted Kremenek5744dc22008-04-02 18:03:36 +0000432}
433
434##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000435# Postprocess - Postprocess the results of an analysis scan.
436##----------------------------------------------------------------------------##
437
Sam Bishopa0e22662008-04-02 03:35:43 +0000438sub Postprocess {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000439
440 my $Dir = shift;
Ted Kremenek684bb092008-04-18 15:18:20 +0000441 my $BaseDir = shift;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000442
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000443 die "No directory specified." if (!defined $Dir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000444
445 if (! -d $Dir) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000446 Diag("No bugs found.\n");
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000447 return 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000448 }
449
450 opendir(DIR, $Dir);
Ted Kremenek938eef12009-02-17 23:31:05 +0000451 my @files = grep { /^report-.*\.html$/ } readdir(DIR);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000452 closedir(DIR);
453
Ted Kremenek938eef12009-02-17 23:31:05 +0000454 if (scalar(@files) == 0 and ! -e "$Dir/failures") {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000455 Diag("Removing directory '$Dir' because it contains no reports.\n");
Ted Kremenek20161e92008-07-15 20:18:21 +0000456 system ("rm", "-fR", $Dir);
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000457 return 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000458 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000459
Ted Kremenek991c54b2008-08-08 20:46:42 +0000460 # Scan each report file and build an index.
461 my @Index;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000462 foreach my $file (@files) { ScanFile(\@Index, $Dir, $file); }
463
Ted Kremenek938eef12009-02-17 23:31:05 +0000464 # Scan the failures directory and use the information in the .info files
Ted Kremenekd52e4252008-08-25 20:45:07 +0000465 # to update the common prefix directory.
Ted Kremenek938eef12009-02-17 23:31:05 +0000466 my @failures;
467 my @attributes_ignored;
468 if (-d "$Dir/failures") {
469 opendir(DIR, "$Dir/failures");
470 @failures = grep { /[.]info.txt$/ && !/attribute_ignored/; } readdir(DIR);
Ted Kremenekd52e4252008-08-25 20:45:07 +0000471 closedir(DIR);
Ted Kremenek938eef12009-02-17 23:31:05 +0000472 opendir(DIR, "$Dir/failures");
473 @attributes_ignored = grep { /^attribute_ignored/; } readdir(DIR);
474 closedir(DIR);
475 foreach my $file (@failures) {
476 open IN, "$Dir/failures/$file" or DieDiag("cannot open $file\n");
Ted Kremenekd52e4252008-08-25 20:45:07 +0000477 my $Path = <IN>;
478 if (defined $Path) { UpdatePrefix($Path); }
479 close IN;
480 }
481 }
482
Ted Kremenek63c20172008-08-04 17:34:06 +0000483 # Generate an index.html file.
484 my $FName = "$Dir/index.html";
485 open(OUT, ">", $FName) or DieDiag("Cannot create file '$FName'\n");
Ted Kremenek5744dc22008-04-02 18:03:36 +0000486
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000487 # Print out the header.
488
Ted Kremenek5744dc22008-04-02 18:03:36 +0000489print OUT <<ENDTEXT;
490<html>
491<head>
Ted Kremenek7cba1122008-09-22 01:35:58 +0000492<title>${HtmlTitle}</title>
Ted Kremenekf1435452008-09-23 22:34:51 +0000493<link type="text/css" rel="stylesheet" href="scanview.css"/>
Ted Kremenek22d6a632008-04-02 20:43:36 +0000494<script src="sorttable.js"></script>
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000495<script language='javascript' type="text/javascript">
496function SetDisplay(RowClass, DisplayVal)
497{
498 var Rows = document.getElementsByTagName("tr");
499 for ( var i = 0 ; i < Rows.length; ++i ) {
500 if (Rows[i].className == RowClass) {
501 Rows[i].style.display = DisplayVal;
502 }
503 }
504}
Ted Kremenekebb74132008-09-21 06:58:09 +0000505
Ted Kremenek2350a462008-10-28 19:56:52 +0000506function CopyCheckedStateToCheckButtons(SummaryCheckButton) {
507 var Inputs = document.getElementsByTagName("input");
508 for ( var i = 0 ; i < Inputs.length; ++i ) {
509 if (Inputs[i].type == "checkbox") {
510 if(Inputs[i] != SummaryCheckButton) {
511 Inputs[i].checked = SummaryCheckButton.checked;
512 Inputs[i].onclick();
513 }
514 }
515 }
516}
517
Ted Kremenek999e1202008-10-28 20:09:57 +0000518function returnObjById( id ) {
519 if (document.getElementById)
520 var returnVar = document.getElementById(id);
521 else if (document.all)
522 var returnVar = document.all[id];
523 else if (document.layers)
524 var returnVar = document.layers[id];
525 return returnVar;
526}
527
528var NumUnchecked = 0;
529
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000530function ToggleDisplay(CheckButton, ClassName) {
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000531 if (CheckButton.checked) {
532 SetDisplay(ClassName, "");
Ted Kremenek999e1202008-10-28 20:09:57 +0000533 if (--NumUnchecked == 0) {
534 returnObjById("AllBugsCheck").checked = true;
535 }
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000536 }
537 else {
538 SetDisplay(ClassName, "none");
Ted Kremenek999e1202008-10-28 20:09:57 +0000539 NumUnchecked++;
540 returnObjById("AllBugsCheck").checked = false;
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000541 }
542}
543</script>
Ted Kremenek1d1abb12008-09-22 17:52:58 +0000544<!-- SUMMARYENDHEAD -->
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000545</head>
546<body>
Ted Kremenek7cba1122008-09-22 01:35:58 +0000547<h1>${HtmlTitle}</h1>
548
549<table>
550<tr><th>User:</th><td>${UserName}\@${HostName}</td></tr>
551<tr><th>Working Directory:</th><td>${CurrentDir}</td></tr>
552<tr><th>Command Line:</th><td>${CmdArgs}</td></tr>
553<tr><th>Date:</th><td>${Date}</td></tr>
554ENDTEXT
555
556print OUT "<tr><th>Version:</th><td>${BuildName} (${BuildDate})</td></tr>\n"
557 if (defined($BuildName) && defined($BuildDate));
558
559print OUT <<ENDTEXT;
560</table>
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000561ENDTEXT
562
Ted Kremenek991c54b2008-08-08 20:46:42 +0000563 if (scalar(@files)) {
564 # Print out the summary table.
565 my %Totals;
Ted Kremenekebb74132008-09-21 06:58:09 +0000566
Ted Kremenek991c54b2008-08-08 20:46:42 +0000567 for my $row ( @Index ) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000568 my $bug_type = ($row->[2]);
569 my $bug_category = ($row->[1]);
570 my $key = "$bug_category:$bug_type";
571
572 if (!defined $Totals{$key}) { $Totals{$key} = [1,$bug_category,$bug_type]; }
573 else { $Totals{$key}->[0]++; }
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000574 }
Ted Kremenek991c54b2008-08-08 20:46:42 +0000575
Ted Kremenek7cba1122008-09-22 01:35:58 +0000576 print OUT "<h2>Bug Summary</h2>";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000577
578 if (defined $BuildName) {
579 print OUT "\n<p>Results in this analysis run are based on analyzer build <b>$BuildName</b>.</p>\n"
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000580 }
Ted Kremenekf4cdf412008-05-23 18:17:05 +0000581
Ted Kremenek2350a462008-10-28 19:56:52 +0000582 my $TotalBugs = scalar(@Index);
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000583print OUT <<ENDTEXT;
Ted Kremenekebb74132008-09-21 06:58:09 +0000584<table>
585<thead><tr><td>Bug Type</td><td>Quantity</td><td class="sorttable_nosort">Display?</td></tr></thead>
Ted Kremenek999e1202008-10-28 20:09:57 +0000586<tr style="font-weight:bold"><td class="SUMM_DESC">All Bugs</td><td class="Q">$TotalBugs</td><td><center><input type="checkbox" id="AllBugsCheck" onClick="CopyCheckedStateToCheckButtons(this);" checked/></center></td></tr>
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000587ENDTEXT
588
Ted Kremenekebb74132008-09-21 06:58:09 +0000589 my $last_category;
590
591 for my $key (
592 sort {
593 my $x = $Totals{$a};
594 my $y = $Totals{$b};
595 my $res = $x->[1] cmp $y->[1];
596 $res = $x->[2] cmp $y->[2] if ($res == 0);
597 $res
598 } keys %Totals )
599 {
600 my $val = $Totals{$key};
601 my $category = $val->[1];
602 if (!defined $last_category or $last_category ne $category) {
603 $last_category = $category;
604 print OUT "<tr><th>$category</th><th colspan=2></th></tr>\n";
605 }
606 my $x = lc $key;
607 $x =~ s/[ ,'":\/()]+/_/g;
608 print OUT "<tr><td class=\"SUMM_DESC\">";
609 print OUT $val->[2];
Ted Kremenek2350a462008-10-28 19:56:52 +0000610 print OUT "</td><td class=\"Q\">";
Ted Kremenekebb74132008-09-21 06:58:09 +0000611 print OUT $val->[0];
612 print OUT "</td><td><center><input type=\"checkbox\" onClick=\"ToggleDisplay(this,'bt_$x');\" checked/></center></td></tr>\n";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000613 }
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000614
615 # Print out the table of errors.
616
617print OUT <<ENDTEXT;
618</table>
Ted Kremenek7cba1122008-09-22 01:35:58 +0000619<h2>Reports</h2>
Ted Kremenekebb74132008-09-21 06:58:09 +0000620
621<table class="sortable" style="table-layout:automatic">
622<thead><tr>
623 <td>Bug Group</td>
624 <td class="sorttable_sorted">Bug Type<span id="sorttable_sortfwdind">&nbsp;&#x25BE;</span></td>
Ted Kremenekbba1cf52008-04-03 05:50:51 +0000625 <td>File</td>
Ted Kremenekebb74132008-09-21 06:58:09 +0000626 <td class="Q">Line</td>
Ted Kremenek81983112008-09-28 04:13:09 +0000627 <td class="Q">Path Length</td>
Ted Kremenek2645c772008-07-07 16:58:44 +0000628 <td class="sorttable_nosort"></td>
Ted Kremenekebb74132008-09-21 06:58:09 +0000629 <!-- REPORTBUGCOL -->
630</tr></thead>
631<tbody>
Ted Kremenek5744dc22008-04-02 18:03:36 +0000632ENDTEXT
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000633
Ted Kremenek991c54b2008-08-08 20:46:42 +0000634 my $prefix = GetPrefix();
635 my $regex;
636 my $InFileRegex;
637 my $InFilePrefix = "File:</td><td>";
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000638
Ted Kremenek991c54b2008-08-08 20:46:42 +0000639 if (defined $prefix) {
640 $regex = qr/^\Q$prefix\E/is;
641 $InFileRegex = qr/\Q$InFilePrefix$prefix\E/is;
642 }
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000643
Ted Kremenekebb74132008-09-21 06:58:09 +0000644 for my $row ( sort { $a->[2] cmp $b->[2] } @Index ) {
645 my $x = "$row->[1]:$row->[2]";
646 $x = lc $x;
647 $x =~ s/[ ,'":\/()]+/_/g;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000648
Ted Kremenek991c54b2008-08-08 20:46:42 +0000649 my $ReportFile = $row->[0];
Ted Kremenekebb74132008-09-21 06:58:09 +0000650
651 print OUT "<tr class=\"bt_$x\">";
652 print OUT "<td class=\"DESC\">";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000653 print OUT $row->[1];
Ted Kremenekebb74132008-09-21 06:58:09 +0000654 print OUT "</td>";
655 print OUT "<td class=\"DESC\">";
656 print OUT $row->[2];
657 print OUT "</td>";
658
659 # Update the file prefix.
660 my $fname = $row->[3];
Ted Kremenekebb74132008-09-21 06:58:09 +0000661
Ted Kremenek991c54b2008-08-08 20:46:42 +0000662 if (defined $regex) {
663 $fname =~ s/$regex//;
664 UpdateInFilePath("$Dir/$ReportFile", $InFileRegex, $InFilePrefix)
665 }
Ted Kremenekebb74132008-09-21 06:58:09 +0000666
Ted Kremenek91639ef2008-09-22 17:42:31 +0000667 print OUT "<td>";
Ted Kremenekebb74132008-09-21 06:58:09 +0000668 my @fname = split /\//,$fname;
669 if ($#fname > 0) {
670 while ($#fname >= 0) {
671 my $x = shift @fname;
672 print OUT $x;
673 if ($#fname >= 0) {
674 print OUT "<span class=\"W\"> </span>/";
675 }
676 }
677 }
678 else {
679 print OUT $fname;
Ted Kremenek91639ef2008-09-22 17:42:31 +0000680 }
Ted Kremenekebb74132008-09-21 06:58:09 +0000681 print OUT "</td>";
682
683 # Print out the quantities.
Ted Kremenek81983112008-09-28 04:13:09 +0000684 for my $j ( 4 .. 5 ) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000685 print OUT "<td class=\"Q\">$row->[$j]</td>";
686 }
687
Ted Kremenek991c54b2008-08-08 20:46:42 +0000688 # Print the rest of the columns.
Ted Kremenek81983112008-09-28 04:13:09 +0000689 for (my $j = 6; $j <= $#{$row}; ++$j) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000690 print OUT "<td>$row->[$j]</td>"
Ted Kremenek991c54b2008-08-08 20:46:42 +0000691 }
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000692
Ted Kremenek991c54b2008-08-08 20:46:42 +0000693 # Emit the "View" link.
Ted Kremenek68005dd2008-09-22 17:39:18 +0000694 print OUT "<td><a href=\"$ReportFile#EndPath\">View Report</a></td>";
Ted Kremenek3cea9ee2008-07-30 17:58:08 +0000695
Daniel Dunbare43038e2008-09-19 23:18:44 +0000696 # Emit REPORTBUG markers.
Ted Kremenekebb74132008-09-21 06:58:09 +0000697 print OUT "\n<!-- REPORTBUG id=\"$ReportFile\" -->\n";
Daniel Dunbare43038e2008-09-19 23:18:44 +0000698
Ted Kremenek991c54b2008-08-08 20:46:42 +0000699 # End the row.
700 print OUT "</tr>\n";
701 }
702
Ted Kremenekebb74132008-09-21 06:58:09 +0000703 print OUT "</tbody>\n</table>\n\n";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000704 }
705
Ted Kremenek938eef12009-02-17 23:31:05 +0000706 if (scalar (@failures) || scalar(@attributes_ignored)) {
707 print OUT "<h2>Analyzer Failures</h2>\n";
708
709 if (scalar @attributes_ignored) {
710 print OUT "The analyzer's parser ignored the following attributes:<p>\n";
711 print OUT "<table>\n";
712 print OUT "<thead><tr><td>Attribute</td><td>Source File</td><td>Preprocessed File</td><td>STDERR Output</td></tr></thead>\n";
713 foreach my $file (sort @attributes_ignored) {
714 die "cannot demangle attribute name\n" if (! ($file =~ /^attribute_ignored_(.+).txt/));
715 my $attribute = $1;
716 # Open the attribute file to get the first file that failed.
717 next if (!open (ATTR, "$Dir/failures/$file"));
718 my $ppfile = <ATTR>;
719 chomp $ppfile;
720 close ATTR;
721 next if (! -e "$Dir/failures/$ppfile");
722 # Open the info file and get the name of the source file.
723 open (INFO, "$Dir/failures/$ppfile.info.txt") or
724 die "Cannot open $Dir/failures/$ppfile.info.txt\n";
725 my $srcfile = <INFO>;
726 chomp $srcfile;
727 close (INFO);
728 # Print the information in the table.
729 my $prefix = GetPrefix();
730 if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; }
731 print OUT "<tr><td>$attribute</td><td>$srcfile</td><td><a href=\"failures/$ppfile\">$ppfile</a></td><td><a href=\"failures/$ppfile.stderr.txt\">$ppfile.stderr.txt</a></td></tr>\n";
732 my $ppfile_clang = $ppfile;
733 $ppfile_clang =~ s/[.](.+)$/.clang.$1/;
734 print OUT " <!-- REPORTPROBLEM src=\"$srcfile\" file=\"failures/$ppfile\" clangfile=\"failures/$ppfile_clang\" stderr=\"failures/$ppfile.stderr.txt\" info=\"failures/$ppfile.info.txt\" -->\n";
735 }
736 print OUT "</table>\n";
737 }
738
739 if (scalar @failures) {
740 print OUT "<p>The analyzer had problems processing the following files:</p>\n";
741 print OUT "<table>\n";
742 print OUT "<thead><tr><td>Problem</td><td>Source File</td><td>Preprocessed File</td><td>STDERR Output</td></tr></thead>\n";
743 foreach my $file (sort @failures) {
Ted Kremenek82a12532008-09-25 00:25:16 +0000744 $file =~ /(.+).info.txt$/;
Ted Kremenek991c54b2008-08-08 20:46:42 +0000745 # Get the preprocessed file.
746 my $ppfile = $1;
747 # Open the info file and get the name of the source file.
Ted Kremenek938eef12009-02-17 23:31:05 +0000748 open (INFO, "$Dir/failures/$file") or
749 die "Cannot open $Dir/failures/$file\n";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000750 my $srcfile = <INFO>;
Ted Kremenek5d31f832008-08-18 18:38:29 +0000751 chomp $srcfile;
752 my $problem = <INFO>;
753 chomp $problem;
Ted Kremenek991c54b2008-08-08 20:46:42 +0000754 close (INFO);
755 # Print the information in the table.
Ted Kremenekd52e4252008-08-25 20:45:07 +0000756 my $prefix = GetPrefix();
Ted Kremenek9f9b1fd2008-09-12 22:49:36 +0000757 if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; }
Ted Kremenek938eef12009-02-17 23:31:05 +0000758 print OUT "<tr><td>$problem</td><td>$srcfile</td><td><a href=\"failures/$ppfile\">$ppfile</a></td><td><a href=\"failures/$ppfile.stderr.txt\">$ppfile.stderr.txt</a></td></tr>\n";
Daniel Dunbarce723ce2008-09-25 01:10:50 +0000759 my $ppfile_clang = $ppfile;
760 $ppfile_clang =~ s/[.](.+)$/.clang.$1/;
Ted Kremenek938eef12009-02-17 23:31:05 +0000761 print OUT " <!-- REPORTPROBLEM src=\"$srcfile\" file=\"failures/$ppfile\" clangfile=\"failures/$ppfile_clang\" stderr=\"failures/$ppfile.stderr.txt\" info=\"failures/$ppfile.info.txt\" -->\n";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000762 }
Ted Kremenek938eef12009-02-17 23:31:05 +0000763 print OUT "</table>\n";
764 }
765 print OUT "<p>Please consider submitting preprocessed files as <a href=\"http://clang.llvm.org/StaticAnalysisUsage.html#filingbugs\">bug reports</a>. <!-- REPORTCRASHES --> </p>\n";
Ted Kremenek5744dc22008-04-02 18:03:36 +0000766 }
767
Ted Kremenek991c54b2008-08-08 20:46:42 +0000768 print OUT "</body></html>\n";
Ted Kremenek5744dc22008-04-02 18:03:36 +0000769 close(OUT);
Ted Kremenek3ce12072008-09-22 17:50:47 +0000770 CopyFiles($Dir);
Ted Kremenek20161e92008-07-15 20:18:21 +0000771
772 # Make sure $Dir and $BaseDir are world readable/executable.
773 system("chmod", "755", $Dir);
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000774 if (defined $BaseDir) { system("chmod", "755", $BaseDir); }
Ted Kremenek20161e92008-07-15 20:18:21 +0000775
Ted Kremenek23cfca32008-06-16 22:40:14 +0000776 my $Num = scalar(@Index);
Ted Kremenek150c2122008-07-11 19:15:05 +0000777 Diag("$Num bugs found.\n");
778 if ($Num > 0 && -r "$Dir/index.html") {
Ted Kremenek5950b3f2008-09-22 06:47:01 +0000779 Diag("Run 'scan-view $Dir' to examine bug reports.\n");
Ted Kremenek150c2122008-07-11 19:15:05 +0000780 }
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000781
Ted Kremenek938eef12009-02-17 23:31:05 +0000782 DiagCrashes($Dir) if (scalar @failures || scalar @attributes_ignored);
Ted Kremenek991c54b2008-08-08 20:46:42 +0000783
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000784 return $Num;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000785}
786
787##----------------------------------------------------------------------------##
Ted Kremenekdab11102008-04-02 04:43:42 +0000788# RunBuildCommand - Run the build command.
789##----------------------------------------------------------------------------##
790
Ted Kremenek6b628982008-04-30 23:47:12 +0000791sub AddIfNotPresent {
792 my $Args = shift;
793 my $Arg = shift;
794 my $found = 0;
795
796 foreach my $k (@$Args) {
797 if ($k eq $Arg) {
798 $found = 1;
799 last;
800 }
801 }
802
803 if ($found == 0) {
804 push @$Args, $Arg;
805 }
806}
807
Ted Kremenekdab11102008-04-02 04:43:42 +0000808sub RunBuildCommand {
809
810 my $Args = shift;
Ted Kremenek7442ca62008-04-02 16:04:51 +0000811 my $IgnoreErrors = shift;
Ted Kremenekdab11102008-04-02 04:43:42 +0000812 my $Cmd = $Args->[0];
Ted Kremenek6195c372008-06-02 21:52:47 +0000813 my $CCAnalyzer = shift;
Ted Kremenekdab11102008-04-02 04:43:42 +0000814
Ted Kremenek3301cb12008-06-30 18:18:16 +0000815 # Get only the part of the command after the last '/'.
816 if ($Cmd =~ /\/([^\/]+)$/) {
817 $Cmd = $1;
818 }
819
Ted Kremenek92548fe2008-11-19 01:46:21 +0000820 if ($Cmd =~ /(.*\/?gcc[^\/]*$)/ or
821 $Cmd =~ /(.*\/?cc[^\/]*$)/ or
822 $Cmd =~ /(.*\/?llvm-gcc[^\/]*$)/ or
823 $Cmd =~ /(.*\/?ccc-analyzer[^\/]*$)/) {
824
825 if (!($Cmd =~ /ccc-analyzer/) and !defined $ENV{"CCC_CC"}) {
826 $ENV{"CCC_CC"} = $1;
827 }
828
Ted Kremenekdab11102008-04-02 04:43:42 +0000829 shift @$Args;
Ted Kremenek6195c372008-06-02 21:52:47 +0000830 unshift @$Args, $CCAnalyzer;
Ted Kremenekdab11102008-04-02 04:43:42 +0000831 }
Ted Kremenek7442ca62008-04-02 16:04:51 +0000832 elsif ($IgnoreErrors) {
833 if ($Cmd eq "make" or $Cmd eq "gmake") {
Ted Kremenek6b628982008-04-30 23:47:12 +0000834 AddIfNotPresent($Args,"-k");
Ted Kremenek8912b542008-05-13 21:28:02 +0000835 AddIfNotPresent($Args,"-i");
Ted Kremenek7442ca62008-04-02 16:04:51 +0000836 }
837 elsif ($Cmd eq "xcodebuild") {
Ted Kremenek6b628982008-04-30 23:47:12 +0000838 AddIfNotPresent($Args,"-PBXBuildsContinueAfterErrors=YES");
Ted Kremenek7442ca62008-04-02 16:04:51 +0000839 }
Ted Kremenek6b628982008-04-30 23:47:12 +0000840 }
841
Ted Kremenek6b628982008-04-30 23:47:12 +0000842 if ($Cmd eq "xcodebuild") {
Ted Kremenekcfd4c7b2008-05-23 22:18:16 +0000843 # Disable distributed builds for xcodebuild.
Ted Kremenek6b628982008-04-30 23:47:12 +0000844 AddIfNotPresent($Args,"-nodistribute");
Ted Kremenekcfd4c7b2008-05-23 22:18:16 +0000845
846 # Disable PCH files until clang supports them.
847 AddIfNotPresent($Args,"GCC_PRECOMPILE_PREFIX_HEADER=NO");
Ted Kremenek915e9722008-05-27 23:18:07 +0000848
849 # When 'CC' is set, xcodebuild uses it to do all linking, even if we are
850 # linking C++ object files. Set 'LDPLUSPLUS' so that xcodebuild uses 'g++'
851 # when linking such files.
Ted Kremenek95aa1052008-09-04 17:52:41 +0000852 die if (!defined $CXX);
853 my $LDPLUSPLUS = `which $CXX`;
Ted Kremenek915e9722008-05-27 23:18:07 +0000854 $LDPLUSPLUS =~ s/\015?\012//; # strip newlines
855 $ENV{'LDPLUSPLUS'} = $LDPLUSPLUS;
Ted Kremenek6b628982008-04-30 23:47:12 +0000856 }
Ted Kremenekdab11102008-04-02 04:43:42 +0000857
Ted Kremenek5a4ddaf2008-08-25 20:10:45 +0000858 return (system(@$Args) >> 8);
Ted Kremenekdab11102008-04-02 04:43:42 +0000859}
860
Ted Kremenekdab11102008-04-02 04:43:42 +0000861##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000862# DisplayHelp - Utility function to display all help options.
863##----------------------------------------------------------------------------##
864
Sam Bishopa0e22662008-04-02 03:35:43 +0000865sub DisplayHelp {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000866
Ted Kremenek5744dc22008-04-02 18:03:36 +0000867print <<ENDTEXT;
Sam Bishopa0e22662008-04-02 03:35:43 +0000868USAGE: $Prog [options] <build command> [build options]
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000869
Ted Kremenekf4cdf412008-05-23 18:17:05 +0000870ENDTEXT
871
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000872 if (defined $BuildName) {
Ted Kremenekf4cdf412008-05-23 18:17:05 +0000873 print "ANALYZER BUILD: $BuildName ($BuildDate)\n\n";
874 }
875
876print <<ENDTEXT;
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000877OPTIONS:
878
Ted Kremeneke15fa272008-10-13 21:46:42 +0000879 -analyze-headers - Also analyze functions in #included files.
880
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000881 -o - Target directory for HTML report files. Subdirectories
Sam Bishopa0e22662008-04-02 03:35:43 +0000882 will be created as needed to represent separate "runs" of
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000883 the analyzer. If this option is not specified, a directory
Ted Kremenekffda0b42008-10-31 05:48:42 +0000884 is created in /tmp (TMPDIR on Mac OS X) to store the reports.
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000885
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000886 -h - Display this message.
887 --help
Ted Kremenek1262fc42008-05-14 20:10:33 +0000888
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000889 -k - Add a "keep on going" option to the specified build command.
890 --keep-going This option currently supports make and xcodebuild.
Ted Kremenekf02e8db2008-04-02 16:41:25 +0000891 This is a convenience option; one can specify this
892 behavior directly using build options.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000893
Ted Kremenek7cba1122008-09-22 01:35:58 +0000894 --html-title [title] - Specify the title used on generated HTML pages.
895 --html-title=[title] If not specified, a default title will be used.
896
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000897 -plist - By default the output of scan-build is a set of HTML files.
898 This option outputs the results as a set of .plist files.
899
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000900 --status-bugs - By default, the exit status of $Prog is the same as the
901 executed build command. Specifying this option causes the
902 exit status of $Prog to be 1 if it found potential bugs
903 and 0 otherwise.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000904
Ted Kremenek386c6932008-09-03 17:59:35 +0000905 --use-cc [compiler path] - By default, $Prog uses 'gcc' to compile and link
906 --use-cc=[compiler path] your C and Objective-C code. Use this option
907 to specify an alternate compiler.
908
909 --use-c++ [compiler path] - By default, $Prog uses 'g++' to compile and link
910 --use-c++=[compiler path] your C++ and Objective-C++ code. Use this option
911 to specify an alternate compiler.
Ted Kremenekf17ef3c2008-08-21 21:47:09 +0000912
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000913 -v - Verbose output from $Prog and the analyzer.
Ted Kremenek386c6932008-09-03 17:59:35 +0000914 A second and third '-v' increases verbosity.
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000915
916 -V - View analysis results in a web browser when the build
917 --view completes.
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000918
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000919ADVANCED OPTIONS:
920
Ted Kremenek9f4ecb32009-02-20 21:49:22 +0000921 -constraints [model] - Specify the contraint engine used by the analyzer.
922 By default the 'range' model is used. Specifying
923 'basic' uses a simpler, less powerful constraint model
Ted Kremenekd4c76842009-02-21 04:46:41 +0000924 used by checker-0.160 and earlier.
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000925
926 -store [model] - Specify the store model used by the analyzer. By default,
927 the 'basic' store model is used. 'region' specifies a field-
928 sensitive store model. Be warned that the 'region' model
929 is still in very early testing phase and may often crash.
Ted Kremenekb7770c02008-07-15 17:06:13 +0000930
Ted Kremenek386c6932008-09-03 17:59:35 +0000931AVAILABLE ANALYSES (multiple analyses may be specified):
Ted Kremenekd52e4252008-08-25 20:45:07 +0000932
933ENDTEXT
Ted Kremenekb7770c02008-07-15 17:06:13 +0000934
935 foreach my $Analysis (sort keys %AvailableAnalyses) {
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000936 if (defined $AnalysesDefaultEnabled{$Analysis}) {
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000937 print " (+)";
Ted Kremenekb7770c02008-07-15 17:06:13 +0000938 }
939 else {
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000940 print " ";
Ted Kremenekb7770c02008-07-15 17:06:13 +0000941 }
942
943 print " $Analysis $AvailableAnalyses{$Analysis}\n";
944 }
945
946print <<ENDTEXT
947
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000948 NOTE: "(+)" indicates that an analysis is enabled by default unless one
949 or more analysis options are specified
Ted Kremenekb7770c02008-07-15 17:06:13 +0000950
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000951BUILD OPTIONS
952
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000953 You can specify any build option acceptable to the build command.
Ted Kremenek39eefde2008-04-02 16:47:27 +0000954
Ted Kremenek5744dc22008-04-02 18:03:36 +0000955EXAMPLE
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000956
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000957 $Prog -o /tmp/myhtmldir make -j4
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000958
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000959 The above example causes analysis reports to be deposited into
960 a subdirectory of "/tmp/myhtmldir" and to run "make" with the "-j4" option.
961 A different subdirectory is created each time $Prog analyzes a project.
962 The analyzer should support most parallel builds, but not distributed builds.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000963
964ENDTEXT
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000965}
966
967##----------------------------------------------------------------------------##
Ted Kremenek7cba1122008-09-22 01:35:58 +0000968# HtmlEscape - HTML entity encode characters that are special in HTML
969##----------------------------------------------------------------------------##
970
971sub HtmlEscape {
972 # copy argument to new variable so we don't clobber the original
973 my $arg = shift || '';
974 my $tmp = $arg;
Ted Kremenek87f8de72008-11-03 07:44:16 +0000975 $tmp =~ s/&/&amp;/g;
976 $tmp =~ s/</&lt;/g;
977 $tmp =~ s/>/&gt;/g;
Ted Kremenek7cba1122008-09-22 01:35:58 +0000978 return $tmp;
979}
980
981##----------------------------------------------------------------------------##
982# ShellEscape - backslash escape characters that are special to the shell
983##----------------------------------------------------------------------------##
984
985sub ShellEscape {
986 # copy argument to new variable so we don't clobber the original
987 my $arg = shift || '';
Ted Kremenek87f8de72008-11-03 07:44:16 +0000988 if ($arg =~ /["\s]/) { return "'" . $arg . "'"; }
989 return $arg;
Ted Kremenek7cba1122008-09-22 01:35:58 +0000990}
991
992##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000993# Process command-line arguments.
994##----------------------------------------------------------------------------##
995
Ted Kremeneke15fa272008-10-13 21:46:42 +0000996my $AnalyzeHeaders = 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000997my $HtmlDir; # Parent directory to store HTML files.
998my $IgnoreErrors = 0; # Ignore build errors.
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000999my $ViewResults = 0; # View results when the build terminates.
Ted Kremenek363dc3f2008-07-15 22:03:09 +00001000my $ExitStatusFoundBugs = 0; # Exit status reflects whether bugs were found
Ted Kremenekb7770c02008-07-15 17:06:13 +00001001my @AnalysesToRun;
Zhongxing Xu07c37672008-10-27 14:26:32 +00001002my $StoreModel;
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +00001003my $ConstraintsModel;
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001004my $OutputFormat;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001005
1006if (!@ARGV) {
1007 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +00001008 exit 1;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001009}
1010
1011while (@ARGV) {
1012
1013 # Scan for options we recognize.
1014
1015 my $arg = $ARGV[0];
1016
Sam Bishop2f2418e2008-04-03 14:29:47 +00001017 if ($arg eq "-h" or $arg eq "--help") {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001018 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +00001019 exit 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001020 }
1021
Ted Kremeneke15fa272008-10-13 21:46:42 +00001022 if ($arg eq '-analyze-headers') {
1023 shift @ARGV;
1024 $AnalyzeHeaders = 1;
1025 next;
1026 }
1027
Ted Kremenekfc1d3402008-08-04 18:15:26 +00001028 if (defined $AvailableAnalyses{$arg}) {
Ted Kremenek1262fc42008-05-14 20:10:33 +00001029 shift @ARGV;
Ted Kremenekb7770c02008-07-15 17:06:13 +00001030 push @AnalysesToRun, $arg;
Ted Kremenek1262fc42008-05-14 20:10:33 +00001031 next;
1032 }
1033
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001034 if ($arg eq "-o") {
1035 shift @ARGV;
1036
1037 if (!@ARGV) {
Ted Kremenek23cfca32008-06-16 22:40:14 +00001038 DieDiag("'-o' option requires a target directory name.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001039 }
1040
1041 $HtmlDir = shift @ARGV;
1042 next;
1043 }
Ted Kremenek7cba1122008-09-22 01:35:58 +00001044
1045 if ($arg =~ /^--html-title(=(.+))?$/) {
1046 shift @ARGV;
1047
1048 if ($2 eq '') {
1049 if (!@ARGV) {
1050 DieDiag("'--html-title' option requires a string.\n");
1051 }
1052
1053 $HtmlTitle = shift @ARGV;
1054 } else {
1055 $HtmlTitle = $2;
1056 }
1057
1058 next;
1059 }
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001060
Ted Kremenek2b74ab62008-04-01 21:22:03 +00001061 if ($arg eq "-k" or $arg eq "--keep-going") {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001062 shift @ARGV;
1063 $IgnoreErrors = 1;
1064 next;
1065 }
1066
Ted Kremenekf17ef3c2008-08-21 21:47:09 +00001067 if ($arg =~ /^--use-cc(=(.+))?$/) {
1068 shift @ARGV;
1069 my $cc;
1070
1071 if ($2 eq "") {
1072 if (!@ARGV) {
1073 DieDiag("'--use-cc' option requires a compiler executable name.\n");
1074 }
1075 $cc = shift @ARGV;
1076 }
1077 else {
1078 $cc = $2;
1079 }
1080
1081 $ENV{"CCC_CC"} = $cc;
1082 next;
1083 }
1084
Ted Kremenek7cba1122008-09-22 01:35:58 +00001085 if ($arg =~ /^--use-c\+\+(=(.+))?$/) {
Ted Kremenek386c6932008-09-03 17:59:35 +00001086 shift @ARGV;
1087
1088 if ($2 eq "") {
1089 if (!@ARGV) {
1090 DieDiag("'--use-c++' option requires a compiler executable name.\n");
1091 }
1092 $CXX = shift @ARGV;
1093 }
1094 else {
1095 $CXX = $2;
1096 }
1097 next;
1098 }
1099
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001100 if ($arg eq "-v") {
1101 shift @ARGV;
1102 $Verbose++;
1103 next;
1104 }
1105
Ted Kremenek7f8a3252008-04-02 18:42:49 +00001106 if ($arg eq "-V" or $arg eq "--view") {
1107 shift @ARGV;
1108 $ViewResults = 1;
1109 next;
1110 }
1111
Ted Kremenek363dc3f2008-07-15 22:03:09 +00001112 if ($arg eq "--status-bugs") {
1113 shift @ARGV;
1114 $ExitStatusFoundBugs = 1;
1115 next;
1116 }
Zhongxing Xu07c37672008-10-27 14:26:32 +00001117
1118 if ($arg eq "-store") {
1119 shift @ARGV;
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +00001120 $StoreModel = shift @ARGV;
1121 next;
1122 }
1123
1124 if ($arg eq "-constraints") {
1125 shift @ARGV;
1126 $ConstraintsModel = shift @ARGV;
Zhongxing Xu07c37672008-10-27 14:26:32 +00001127 next;
1128 }
Ted Kremenek363dc3f2008-07-15 22:03:09 +00001129
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001130 if ($arg eq "-plist") {
1131 shift @ARGV;
1132 $OutputFormat = "plist";
1133 next;
1134 }
1135
Ted Kremenek23cfca32008-06-16 22:40:14 +00001136 DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/);
Ted Kremenek0062ad42008-04-02 16:35:01 +00001137
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001138 last;
1139}
1140
1141if (!@ARGV) {
Ted Kremenek23cfca32008-06-16 22:40:14 +00001142 Diag("No build command specified.\n\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001143 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +00001144 exit 1;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001145}
1146
Ted Kremenek7cba1122008-09-22 01:35:58 +00001147$CmdArgs = HtmlEscape(join(' ', map(ShellEscape($_), @ARGV)));
1148$HtmlTitle = "${CurrentDirSuffix} - scan-build results"
1149 unless (defined($HtmlTitle));
Ted Kremenek386c6932008-09-03 17:59:35 +00001150
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001151# Determine the output directory for the HTML reports.
Ted Kremenek684bb092008-04-18 15:18:20 +00001152my $BaseDir = $HtmlDir;
Sam Bishopa0e22662008-04-02 03:35:43 +00001153$HtmlDir = GetHTMLRunDir($HtmlDir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001154
1155# Set the appropriate environment variables.
Sam Bishopa0e22662008-04-02 03:35:43 +00001156SetHtmlEnv(\@ARGV, $HtmlDir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001157
Ted Kremenekce87b922009-02-25 22:54:02 +00001158my $Cmd = Cwd::realpath("$RealBin/bin/ccc-analyzer");
1159if (!defined $Cmd || ! -x $Cmd) {
1160 $Cmd = Cwd::realpath("$RealBin/ccc-analyzer");
Ted Kremenek6b896362009-02-27 06:17:05 +00001161 DieDiag("Executable 'ccc-analyzer' does not exist at '$Cmd'\n") if(! -x $Cmd);
Ted Kremenekce87b922009-02-25 22:54:02 +00001162}
Ted Kremenekf22eacb2008-04-18 22:00:56 +00001163
Ted Kremenek2d62ab12009-02-23 23:01:06 +00001164if (!defined $ClangSB || ! -x $ClangSB) {
1165 Diag("'clang' executable not found in '$RealBin/bin'.\n");
Ted Kremenekb7770c02008-07-15 17:06:13 +00001166 Diag("Using 'clang' from path.\n");
Ted Kremenekf22eacb2008-04-18 22:00:56 +00001167}
Ted Kremenek0b6c1532008-04-08 20:22:12 +00001168
Ted Kremenek95aa1052008-09-04 17:52:41 +00001169if (defined $CXX) {
1170 $ENV{'CXX'} = $CXX;
1171}
1172else {
1173 $CXX = 'g++'; # This variable is used by other parts of scan-build
1174 # that need to know a default C++ compiler to fall back to.
1175}
1176
Ted Kremenek4f4b17d2008-04-03 20:08:18 +00001177$ENV{'CC'} = $Cmd;
Ted Kremenekf22eacb2008-04-18 22:00:56 +00001178$ENV{'CLANG'} = $Clang;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001179
1180if ($Verbose >= 2) {
1181 $ENV{'CCC_ANALYZER_VERBOSE'} = 1;
1182}
1183
Ted Kremeneka9525c92008-05-12 22:07:14 +00001184if ($Verbose >= 3) {
1185 $ENV{'CCC_ANALYZER_LOG'} = 1;
1186}
1187
Ted Kremenek90125992008-07-15 23:41:32 +00001188if (scalar(@AnalysesToRun) == 0) {
1189 foreach my $key (keys %AnalysesDefaultEnabled) {
1190 push @AnalysesToRun,$key;
1191 }
Ted Kremenek01006782008-07-02 23:16:10 +00001192}
Ted Kremenek1262fc42008-05-14 20:10:33 +00001193
Ted Kremeneke15fa272008-10-13 21:46:42 +00001194if ($AnalyzeHeaders) {
1195 push @AnalysesToRun,"-analyzer-opt-analyze-headers";
1196}
1197
Ted Kremenek90125992008-07-15 23:41:32 +00001198$ENV{'CCC_ANALYZER_ANALYSIS'} = join ' ',@AnalysesToRun;
1199
Zhongxing Xu3cab2b12008-11-02 10:58:16 +00001200if (defined $StoreModel) {
Zhongxing Xu07c37672008-10-27 14:26:32 +00001201 $ENV{'CCC_ANALYZER_STORE_MODEL'} = $StoreModel;
1202}
1203
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +00001204if (defined $ConstraintsModel) {
1205 $ENV{'CCC_ANALYZER_CONSTRAINTS_MODEL'} = $ConstraintsModel;
1206}
1207
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001208if (defined $OutputFormat) {
1209 $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'} = $OutputFormat;
1210}
1211
1212
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001213# Run the build.
Ted Kremenek5656a982008-07-15 17:09:28 +00001214my $ExitStatus = RunBuildCommand(\@ARGV, $IgnoreErrors, $Cmd);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001215
Ted Kremenek655aba72008-11-04 00:22:12 +00001216if (defined $OutputFormat and $OutputFormat eq "plist") {
Ted Kremenek50534dc2008-09-22 17:38:23 +00001217 Diag "Analysis run complete.\n";
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001218 Diag "Analysis results (plist files) deposited in '$HtmlDir'\n";
Ted Kremenek7f8a3252008-04-02 18:42:49 +00001219}
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001220else {
1221 # Postprocess the HTML directory.
1222 my $NumBugs = Postprocess($HtmlDir, $BaseDir);
Ted Kremenek5656a982008-07-15 17:09:28 +00001223
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001224 if ($ViewResults and -r "$HtmlDir/index.html") {
1225 Diag "Analysis run complete.\n";
1226 Diag "Viewing analysis results in '$HtmlDir' using scan-view.\n";
1227 my $ScanView = Cwd::realpath("$RealBin/scan-view");
1228 if (! -x $ScanView) { $ScanView = "scan-view"; }
1229 exec $ScanView, "$HtmlDir";
1230 }
1231
1232 if ($ExitStatusFoundBugs) {
1233 exit 1 if ($NumBugs > 0);
1234 exit 0;
1235 }
Ted Kremenek363dc3f2008-07-15 22:03:09 +00001236}
1237
Ted Kremenek5656a982008-07-15 17:09:28 +00001238exit $ExitStatus;
1239