blob: 6d43c3c9626f4fafa5610c102a5de8d4be27e048 [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 Kremenekb7770c02008-07-15 17:06:13 +000085my $Clang = $ClangSB;
86
Ted Kremenek8d10cdd2009-02-20 04:34:29 +000087if (!defined $ClangSB || ! -x $ClangSB) {
Ted Kremenekb7770c02008-07-15 17:06:13 +000088 $Clang = "clang";
89}
90
91my %AvailableAnalyses;
92
93# Query clang for analysis options.
Ted Kremenek63c20172008-08-04 17:34:06 +000094open(PIPE, "-|", $Clang, "--help") or
Ted Kremenek445fa772008-10-10 00:17:08 +000095 DieDiag("Cannot execute '$Clang'\n");
Ted Kremenek63c20172008-08-04 17:34:06 +000096
Ted Kremenekb7770c02008-07-15 17:06:13 +000097my $FoundAnalysis = 0;
98
99while(<PIPE>) {
100 if ($FoundAnalysis == 0) {
Ted Kremenek938eef12009-02-17 23:31:05 +0000101 if (/Checks and Analyses/) {
Ted Kremenekb7770c02008-07-15 17:06:13 +0000102 $FoundAnalysis = 1;
103 }
Ted Kremenekb7770c02008-07-15 17:06:13 +0000104 next;
105 }
106
107 if (/^\s\s\s\s([^\s]+)\s(.+)$/) {
108 next if ($1 =~ /-dump/ or $1 =~ /-view/
109 or $1 =~ /-checker-simple/ or $1 =~ /-warn-uninit/);
110
111 $AvailableAnalyses{$1} = $2;
112 next;
Ted Kremenek938eef12009-02-17 23:31:05 +0000113 }
Ted Kremenekb7770c02008-07-15 17:06:13 +0000114 last;
115}
116
117close (PIPE);
118
119my %AnalysesDefaultEnabled = (
120 '-warn-dead-stores' => 1,
121 '-checker-cfref' => 1,
Ted Kremenek90125992008-07-15 23:41:32 +0000122 '-warn-objc-methodsigs' => 1,
Ted Kremenekd76c6a32009-02-25 21:08:30 +0000123 # Do not enable the missing -dealloc check by default.
124 # '-warn-objc-missing-dealloc' => 1,
Ted Kremenek5d443492008-09-18 06:34:16 +0000125 '-warn-objc-unused-ivars' => 1,
Ted Kremenekb7770c02008-07-15 17:06:13 +0000126);
127
128##----------------------------------------------------------------------------##
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000129# GetHTMLRunDir - Construct an HTML directory name for the current sub-run.
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000130##----------------------------------------------------------------------------##
131
Sam Bishopa0e22662008-04-02 03:35:43 +0000132sub GetHTMLRunDir {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000133
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000134 die "Not enough arguments." if (@_ == 0);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000135 my $Dir = shift @_;
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000136
137 my $TmpMode = 0;
138 if (!defined $Dir) {
Ted Kremenekffda0b42008-10-31 05:48:42 +0000139 if (`uname` =~ /Darwin/) {
140 $Dir = $ENV{'TMPDIR'};
141 if (!defined $Dir) { $Dir = "/tmp"; }
142 }
143 else {
144 $Dir = "/tmp";
145 }
146
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000147 $TmpMode = 1;
148 }
Ted Kremenekbf762c92009-02-24 02:38:02 +0000149
150 # Chop off any trailing '/' characters.
151 while ($Dir =~ /\/$/) { chop $Dir; }
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000152
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000153 # Get current date and time.
154
155 my @CurrentTime = localtime();
156
157 my $year = $CurrentTime[5] + 1900;
158 my $day = $CurrentTime[3];
159 my $month = $CurrentTime[4] + 1;
160
Ted Kremenek9d7405f2008-05-14 17:23:56 +0000161 my $DateString = sprintf("%d-%02d-%02d", $year, $month, $day);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000162
163 # Determine the run number.
164
165 my $RunNumber;
166
167 if (-d $Dir) {
168
169 if (! -r $Dir) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000170 DieDiag("directory '$Dir' exists but is not readable.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000171 }
172
173 # Iterate over all files in the specified directory.
174
175 my $max = 0;
176
177 opendir(DIR, $Dir);
Ted Kremenek29da6c52008-08-07 17:57:34 +0000178 my @FILES = grep { -d "$Dir/$_" } readdir(DIR);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000179 closedir(DIR);
180
181 foreach my $f (@FILES) {
182
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000183 # Strip the prefix '$Prog-' if we are dumping files to /tmp.
184 if ($TmpMode) {
185 next if (!($f =~ /^$Prog-(.+)/));
186 $f = $1;
187 }
188
Ted Kremenekebb74132008-09-21 06:58:09 +0000189
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000190 my @x = split/-/, $f;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000191 next if (scalar(@x) != 4);
192 next if ($x[0] != $year);
193 next if ($x[1] != $month);
194 next if ($x[2] != $day);
195
196 if ($x[3] > $max) {
197 $max = $x[3];
198 }
199 }
200
201 $RunNumber = $max + 1;
202 }
203 else {
204
205 if (-x $Dir) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000206 DieDiag("'$Dir' exists but is not a directory.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000207 }
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000208
209 if ($TmpMode) {
Ted Kremenek445fa772008-10-10 00:17:08 +0000210 DieDiag("The directory '/tmp' does not exist or cannot be accessed.\n");
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000211 }
212
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000213 # $Dir does not exist. It will be automatically created by the
214 # clang driver. Set the run number to 1.
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000215
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000216 $RunNumber = 1;
217 }
218
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000219 die "RunNumber must be defined!" if (!defined $RunNumber);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000220
221 # Append the run number.
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000222 my $NewDir;
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000223 if ($TmpMode) {
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000224 $NewDir = "$Dir/$Prog-$DateString-$RunNumber";
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000225 }
226 else {
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000227 $NewDir = "$Dir/$DateString-$RunNumber";
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000228 }
Ted Kremenekfc0898a2008-09-04 23:56:36 +0000229 system 'mkdir','-p',$NewDir;
230 return $NewDir;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000231}
232
Sam Bishopa0e22662008-04-02 03:35:43 +0000233sub SetHtmlEnv {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000234
235 die "Wrong number of arguments." if (scalar(@_) != 2);
236
237 my $Args = shift;
238 my $Dir = shift;
239
240 die "No build command." if (scalar(@$Args) == 0);
241
242 my $Cmd = $$Args[0];
243
244 if ($Cmd =~ /configure/) {
245 return;
246 }
247
248 if ($Verbose) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000249 Diag("Emitting reports for this run to '$Dir'.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000250 }
251
252 $ENV{'CCC_ANALYZER_HTML'} = $Dir;
253}
254
255##----------------------------------------------------------------------------##
Ted Kremenek57cf4462008-04-18 15:09:30 +0000256# ComputeDigest - Compute a digest of the specified file.
257##----------------------------------------------------------------------------##
258
259sub ComputeDigest {
260 my $FName = shift;
Ted Kremenek23cfca32008-06-16 22:40:14 +0000261 DieDiag("Cannot read $FName to compute Digest.\n") if (! -r $FName);
Ted Kremeneka6e24812008-04-19 18:05:48 +0000262
263 # Use Digest::MD5. We don't have to be cryptographically secure. We're
Ted Kremenek7ea02e62008-04-19 18:07:44 +0000264 # just looking for duplicate files that come from a non-malicious source.
265 # We use Digest::MD5 because it is a standard Perl module that should
Ted Kremenek63c20172008-08-04 17:34:06 +0000266 # come bundled on most systems.
Ted Kremenek23cfca32008-06-16 22:40:14 +0000267 open(FILE, $FName) or DieDiag("Cannot open $FName when computing Digest.\n");
Ted Kremeneka6e24812008-04-19 18:05:48 +0000268 binmode FILE;
269 my $Result = Digest::MD5->new->addfile(*FILE)->hexdigest;
270 close(FILE);
271
Ted Kremenek63c20172008-08-04 17:34:06 +0000272 # Return the digest.
Ted Kremeneka6e24812008-04-19 18:05:48 +0000273 return $Result;
Ted Kremenek57cf4462008-04-18 15:09:30 +0000274}
275
276##----------------------------------------------------------------------------##
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000277# UpdatePrefix - Compute the common prefix of files.
278##----------------------------------------------------------------------------##
279
280my $Prefix;
281
282sub UpdatePrefix {
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000283 my $x = shift;
284 my $y = basename($x);
285 $x =~ s/\Q$y\E$//;
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000286
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000287 if (!defined $Prefix) {
288 $Prefix = $x;
289 return;
290 }
291
Ted Kremenek20b2bae2008-09-11 21:15:10 +0000292 chop $Prefix while (!($x =~ /^\Q$Prefix/));
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000293}
294
295sub GetPrefix {
296 return $Prefix;
297}
298
299##----------------------------------------------------------------------------##
300# UpdateInFilePath - Update the path in the report file.
301##----------------------------------------------------------------------------##
302
303sub UpdateInFilePath {
304 my $fname = shift;
305 my $regex = shift;
306 my $newtext = shift;
Ted Kremenek63c20172008-08-04 17:34:06 +0000307
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000308 open (RIN, $fname) or die "cannot open $fname";
Ted Kremenek63c20172008-08-04 17:34:06 +0000309 open (ROUT, ">", "$fname.tmp") or die "cannot open $fname.tmp";
310
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000311 while (<RIN>) {
312 s/$regex/$newtext/;
313 print ROUT $_;
314 }
Ted Kremenek63c20172008-08-04 17:34:06 +0000315
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000316 close (ROUT);
317 close (RIN);
Ted Kremenek20161e92008-07-15 20:18:21 +0000318 system("mv", "$fname.tmp", $fname);
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000319}
320
321##----------------------------------------------------------------------------##
Ted Kremenek5744dc22008-04-02 18:03:36 +0000322# ScanFile - Scan a report file for various identifying attributes.
323##----------------------------------------------------------------------------##
324
Ted Kremenek57cf4462008-04-18 15:09:30 +0000325# Sometimes a source file is scanned more than once, and thus produces
326# multiple error reports. We use a cache to solve this problem.
327
328my %AlreadyScanned;
329
Ted Kremenek5744dc22008-04-02 18:03:36 +0000330sub ScanFile {
331
332 my $Index = shift;
333 my $Dir = shift;
334 my $FName = shift;
335
Ted Kremenek57cf4462008-04-18 15:09:30 +0000336 # Compute a digest for the report file. Determine if we have already
337 # scanned a file that looks just like it.
338
339 my $digest = ComputeDigest("$Dir/$FName");
340
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000341 if (defined $AlreadyScanned{$digest}) {
Ted Kremenek57cf4462008-04-18 15:09:30 +0000342 # Redundant file. Remove it.
Ted Kremenek20161e92008-07-15 20:18:21 +0000343 system ("rm", "-f", "$Dir/$FName");
Ted Kremenek57cf4462008-04-18 15:09:30 +0000344 return;
345 }
346
347 $AlreadyScanned{$digest} = 1;
348
Ted Kremenek809709f2008-04-18 16:58:34 +0000349 # At this point the report file is not world readable. Make it happen.
Ted Kremenek20161e92008-07-15 20:18:21 +0000350 system ("chmod", "644", "$Dir/$FName");
Ted Kremenek684bb092008-04-18 15:18:20 +0000351
352 # Scan the report file for tags.
Ted Kremenek23cfca32008-06-16 22:40:14 +0000353 open(IN, "$Dir/$FName") or DieDiag("Cannot open '$Dir/$FName'\n");
Ted Kremenek5744dc22008-04-02 18:03:36 +0000354
Ted Kremeneka26ddab2009-01-27 01:53:39 +0000355 my $BugType = "";
Ted Kremenek22d6a632008-04-02 20:43:36 +0000356 my $BugFile = "";
Ted Kremenekebb74132008-09-21 06:58:09 +0000357 my $BugCategory;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000358 my $BugPathLength = 1;
359 my $BugLine = 0;
Ted Kremenekebb74132008-09-21 06:58:09 +0000360 my $found = 0;
361
Ted Kremenek5744dc22008-04-02 18:03:36 +0000362 while (<IN>) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000363
364 last if ($found == 5);
365
Ted Kremeneka26ddab2009-01-27 01:53:39 +0000366 if (/<!-- BUGTYPE (.*) -->$/) {
367 $BugType = $1;
Ted Kremenekebb74132008-09-21 06:58:09 +0000368 ++$found;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000369 }
Ted Kremenek22d6a632008-04-02 20:43:36 +0000370 elsif (/<!-- BUGFILE (.*) -->$/) {
Ted Kremenek990c2f42008-12-03 19:19:23 +0000371 $BugFile = abs_path($1);
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000372 UpdatePrefix($BugFile);
Ted Kremenekebb74132008-09-21 06:58:09 +0000373 ++$found;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000374 }
375 elsif (/<!-- BUGPATHLENGTH (.*) -->$/) {
376 $BugPathLength = $1;
Ted Kremenekebb74132008-09-21 06:58:09 +0000377 ++$found;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000378 }
379 elsif (/<!-- BUGLINE (.*) -->$/) {
380 $BugLine = $1;
Ted Kremenekebb74132008-09-21 06:58:09 +0000381 ++$found;
382 }
383 elsif (/<!-- BUGCATEGORY (.*) -->$/) {
384 $BugCategory = $1;
385 ++$found;
Ted Kremenek22d6a632008-04-02 20:43:36 +0000386 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000387 }
388
389 close(IN);
Ted Kremenekebb74132008-09-21 06:58:09 +0000390
391 if (!defined $BugCategory) {
392 $BugCategory = "Other";
393 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000394
Ted Kremeneka26ddab2009-01-27 01:53:39 +0000395 push @$Index,[ $FName, $BugCategory, $BugType, $BugFile, $BugLine,
Ted Kremenek81983112008-09-28 04:13:09 +0000396 $BugPathLength ];
Ted Kremenek22d6a632008-04-02 20:43:36 +0000397}
398
399##----------------------------------------------------------------------------##
Ted Kremenek3ce12072008-09-22 17:50:47 +0000400# CopyFiles - Copy resource files to target directory.
Ted Kremenek22d6a632008-04-02 20:43:36 +0000401##----------------------------------------------------------------------------##
402
Ted Kremenek3ce12072008-09-22 17:50:47 +0000403sub CopyFiles {
Ted Kremenek22d6a632008-04-02 20:43:36 +0000404
405 my $Dir = shift;
Ted Kremeneke15fa272008-10-13 21:46:42 +0000406
407 my $JS = Cwd::realpath("$RealBin/sorttable.js");
Ted Kremenek22d6a632008-04-02 20:43:36 +0000408
Ted Kremenek23cfca32008-06-16 22:40:14 +0000409 DieDiag("Cannot find 'sorttable.js'.\n")
Ted Kremeneke15fa272008-10-13 21:46:42 +0000410 if (! -r $JS);
Ted Kremenek22d6a632008-04-02 20:43:36 +0000411
Ted Kremeneke15fa272008-10-13 21:46:42 +0000412 system ("cp", $JS, "$Dir");
Ted Kremenek22d6a632008-04-02 20:43:36 +0000413
Ted Kremenek23cfca32008-06-16 22:40:14 +0000414 DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
Ted Kremenek22d6a632008-04-02 20:43:36 +0000415 if (! -r "$Dir/sorttable.js");
Ted Kremenek3ce12072008-09-22 17:50:47 +0000416
Ted Kremeneke15fa272008-10-13 21:46:42 +0000417 my $CSS = Cwd::realpath("$RealBin/scanview.css");
418
Ted Kremenek3ce12072008-09-22 17:50:47 +0000419 DieDiag("Cannot find 'scanview.css'.\n")
Ted Kremeneke15fa272008-10-13 21:46:42 +0000420 if (! -r $CSS);
Ted Kremenek3ce12072008-09-22 17:50:47 +0000421
Ted Kremeneke15fa272008-10-13 21:46:42 +0000422 system ("cp", $CSS, "$Dir");
Ted Kremenek3ce12072008-09-22 17:50:47 +0000423
424 DieDiag("Could not copy 'scanview.css' to '$Dir'.\n")
Ted Kremeneke15fa272008-10-13 21:46:42 +0000425 if (! -r $CSS);
Ted Kremenek5744dc22008-04-02 18:03:36 +0000426}
427
428##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000429# Postprocess - Postprocess the results of an analysis scan.
430##----------------------------------------------------------------------------##
431
Sam Bishopa0e22662008-04-02 03:35:43 +0000432sub Postprocess {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000433
434 my $Dir = shift;
Ted Kremenek684bb092008-04-18 15:18:20 +0000435 my $BaseDir = shift;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000436
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000437 die "No directory specified." if (!defined $Dir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000438
439 if (! -d $Dir) {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000440 Diag("No bugs found.\n");
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000441 return 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000442 }
443
444 opendir(DIR, $Dir);
Ted Kremenek938eef12009-02-17 23:31:05 +0000445 my @files = grep { /^report-.*\.html$/ } readdir(DIR);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000446 closedir(DIR);
447
Ted Kremenek938eef12009-02-17 23:31:05 +0000448 if (scalar(@files) == 0 and ! -e "$Dir/failures") {
Ted Kremenek23cfca32008-06-16 22:40:14 +0000449 Diag("Removing directory '$Dir' because it contains no reports.\n");
Ted Kremenek20161e92008-07-15 20:18:21 +0000450 system ("rm", "-fR", $Dir);
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000451 return 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000452 }
Ted Kremenek5744dc22008-04-02 18:03:36 +0000453
Ted Kremenek991c54b2008-08-08 20:46:42 +0000454 # Scan each report file and build an index.
455 my @Index;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000456 foreach my $file (@files) { ScanFile(\@Index, $Dir, $file); }
457
Ted Kremenek938eef12009-02-17 23:31:05 +0000458 # Scan the failures directory and use the information in the .info files
Ted Kremenekd52e4252008-08-25 20:45:07 +0000459 # to update the common prefix directory.
Ted Kremenek938eef12009-02-17 23:31:05 +0000460 my @failures;
461 my @attributes_ignored;
462 if (-d "$Dir/failures") {
463 opendir(DIR, "$Dir/failures");
464 @failures = grep { /[.]info.txt$/ && !/attribute_ignored/; } readdir(DIR);
Ted Kremenekd52e4252008-08-25 20:45:07 +0000465 closedir(DIR);
Ted Kremenek938eef12009-02-17 23:31:05 +0000466 opendir(DIR, "$Dir/failures");
467 @attributes_ignored = grep { /^attribute_ignored/; } readdir(DIR);
468 closedir(DIR);
469 foreach my $file (@failures) {
470 open IN, "$Dir/failures/$file" or DieDiag("cannot open $file\n");
Ted Kremenekd52e4252008-08-25 20:45:07 +0000471 my $Path = <IN>;
472 if (defined $Path) { UpdatePrefix($Path); }
473 close IN;
474 }
475 }
476
Ted Kremenek63c20172008-08-04 17:34:06 +0000477 # Generate an index.html file.
478 my $FName = "$Dir/index.html";
479 open(OUT, ">", $FName) or DieDiag("Cannot create file '$FName'\n");
Ted Kremenek5744dc22008-04-02 18:03:36 +0000480
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000481 # Print out the header.
482
Ted Kremenek5744dc22008-04-02 18:03:36 +0000483print OUT <<ENDTEXT;
484<html>
485<head>
Ted Kremenek7cba1122008-09-22 01:35:58 +0000486<title>${HtmlTitle}</title>
Ted Kremenekf1435452008-09-23 22:34:51 +0000487<link type="text/css" rel="stylesheet" href="scanview.css"/>
Ted Kremenek22d6a632008-04-02 20:43:36 +0000488<script src="sorttable.js"></script>
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000489<script language='javascript' type="text/javascript">
490function SetDisplay(RowClass, DisplayVal)
491{
492 var Rows = document.getElementsByTagName("tr");
493 for ( var i = 0 ; i < Rows.length; ++i ) {
494 if (Rows[i].className == RowClass) {
495 Rows[i].style.display = DisplayVal;
496 }
497 }
498}
Ted Kremenekebb74132008-09-21 06:58:09 +0000499
Ted Kremenek2350a462008-10-28 19:56:52 +0000500function CopyCheckedStateToCheckButtons(SummaryCheckButton) {
501 var Inputs = document.getElementsByTagName("input");
502 for ( var i = 0 ; i < Inputs.length; ++i ) {
503 if (Inputs[i].type == "checkbox") {
504 if(Inputs[i] != SummaryCheckButton) {
505 Inputs[i].checked = SummaryCheckButton.checked;
506 Inputs[i].onclick();
507 }
508 }
509 }
510}
511
Ted Kremenek999e1202008-10-28 20:09:57 +0000512function returnObjById( id ) {
513 if (document.getElementById)
514 var returnVar = document.getElementById(id);
515 else if (document.all)
516 var returnVar = document.all[id];
517 else if (document.layers)
518 var returnVar = document.layers[id];
519 return returnVar;
520}
521
522var NumUnchecked = 0;
523
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000524function ToggleDisplay(CheckButton, ClassName) {
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000525 if (CheckButton.checked) {
526 SetDisplay(ClassName, "");
Ted Kremenek999e1202008-10-28 20:09:57 +0000527 if (--NumUnchecked == 0) {
528 returnObjById("AllBugsCheck").checked = true;
529 }
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000530 }
531 else {
532 SetDisplay(ClassName, "none");
Ted Kremenek999e1202008-10-28 20:09:57 +0000533 NumUnchecked++;
534 returnObjById("AllBugsCheck").checked = false;
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000535 }
536}
537</script>
Ted Kremenek1d1abb12008-09-22 17:52:58 +0000538<!-- SUMMARYENDHEAD -->
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000539</head>
540<body>
Ted Kremenek7cba1122008-09-22 01:35:58 +0000541<h1>${HtmlTitle}</h1>
542
543<table>
544<tr><th>User:</th><td>${UserName}\@${HostName}</td></tr>
545<tr><th>Working Directory:</th><td>${CurrentDir}</td></tr>
546<tr><th>Command Line:</th><td>${CmdArgs}</td></tr>
547<tr><th>Date:</th><td>${Date}</td></tr>
548ENDTEXT
549
550print OUT "<tr><th>Version:</th><td>${BuildName} (${BuildDate})</td></tr>\n"
551 if (defined($BuildName) && defined($BuildDate));
552
553print OUT <<ENDTEXT;
554</table>
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000555ENDTEXT
556
Ted Kremenek991c54b2008-08-08 20:46:42 +0000557 if (scalar(@files)) {
558 # Print out the summary table.
559 my %Totals;
Ted Kremenekebb74132008-09-21 06:58:09 +0000560
Ted Kremenek991c54b2008-08-08 20:46:42 +0000561 for my $row ( @Index ) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000562 my $bug_type = ($row->[2]);
563 my $bug_category = ($row->[1]);
564 my $key = "$bug_category:$bug_type";
565
566 if (!defined $Totals{$key}) { $Totals{$key} = [1,$bug_category,$bug_type]; }
567 else { $Totals{$key}->[0]++; }
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000568 }
Ted Kremenek991c54b2008-08-08 20:46:42 +0000569
Ted Kremenek7cba1122008-09-22 01:35:58 +0000570 print OUT "<h2>Bug Summary</h2>";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000571
572 if (defined $BuildName) {
573 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 +0000574 }
Ted Kremenekf4cdf412008-05-23 18:17:05 +0000575
Ted Kremenek2350a462008-10-28 19:56:52 +0000576 my $TotalBugs = scalar(@Index);
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000577print OUT <<ENDTEXT;
Ted Kremenekebb74132008-09-21 06:58:09 +0000578<table>
579<thead><tr><td>Bug Type</td><td>Quantity</td><td class="sorttable_nosort">Display?</td></tr></thead>
Ted Kremenek999e1202008-10-28 20:09:57 +0000580<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 +0000581ENDTEXT
582
Ted Kremenekebb74132008-09-21 06:58:09 +0000583 my $last_category;
584
585 for my $key (
586 sort {
587 my $x = $Totals{$a};
588 my $y = $Totals{$b};
589 my $res = $x->[1] cmp $y->[1];
590 $res = $x->[2] cmp $y->[2] if ($res == 0);
591 $res
592 } keys %Totals )
593 {
594 my $val = $Totals{$key};
595 my $category = $val->[1];
596 if (!defined $last_category or $last_category ne $category) {
597 $last_category = $category;
598 print OUT "<tr><th>$category</th><th colspan=2></th></tr>\n";
599 }
600 my $x = lc $key;
601 $x =~ s/[ ,'":\/()]+/_/g;
602 print OUT "<tr><td class=\"SUMM_DESC\">";
603 print OUT $val->[2];
Ted Kremenek2350a462008-10-28 19:56:52 +0000604 print OUT "</td><td class=\"Q\">";
Ted Kremenekebb74132008-09-21 06:58:09 +0000605 print OUT $val->[0];
606 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 +0000607 }
Ted Kremenek6e6eff72008-04-15 20:47:02 +0000608
609 # Print out the table of errors.
610
611print OUT <<ENDTEXT;
612</table>
Ted Kremenek7cba1122008-09-22 01:35:58 +0000613<h2>Reports</h2>
Ted Kremenekebb74132008-09-21 06:58:09 +0000614
615<table class="sortable" style="table-layout:automatic">
616<thead><tr>
617 <td>Bug Group</td>
618 <td class="sorttable_sorted">Bug Type<span id="sorttable_sortfwdind">&nbsp;&#x25BE;</span></td>
Ted Kremenekbba1cf52008-04-03 05:50:51 +0000619 <td>File</td>
Ted Kremenekebb74132008-09-21 06:58:09 +0000620 <td class="Q">Line</td>
Ted Kremenek81983112008-09-28 04:13:09 +0000621 <td class="Q">Path Length</td>
Ted Kremenek2645c772008-07-07 16:58:44 +0000622 <td class="sorttable_nosort"></td>
Ted Kremenekebb74132008-09-21 06:58:09 +0000623 <!-- REPORTBUGCOL -->
624</tr></thead>
625<tbody>
Ted Kremenek5744dc22008-04-02 18:03:36 +0000626ENDTEXT
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000627
Ted Kremenek991c54b2008-08-08 20:46:42 +0000628 my $prefix = GetPrefix();
629 my $regex;
630 my $InFileRegex;
631 my $InFilePrefix = "File:</td><td>";
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000632
Ted Kremenek991c54b2008-08-08 20:46:42 +0000633 if (defined $prefix) {
634 $regex = qr/^\Q$prefix\E/is;
635 $InFileRegex = qr/\Q$InFilePrefix$prefix\E/is;
636 }
Ted Kremenek7a4648d2008-05-02 22:04:53 +0000637
Ted Kremenekebb74132008-09-21 06:58:09 +0000638 for my $row ( sort { $a->[2] cmp $b->[2] } @Index ) {
639 my $x = "$row->[1]:$row->[2]";
640 $x = lc $x;
641 $x =~ s/[ ,'":\/()]+/_/g;
Ted Kremenek5744dc22008-04-02 18:03:36 +0000642
Ted Kremenek991c54b2008-08-08 20:46:42 +0000643 my $ReportFile = $row->[0];
Ted Kremenekebb74132008-09-21 06:58:09 +0000644
645 print OUT "<tr class=\"bt_$x\">";
646 print OUT "<td class=\"DESC\">";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000647 print OUT $row->[1];
Ted Kremenekebb74132008-09-21 06:58:09 +0000648 print OUT "</td>";
649 print OUT "<td class=\"DESC\">";
650 print OUT $row->[2];
651 print OUT "</td>";
652
653 # Update the file prefix.
654 my $fname = $row->[3];
Ted Kremenekebb74132008-09-21 06:58:09 +0000655
Ted Kremenek991c54b2008-08-08 20:46:42 +0000656 if (defined $regex) {
657 $fname =~ s/$regex//;
658 UpdateInFilePath("$Dir/$ReportFile", $InFileRegex, $InFilePrefix)
659 }
Ted Kremenekebb74132008-09-21 06:58:09 +0000660
Ted Kremenek91639ef2008-09-22 17:42:31 +0000661 print OUT "<td>";
Ted Kremenekebb74132008-09-21 06:58:09 +0000662 my @fname = split /\//,$fname;
663 if ($#fname > 0) {
664 while ($#fname >= 0) {
665 my $x = shift @fname;
666 print OUT $x;
667 if ($#fname >= 0) {
668 print OUT "<span class=\"W\"> </span>/";
669 }
670 }
671 }
672 else {
673 print OUT $fname;
Ted Kremenek91639ef2008-09-22 17:42:31 +0000674 }
Ted Kremenekebb74132008-09-21 06:58:09 +0000675 print OUT "</td>";
676
677 # Print out the quantities.
Ted Kremenek81983112008-09-28 04:13:09 +0000678 for my $j ( 4 .. 5 ) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000679 print OUT "<td class=\"Q\">$row->[$j]</td>";
680 }
681
Ted Kremenek991c54b2008-08-08 20:46:42 +0000682 # Print the rest of the columns.
Ted Kremenek81983112008-09-28 04:13:09 +0000683 for (my $j = 6; $j <= $#{$row}; ++$j) {
Ted Kremenekebb74132008-09-21 06:58:09 +0000684 print OUT "<td>$row->[$j]</td>"
Ted Kremenek991c54b2008-08-08 20:46:42 +0000685 }
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000686
Ted Kremenek991c54b2008-08-08 20:46:42 +0000687 # Emit the "View" link.
Ted Kremenek68005dd2008-09-22 17:39:18 +0000688 print OUT "<td><a href=\"$ReportFile#EndPath\">View Report</a></td>";
Ted Kremenek3cea9ee2008-07-30 17:58:08 +0000689
Daniel Dunbare43038e2008-09-19 23:18:44 +0000690 # Emit REPORTBUG markers.
Ted Kremenekebb74132008-09-21 06:58:09 +0000691 print OUT "\n<!-- REPORTBUG id=\"$ReportFile\" -->\n";
Daniel Dunbare43038e2008-09-19 23:18:44 +0000692
Ted Kremenek991c54b2008-08-08 20:46:42 +0000693 # End the row.
694 print OUT "</tr>\n";
695 }
696
Ted Kremenekebb74132008-09-21 06:58:09 +0000697 print OUT "</tbody>\n</table>\n\n";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000698 }
699
Ted Kremenek938eef12009-02-17 23:31:05 +0000700 if (scalar (@failures) || scalar(@attributes_ignored)) {
701 print OUT "<h2>Analyzer Failures</h2>\n";
702
703 if (scalar @attributes_ignored) {
704 print OUT "The analyzer's parser ignored the following attributes:<p>\n";
705 print OUT "<table>\n";
706 print OUT "<thead><tr><td>Attribute</td><td>Source File</td><td>Preprocessed File</td><td>STDERR Output</td></tr></thead>\n";
707 foreach my $file (sort @attributes_ignored) {
708 die "cannot demangle attribute name\n" if (! ($file =~ /^attribute_ignored_(.+).txt/));
709 my $attribute = $1;
710 # Open the attribute file to get the first file that failed.
711 next if (!open (ATTR, "$Dir/failures/$file"));
712 my $ppfile = <ATTR>;
713 chomp $ppfile;
714 close ATTR;
715 next if (! -e "$Dir/failures/$ppfile");
716 # Open the info file and get the name of the source file.
717 open (INFO, "$Dir/failures/$ppfile.info.txt") or
718 die "Cannot open $Dir/failures/$ppfile.info.txt\n";
719 my $srcfile = <INFO>;
720 chomp $srcfile;
721 close (INFO);
722 # Print the information in the table.
723 my $prefix = GetPrefix();
724 if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; }
725 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";
726 my $ppfile_clang = $ppfile;
727 $ppfile_clang =~ s/[.](.+)$/.clang.$1/;
728 print OUT " <!-- REPORTPROBLEM src=\"$srcfile\" file=\"failures/$ppfile\" clangfile=\"failures/$ppfile_clang\" stderr=\"failures/$ppfile.stderr.txt\" info=\"failures/$ppfile.info.txt\" -->\n";
729 }
730 print OUT "</table>\n";
731 }
732
733 if (scalar @failures) {
734 print OUT "<p>The analyzer had problems processing the following files:</p>\n";
735 print OUT "<table>\n";
736 print OUT "<thead><tr><td>Problem</td><td>Source File</td><td>Preprocessed File</td><td>STDERR Output</td></tr></thead>\n";
737 foreach my $file (sort @failures) {
Ted Kremenek82a12532008-09-25 00:25:16 +0000738 $file =~ /(.+).info.txt$/;
Ted Kremenek991c54b2008-08-08 20:46:42 +0000739 # Get the preprocessed file.
740 my $ppfile = $1;
741 # Open the info file and get the name of the source file.
Ted Kremenek938eef12009-02-17 23:31:05 +0000742 open (INFO, "$Dir/failures/$file") or
743 die "Cannot open $Dir/failures/$file\n";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000744 my $srcfile = <INFO>;
Ted Kremenek5d31f832008-08-18 18:38:29 +0000745 chomp $srcfile;
746 my $problem = <INFO>;
747 chomp $problem;
Ted Kremenek991c54b2008-08-08 20:46:42 +0000748 close (INFO);
749 # Print the information in the table.
Ted Kremenekd52e4252008-08-25 20:45:07 +0000750 my $prefix = GetPrefix();
Ted Kremenek9f9b1fd2008-09-12 22:49:36 +0000751 if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; }
Ted Kremenek938eef12009-02-17 23:31:05 +0000752 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 +0000753 my $ppfile_clang = $ppfile;
754 $ppfile_clang =~ s/[.](.+)$/.clang.$1/;
Ted Kremenek938eef12009-02-17 23:31:05 +0000755 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 +0000756 }
Ted Kremenek938eef12009-02-17 23:31:05 +0000757 print OUT "</table>\n";
758 }
759 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 +0000760 }
761
Ted Kremenek991c54b2008-08-08 20:46:42 +0000762 print OUT "</body></html>\n";
Ted Kremenek5744dc22008-04-02 18:03:36 +0000763 close(OUT);
Ted Kremenek3ce12072008-09-22 17:50:47 +0000764 CopyFiles($Dir);
Ted Kremenek20161e92008-07-15 20:18:21 +0000765
766 # Make sure $Dir and $BaseDir are world readable/executable.
767 system("chmod", "755", $Dir);
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000768 if (defined $BaseDir) { system("chmod", "755", $BaseDir); }
Ted Kremenek20161e92008-07-15 20:18:21 +0000769
Ted Kremenek23cfca32008-06-16 22:40:14 +0000770 my $Num = scalar(@Index);
Ted Kremenek150c2122008-07-11 19:15:05 +0000771 Diag("$Num bugs found.\n");
772 if ($Num > 0 && -r "$Dir/index.html") {
Ted Kremenek5950b3f2008-09-22 06:47:01 +0000773 Diag("Run 'scan-view $Dir' to examine bug reports.\n");
Ted Kremenek150c2122008-07-11 19:15:05 +0000774 }
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000775
Ted Kremenek938eef12009-02-17 23:31:05 +0000776 DiagCrashes($Dir) if (scalar @failures || scalar @attributes_ignored);
Ted Kremenek991c54b2008-08-08 20:46:42 +0000777
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000778 return $Num;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000779}
780
781##----------------------------------------------------------------------------##
Ted Kremenekdab11102008-04-02 04:43:42 +0000782# RunBuildCommand - Run the build command.
783##----------------------------------------------------------------------------##
784
Ted Kremenek6b628982008-04-30 23:47:12 +0000785sub AddIfNotPresent {
786 my $Args = shift;
787 my $Arg = shift;
788 my $found = 0;
789
790 foreach my $k (@$Args) {
791 if ($k eq $Arg) {
792 $found = 1;
793 last;
794 }
795 }
796
797 if ($found == 0) {
798 push @$Args, $Arg;
799 }
800}
801
Ted Kremenekdab11102008-04-02 04:43:42 +0000802sub RunBuildCommand {
803
804 my $Args = shift;
Ted Kremenek7442ca62008-04-02 16:04:51 +0000805 my $IgnoreErrors = shift;
Ted Kremenekdab11102008-04-02 04:43:42 +0000806 my $Cmd = $Args->[0];
Ted Kremenek6195c372008-06-02 21:52:47 +0000807 my $CCAnalyzer = shift;
Ted Kremenekdab11102008-04-02 04:43:42 +0000808
Ted Kremenek3301cb12008-06-30 18:18:16 +0000809 # Get only the part of the command after the last '/'.
810 if ($Cmd =~ /\/([^\/]+)$/) {
811 $Cmd = $1;
812 }
813
Ted Kremenek92548fe2008-11-19 01:46:21 +0000814 if ($Cmd =~ /(.*\/?gcc[^\/]*$)/ or
815 $Cmd =~ /(.*\/?cc[^\/]*$)/ or
816 $Cmd =~ /(.*\/?llvm-gcc[^\/]*$)/ or
817 $Cmd =~ /(.*\/?ccc-analyzer[^\/]*$)/) {
818
819 if (!($Cmd =~ /ccc-analyzer/) and !defined $ENV{"CCC_CC"}) {
820 $ENV{"CCC_CC"} = $1;
821 }
822
Ted Kremenekdab11102008-04-02 04:43:42 +0000823 shift @$Args;
Ted Kremenek6195c372008-06-02 21:52:47 +0000824 unshift @$Args, $CCAnalyzer;
Ted Kremenekdab11102008-04-02 04:43:42 +0000825 }
Ted Kremenek7442ca62008-04-02 16:04:51 +0000826 elsif ($IgnoreErrors) {
827 if ($Cmd eq "make" or $Cmd eq "gmake") {
Ted Kremenek6b628982008-04-30 23:47:12 +0000828 AddIfNotPresent($Args,"-k");
Ted Kremenek8912b542008-05-13 21:28:02 +0000829 AddIfNotPresent($Args,"-i");
Ted Kremenek7442ca62008-04-02 16:04:51 +0000830 }
831 elsif ($Cmd eq "xcodebuild") {
Ted Kremenek6b628982008-04-30 23:47:12 +0000832 AddIfNotPresent($Args,"-PBXBuildsContinueAfterErrors=YES");
Ted Kremenek7442ca62008-04-02 16:04:51 +0000833 }
Ted Kremenek6b628982008-04-30 23:47:12 +0000834 }
835
Ted Kremenek6b628982008-04-30 23:47:12 +0000836 if ($Cmd eq "xcodebuild") {
Ted Kremenekcfd4c7b2008-05-23 22:18:16 +0000837 # Disable distributed builds for xcodebuild.
Ted Kremenek6b628982008-04-30 23:47:12 +0000838 AddIfNotPresent($Args,"-nodistribute");
Ted Kremenekcfd4c7b2008-05-23 22:18:16 +0000839
840 # Disable PCH files until clang supports them.
841 AddIfNotPresent($Args,"GCC_PRECOMPILE_PREFIX_HEADER=NO");
Ted Kremenek915e9722008-05-27 23:18:07 +0000842
843 # When 'CC' is set, xcodebuild uses it to do all linking, even if we are
844 # linking C++ object files. Set 'LDPLUSPLUS' so that xcodebuild uses 'g++'
845 # when linking such files.
Ted Kremenek95aa1052008-09-04 17:52:41 +0000846 die if (!defined $CXX);
847 my $LDPLUSPLUS = `which $CXX`;
Ted Kremenek915e9722008-05-27 23:18:07 +0000848 $LDPLUSPLUS =~ s/\015?\012//; # strip newlines
849 $ENV{'LDPLUSPLUS'} = $LDPLUSPLUS;
Ted Kremenek6b628982008-04-30 23:47:12 +0000850 }
Ted Kremenekdab11102008-04-02 04:43:42 +0000851
Ted Kremenek5a4ddaf2008-08-25 20:10:45 +0000852 return (system(@$Args) >> 8);
Ted Kremenekdab11102008-04-02 04:43:42 +0000853}
854
Ted Kremenekdab11102008-04-02 04:43:42 +0000855##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000856# DisplayHelp - Utility function to display all help options.
857##----------------------------------------------------------------------------##
858
Sam Bishopa0e22662008-04-02 03:35:43 +0000859sub DisplayHelp {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000860
Ted Kremenek5744dc22008-04-02 18:03:36 +0000861print <<ENDTEXT;
Sam Bishopa0e22662008-04-02 03:35:43 +0000862USAGE: $Prog [options] <build command> [build options]
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000863
Ted Kremenekf4cdf412008-05-23 18:17:05 +0000864ENDTEXT
865
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000866 if (defined $BuildName) {
Ted Kremenekf4cdf412008-05-23 18:17:05 +0000867 print "ANALYZER BUILD: $BuildName ($BuildDate)\n\n";
868 }
869
870print <<ENDTEXT;
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000871OPTIONS:
872
Ted Kremeneke15fa272008-10-13 21:46:42 +0000873 -analyze-headers - Also analyze functions in #included files.
874
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000875 -o - Target directory for HTML report files. Subdirectories
Sam Bishopa0e22662008-04-02 03:35:43 +0000876 will be created as needed to represent separate "runs" of
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000877 the analyzer. If this option is not specified, a directory
Ted Kremenekffda0b42008-10-31 05:48:42 +0000878 is created in /tmp (TMPDIR on Mac OS X) to store the reports.
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000879
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000880 -h - Display this message.
881 --help
Ted Kremenek1262fc42008-05-14 20:10:33 +0000882
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000883 -k - Add a "keep on going" option to the specified build command.
884 --keep-going This option currently supports make and xcodebuild.
Ted Kremenekf02e8db2008-04-02 16:41:25 +0000885 This is a convenience option; one can specify this
886 behavior directly using build options.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000887
Ted Kremenek7cba1122008-09-22 01:35:58 +0000888 --html-title [title] - Specify the title used on generated HTML pages.
889 --html-title=[title] If not specified, a default title will be used.
890
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000891 -plist - By default the output of scan-build is a set of HTML files.
892 This option outputs the results as a set of .plist files.
893
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000894 --status-bugs - By default, the exit status of $Prog is the same as the
895 executed build command. Specifying this option causes the
896 exit status of $Prog to be 1 if it found potential bugs
897 and 0 otherwise.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000898
Ted Kremenek386c6932008-09-03 17:59:35 +0000899 --use-cc [compiler path] - By default, $Prog uses 'gcc' to compile and link
900 --use-cc=[compiler path] your C and Objective-C code. Use this option
901 to specify an alternate compiler.
902
903 --use-c++ [compiler path] - By default, $Prog uses 'g++' to compile and link
904 --use-c++=[compiler path] your C++ and Objective-C++ code. Use this option
905 to specify an alternate compiler.
Ted Kremenekf17ef3c2008-08-21 21:47:09 +0000906
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000907 -v - Verbose output from $Prog and the analyzer.
Ted Kremenek386c6932008-09-03 17:59:35 +0000908 A second and third '-v' increases verbosity.
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000909
910 -V - View analysis results in a web browser when the build
911 --view completes.
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000912
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000913ADVANCED OPTIONS:
914
Ted Kremenek9f4ecb32009-02-20 21:49:22 +0000915 -constraints [model] - Specify the contraint engine used by the analyzer.
916 By default the 'range' model is used. Specifying
917 'basic' uses a simpler, less powerful constraint model
Ted Kremenekd4c76842009-02-21 04:46:41 +0000918 used by checker-0.160 and earlier.
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000919
920 -store [model] - Specify the store model used by the analyzer. By default,
921 the 'basic' store model is used. 'region' specifies a field-
922 sensitive store model. Be warned that the 'region' model
923 is still in very early testing phase and may often crash.
Ted Kremenekb7770c02008-07-15 17:06:13 +0000924
Ted Kremenek386c6932008-09-03 17:59:35 +0000925AVAILABLE ANALYSES (multiple analyses may be specified):
Ted Kremenekd52e4252008-08-25 20:45:07 +0000926
927ENDTEXT
Ted Kremenekb7770c02008-07-15 17:06:13 +0000928
929 foreach my $Analysis (sort keys %AvailableAnalyses) {
Ted Kremenekfc1d3402008-08-04 18:15:26 +0000930 if (defined $AnalysesDefaultEnabled{$Analysis}) {
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000931 print " (+)";
Ted Kremenekb7770c02008-07-15 17:06:13 +0000932 }
933 else {
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000934 print " ";
Ted Kremenekb7770c02008-07-15 17:06:13 +0000935 }
936
937 print " $Analysis $AvailableAnalyses{$Analysis}\n";
938 }
939
940print <<ENDTEXT
941
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000942 NOTE: "(+)" indicates that an analysis is enabled by default unless one
943 or more analysis options are specified
Ted Kremenekb7770c02008-07-15 17:06:13 +0000944
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000945BUILD OPTIONS
946
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000947 You can specify any build option acceptable to the build command.
Ted Kremenek39eefde2008-04-02 16:47:27 +0000948
Ted Kremenek5744dc22008-04-02 18:03:36 +0000949EXAMPLE
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000950
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000951 $Prog -o /tmp/myhtmldir make -j4
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000952
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000953 The above example causes analysis reports to be deposited into
954 a subdirectory of "/tmp/myhtmldir" and to run "make" with the "-j4" option.
955 A different subdirectory is created each time $Prog analyzes a project.
956 The analyzer should support most parallel builds, but not distributed builds.
Ted Kremenek2b74ab62008-04-01 21:22:03 +0000957
958ENDTEXT
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000959}
960
961##----------------------------------------------------------------------------##
Ted Kremenek7cba1122008-09-22 01:35:58 +0000962# HtmlEscape - HTML entity encode characters that are special in HTML
963##----------------------------------------------------------------------------##
964
965sub HtmlEscape {
966 # copy argument to new variable so we don't clobber the original
967 my $arg = shift || '';
968 my $tmp = $arg;
Ted Kremenek87f8de72008-11-03 07:44:16 +0000969 $tmp =~ s/&/&amp;/g;
970 $tmp =~ s/</&lt;/g;
971 $tmp =~ s/>/&gt;/g;
Ted Kremenek7cba1122008-09-22 01:35:58 +0000972 return $tmp;
973}
974
975##----------------------------------------------------------------------------##
976# ShellEscape - backslash escape characters that are special to the shell
977##----------------------------------------------------------------------------##
978
979sub ShellEscape {
980 # copy argument to new variable so we don't clobber the original
981 my $arg = shift || '';
Ted Kremenek87f8de72008-11-03 07:44:16 +0000982 if ($arg =~ /["\s]/) { return "'" . $arg . "'"; }
983 return $arg;
Ted Kremenek7cba1122008-09-22 01:35:58 +0000984}
985
986##----------------------------------------------------------------------------##
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000987# Process command-line arguments.
988##----------------------------------------------------------------------------##
989
Ted Kremeneke15fa272008-10-13 21:46:42 +0000990my $AnalyzeHeaders = 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000991my $HtmlDir; # Parent directory to store HTML files.
992my $IgnoreErrors = 0; # Ignore build errors.
Ted Kremenek7f8a3252008-04-02 18:42:49 +0000993my $ViewResults = 0; # View results when the build terminates.
Ted Kremenek363dc3f2008-07-15 22:03:09 +0000994my $ExitStatusFoundBugs = 0; # Exit status reflects whether bugs were found
Ted Kremenekb7770c02008-07-15 17:06:13 +0000995my @AnalysesToRun;
Zhongxing Xu07c37672008-10-27 14:26:32 +0000996my $StoreModel;
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000997my $ConstraintsModel;
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000998my $OutputFormat;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +0000999
1000if (!@ARGV) {
1001 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +00001002 exit 1;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001003}
1004
1005while (@ARGV) {
1006
1007 # Scan for options we recognize.
1008
1009 my $arg = $ARGV[0];
1010
Sam Bishop2f2418e2008-04-03 14:29:47 +00001011 if ($arg eq "-h" or $arg eq "--help") {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001012 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +00001013 exit 0;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001014 }
1015
Ted Kremeneke15fa272008-10-13 21:46:42 +00001016 if ($arg eq '-analyze-headers') {
1017 shift @ARGV;
1018 $AnalyzeHeaders = 1;
1019 next;
1020 }
1021
Ted Kremenekfc1d3402008-08-04 18:15:26 +00001022 if (defined $AvailableAnalyses{$arg}) {
Ted Kremenek1262fc42008-05-14 20:10:33 +00001023 shift @ARGV;
Ted Kremenekb7770c02008-07-15 17:06:13 +00001024 push @AnalysesToRun, $arg;
Ted Kremenek1262fc42008-05-14 20:10:33 +00001025 next;
1026 }
1027
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001028 if ($arg eq "-o") {
1029 shift @ARGV;
1030
1031 if (!@ARGV) {
Ted Kremenek23cfca32008-06-16 22:40:14 +00001032 DieDiag("'-o' option requires a target directory name.\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001033 }
1034
1035 $HtmlDir = shift @ARGV;
1036 next;
1037 }
Ted Kremenek7cba1122008-09-22 01:35:58 +00001038
1039 if ($arg =~ /^--html-title(=(.+))?$/) {
1040 shift @ARGV;
1041
1042 if ($2 eq '') {
1043 if (!@ARGV) {
1044 DieDiag("'--html-title' option requires a string.\n");
1045 }
1046
1047 $HtmlTitle = shift @ARGV;
1048 } else {
1049 $HtmlTitle = $2;
1050 }
1051
1052 next;
1053 }
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001054
Ted Kremenek2b74ab62008-04-01 21:22:03 +00001055 if ($arg eq "-k" or $arg eq "--keep-going") {
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001056 shift @ARGV;
1057 $IgnoreErrors = 1;
1058 next;
1059 }
1060
Ted Kremenekf17ef3c2008-08-21 21:47:09 +00001061 if ($arg =~ /^--use-cc(=(.+))?$/) {
1062 shift @ARGV;
1063 my $cc;
1064
1065 if ($2 eq "") {
1066 if (!@ARGV) {
1067 DieDiag("'--use-cc' option requires a compiler executable name.\n");
1068 }
1069 $cc = shift @ARGV;
1070 }
1071 else {
1072 $cc = $2;
1073 }
1074
1075 $ENV{"CCC_CC"} = $cc;
1076 next;
1077 }
1078
Ted Kremenek7cba1122008-09-22 01:35:58 +00001079 if ($arg =~ /^--use-c\+\+(=(.+))?$/) {
Ted Kremenek386c6932008-09-03 17:59:35 +00001080 shift @ARGV;
1081
1082 if ($2 eq "") {
1083 if (!@ARGV) {
1084 DieDiag("'--use-c++' option requires a compiler executable name.\n");
1085 }
1086 $CXX = shift @ARGV;
1087 }
1088 else {
1089 $CXX = $2;
1090 }
1091 next;
1092 }
1093
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001094 if ($arg eq "-v") {
1095 shift @ARGV;
1096 $Verbose++;
1097 next;
1098 }
1099
Ted Kremenek7f8a3252008-04-02 18:42:49 +00001100 if ($arg eq "-V" or $arg eq "--view") {
1101 shift @ARGV;
1102 $ViewResults = 1;
1103 next;
1104 }
1105
Ted Kremenek363dc3f2008-07-15 22:03:09 +00001106 if ($arg eq "--status-bugs") {
1107 shift @ARGV;
1108 $ExitStatusFoundBugs = 1;
1109 next;
1110 }
Zhongxing Xu07c37672008-10-27 14:26:32 +00001111
1112 if ($arg eq "-store") {
1113 shift @ARGV;
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +00001114 $StoreModel = shift @ARGV;
1115 next;
1116 }
1117
1118 if ($arg eq "-constraints") {
1119 shift @ARGV;
1120 $ConstraintsModel = shift @ARGV;
Zhongxing Xu07c37672008-10-27 14:26:32 +00001121 next;
1122 }
Ted Kremenek363dc3f2008-07-15 22:03:09 +00001123
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001124 if ($arg eq "-plist") {
1125 shift @ARGV;
1126 $OutputFormat = "plist";
1127 next;
1128 }
1129
Ted Kremenek23cfca32008-06-16 22:40:14 +00001130 DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/);
Ted Kremenek0062ad42008-04-02 16:35:01 +00001131
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001132 last;
1133}
1134
1135if (!@ARGV) {
Ted Kremenek23cfca32008-06-16 22:40:14 +00001136 Diag("No build command specified.\n\n");
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001137 DisplayHelp();
Sam Bishopa0e22662008-04-02 03:35:43 +00001138 exit 1;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001139}
1140
Ted Kremenek7cba1122008-09-22 01:35:58 +00001141$CmdArgs = HtmlEscape(join(' ', map(ShellEscape($_), @ARGV)));
1142$HtmlTitle = "${CurrentDirSuffix} - scan-build results"
1143 unless (defined($HtmlTitle));
Ted Kremenek386c6932008-09-03 17:59:35 +00001144
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001145# Determine the output directory for the HTML reports.
Ted Kremenek684bb092008-04-18 15:18:20 +00001146my $BaseDir = $HtmlDir;
Sam Bishopa0e22662008-04-02 03:35:43 +00001147$HtmlDir = GetHTMLRunDir($HtmlDir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001148
1149# Set the appropriate environment variables.
Sam Bishopa0e22662008-04-02 03:35:43 +00001150SetHtmlEnv(\@ARGV, $HtmlDir);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001151
Ted Kremeneke15fa272008-10-13 21:46:42 +00001152my $Cmd = Cwd::realpath("$RealBin/ccc-analyzer");
Ted Kremenek0b6c1532008-04-08 20:22:12 +00001153
Ted Kremenek23cfca32008-06-16 22:40:14 +00001154DieDiag("Executable 'ccc-analyzer' does not exist at '$Cmd'\n")
Ted Kremenek0b6c1532008-04-08 20:22:12 +00001155 if (! -x $Cmd);
Ted Kremenekf22eacb2008-04-18 22:00:56 +00001156
Ted Kremenek2d62ab12009-02-23 23:01:06 +00001157if (!defined $ClangSB || ! -x $ClangSB) {
1158 Diag("'clang' executable not found in '$RealBin/bin'.\n");
Ted Kremenekb7770c02008-07-15 17:06:13 +00001159 Diag("Using 'clang' from path.\n");
Ted Kremenekf22eacb2008-04-18 22:00:56 +00001160}
Ted Kremenek0b6c1532008-04-08 20:22:12 +00001161
Ted Kremenek95aa1052008-09-04 17:52:41 +00001162if (defined $CXX) {
1163 $ENV{'CXX'} = $CXX;
1164}
1165else {
1166 $CXX = 'g++'; # This variable is used by other parts of scan-build
1167 # that need to know a default C++ compiler to fall back to.
1168}
1169
Ted Kremenek4f4b17d2008-04-03 20:08:18 +00001170$ENV{'CC'} = $Cmd;
Ted Kremenekf22eacb2008-04-18 22:00:56 +00001171$ENV{'CLANG'} = $Clang;
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001172
1173if ($Verbose >= 2) {
1174 $ENV{'CCC_ANALYZER_VERBOSE'} = 1;
1175}
1176
Ted Kremeneka9525c92008-05-12 22:07:14 +00001177if ($Verbose >= 3) {
1178 $ENV{'CCC_ANALYZER_LOG'} = 1;
1179}
1180
Ted Kremenek90125992008-07-15 23:41:32 +00001181if (scalar(@AnalysesToRun) == 0) {
1182 foreach my $key (keys %AnalysesDefaultEnabled) {
1183 push @AnalysesToRun,$key;
1184 }
Ted Kremenek01006782008-07-02 23:16:10 +00001185}
Ted Kremenek1262fc42008-05-14 20:10:33 +00001186
Ted Kremeneke15fa272008-10-13 21:46:42 +00001187if ($AnalyzeHeaders) {
1188 push @AnalysesToRun,"-analyzer-opt-analyze-headers";
1189}
1190
Ted Kremenek90125992008-07-15 23:41:32 +00001191$ENV{'CCC_ANALYZER_ANALYSIS'} = join ' ',@AnalysesToRun;
1192
Zhongxing Xu3cab2b12008-11-02 10:58:16 +00001193if (defined $StoreModel) {
Zhongxing Xu07c37672008-10-27 14:26:32 +00001194 $ENV{'CCC_ANALYZER_STORE_MODEL'} = $StoreModel;
1195}
1196
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +00001197if (defined $ConstraintsModel) {
1198 $ENV{'CCC_ANALYZER_CONSTRAINTS_MODEL'} = $ConstraintsModel;
1199}
1200
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001201if (defined $OutputFormat) {
1202 $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'} = $OutputFormat;
1203}
1204
1205
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001206# Run the build.
Ted Kremenek5656a982008-07-15 17:09:28 +00001207my $ExitStatus = RunBuildCommand(\@ARGV, $IgnoreErrors, $Cmd);
Ted Kremenek9cc8c2c2008-04-01 20:47:38 +00001208
Ted Kremenek655aba72008-11-04 00:22:12 +00001209if (defined $OutputFormat and $OutputFormat eq "plist") {
Ted Kremenek50534dc2008-09-22 17:38:23 +00001210 Diag "Analysis run complete.\n";
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001211 Diag "Analysis results (plist files) deposited in '$HtmlDir'\n";
Ted Kremenek7f8a3252008-04-02 18:42:49 +00001212}
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001213else {
1214 # Postprocess the HTML directory.
1215 my $NumBugs = Postprocess($HtmlDir, $BaseDir);
Ted Kremenek5656a982008-07-15 17:09:28 +00001216
Ted Kremenekdb4f5f22008-11-04 00:02:53 +00001217 if ($ViewResults and -r "$HtmlDir/index.html") {
1218 Diag "Analysis run complete.\n";
1219 Diag "Viewing analysis results in '$HtmlDir' using scan-view.\n";
1220 my $ScanView = Cwd::realpath("$RealBin/scan-view");
1221 if (! -x $ScanView) { $ScanView = "scan-view"; }
1222 exec $ScanView, "$HtmlDir";
1223 }
1224
1225 if ($ExitStatusFoundBugs) {
1226 exit 1 if ($NumBugs > 0);
1227 exit 0;
1228 }
Ted Kremenek363dc3f2008-07-15 22:03:09 +00001229}
1230
Ted Kremenek5656a982008-07-15 17:09:28 +00001231exit $ExitStatus;
1232