blob: 1fa0779fec7f52c99127512683aeec2951dfeb0d [file] [log] [blame]
Ted Kremenekfbeeca82008-07-19 06:11:04 +00001#!/usr/bin/env perl
Ted Kremenekb0982882008-03-25 22:35:32 +00002#
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#
Ted Kremenekfbeeca82008-07-19 06:11:04 +000010# A script designed to interpose between the build system and gcc. It invokes
11# both gcc and the static analyzer.
Ted Kremenekb0982882008-03-25 22:35:32 +000012#
13##===----------------------------------------------------------------------===##
14
Ted Kremenekfbeeca82008-07-19 06:11:04 +000015use strict;
16use warnings;
Ted Kremenekb315a392008-09-21 19:56:14 +000017use Cwd qw/ getcwd abs_path /;
Ted Kremenek991c54b2008-08-08 20:46:42 +000018use File::Temp qw/ tempfile /;
19use File::Path qw / mkpath /;
Ted Kremenekddf32da2009-01-21 00:42:24 +000020use File::Basename;
Ted Kremenek2ec5cd52008-08-25 20:44:31 +000021
22my $CC = $ENV{'CCC_CC'};
23if (!defined $CC) { $CC = "gcc"; }
Ted Kremenekddf32da2009-01-21 00:42:24 +000024my $CleanupFile;
25my $ResultFile;
26
27# Remove any stale files at exit.
28END {
29 if (defined $CleanupFile && -z $CleanupFile) {
30 `rm -f $CleanupFile`;
31 }
32}
33
Ted Kremenek991c54b2008-08-08 20:46:42 +000034##----------------------------------------------------------------------------##
35# Process Clang Crashes.
36##----------------------------------------------------------------------------##
37
38sub GetPPExt {
39 my $Lang = shift;
40 if ($Lang =~ /objective-c/) { return ".mi"; }
41 return ".i";
42}
43
Ted Kremenek5daa3be2009-01-27 01:19:08 +000044my $ParserRejects = "Parser Rejects";
45
Ted Kremenek5d31f832008-08-18 18:38:29 +000046sub ProcessClangFailure {
Ted Kremenekc3998fa2008-09-25 00:51:44 +000047 my ($Clang, $Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_;
Ted Kremenek991c54b2008-08-08 20:46:42 +000048 my $Dir = "$HtmlDir/crashes";
49 mkpath $Dir;
Ted Kremenek5daa3be2009-01-27 01:19:08 +000050
51 my $prefix = "clang_crash";
Ted Kremenek5f0e9322009-01-27 05:34:28 +000052 if ($ErrorType eq $ParserRejects) { $prefix = "clang_parser_rejects"; }
Ted Kremenekc3998fa2008-09-25 00:51:44 +000053
54 # Generate the preprocessed file with cc (i.e., gcc).
Ted Kremenek5daa3be2009-01-27 01:19:08 +000055 my ($PPH, $PPFile) = tempfile( $prefix . "_XXXXXX",
56 SUFFIX => GetPPExt($Lang),
57 DIR => $Dir);
Ted Kremenek991c54b2008-08-08 20:46:42 +000058
Ted Kremenek2ec5cd52008-08-25 20:44:31 +000059 system $CC, @$Args, "-E", "-o", $PPFile;
Ted Kremenek991c54b2008-08-08 20:46:42 +000060 close ($PPH);
Ted Kremenekc3998fa2008-09-25 00:51:44 +000061
62 # Generate the preprocessed file with clang.
63 my $PPFile_Clang = $PPFile;
64 $PPFile_Clang =~ s/[.](.+)$/.clang.$1/;
65 system $Clang, @$Args, "-E", "-o", "$PPFile_Clang";
66
67 # Create the info file.
Ted Kremenek82a12532008-09-25 00:25:16 +000068 open (OUT, ">", "$PPFile.info.txt") or die "Cannot open $PPFile.info.txt\n";
Ted Kremenek5f2825f2008-09-21 18:04:49 +000069 print OUT abs_path($file), "\n";
Ted Kremenek5d31f832008-08-18 18:38:29 +000070 print OUT "$ErrorType\n";
Ted Kremenek2dd7ad12008-08-18 20:55:25 +000071 print OUT "@$Args\n";
Ted Kremenek991c54b2008-08-08 20:46:42 +000072 close OUT;
Ted Kremenek82a12532008-09-25 00:25:16 +000073 `uname -a >> $PPFile.info.txt 2>&1`;
74 `$CC -v >> $PPFile.info.txt 2>&1`;
Ted Kremenek9f9b1fd2008-09-12 22:49:36 +000075 system 'mv',$ofile,"$PPFile.stderr.txt";
Ted Kremenek991c54b2008-08-08 20:46:42 +000076}
Ted Kremenekb0982882008-03-25 22:35:32 +000077
Ted Kremenekfbeeca82008-07-19 06:11:04 +000078##----------------------------------------------------------------------------##
79# Running the analyzer.
80##----------------------------------------------------------------------------##
Ted Kremenekb0982882008-03-25 22:35:32 +000081
Ted Kremenekfbeeca82008-07-19 06:11:04 +000082sub Analyze {
83 my ($Clang, $Args, $Lang, $Output, $Verbose, $HtmlDir, $file, $Analyses) = @_;
Seo Sanghyeond3894652008-04-04 11:02:21 +000084
Ted Kremenekfbeeca82008-07-19 06:11:04 +000085 # Skip anything related to C++.
86 return if ($Lang =~ /c[+][+]/);
Ted Kremenek5d31f832008-08-18 18:38:29 +000087
Ted Kremenekfbeeca82008-07-19 06:11:04 +000088 my $RunAnalyzer = 0;
89 my $Cmd;
90 my @CmdArgs;
Ted Kremenek991c54b2008-08-08 20:46:42 +000091 my @CmdArgsSansAnalyses;
Ted Kremenek61cd9882008-05-24 15:58:54 +000092
Ted Kremenekfbeeca82008-07-19 06:11:04 +000093 if ($Lang =~ /header/) {
94 exit 0 if (!defined ($Output));
95 $Cmd = 'cp';
96 push @CmdArgs,$file;
97 # Remove the PCH extension.
98 $Output =~ s/[.]gch$//;
99 push @CmdArgs,$Output;
Ted Kremenek991c54b2008-08-08 20:46:42 +0000100 @CmdArgsSansAnalyses = @CmdArgs;
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000101 }
102 else {
103 $Cmd = $Clang;
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000104 push @CmdArgs,'-DIBOutlet=__attribute__((iboutlet))';
105 push @CmdArgs,@$Args;
Ted Kremenek991c54b2008-08-08 20:46:42 +0000106 @CmdArgsSansAnalyses = @CmdArgs;
Daniel Dunbard4270232009-01-20 23:17:32 +0000107 push @CmdArgs,'--analyze';
Ted Kremenek491918e2009-01-23 20:52:26 +0000108 push @CmdArgs,"--analyzer-display-progress";
Ted Kremenek991c54b2008-08-08 20:46:42 +0000109 push @CmdArgs,(split /\s/,$Analyses);
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000110 $RunAnalyzer = 1;
111 }
112
113 my @PrintArgs;
114 my $dir;
115
116 if ($Verbose) {
117 $dir = getcwd();
118 print STDERR "\n[LOCATION]: $dir\n";
119 push @PrintArgs,"'$Cmd'";
120 foreach my $arg (@CmdArgs) { push @PrintArgs,"\'$arg\'"; }
121 }
122
123 if ($Verbose == 1) {
Ted Kremenek61cd9882008-05-24 15:58:54 +0000124 # We MUST print to stderr. Some clients use the stdout output of
125 # gcc for various purposes.
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000126 print STDERR join(' ',@PrintArgs);
127 print STDERR "\n";
128 }
129 elsif ($Verbose == 2) {
130 print STDERR "#SHELL (cd '$dir' && @PrintArgs)\n";
131 }
Ted Kremenek61cd9882008-05-24 15:58:54 +0000132
Ted Kremenekddf32da2009-01-21 00:42:24 +0000133 if ($RunAnalyzer) {
134 if (defined $ResultFile) {
135 push @CmdArgs,'-o';
136 push @CmdArgs, $ResultFile;
137 }
138 elsif (defined $HtmlDir) {
139 push @CmdArgs,'-o';
140 push @CmdArgs, $HtmlDir;
141 }
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000142 }
Ted Kremenek948e06b2008-08-27 22:30:34 +0000143
144 if (defined $ENV{'CCC_UBI'}) {
145 push @CmdArgs,"--analyzer-viz-egraph-ubigraph";
146 }
Ted Kremenek991c54b2008-08-08 20:46:42 +0000147
Ted Kremenek9a3c7da2008-09-04 00:02:34 +0000148 # Capture the STDERR of clang and send it to a temporary file.
149 # Capture the STDOUT of clang and reroute it to ccc-analyzer's STDERR.
150 # We save the output file in the 'crashes' directory if clang encounters
151 # any problems with the file.
Ted Kremenek13462682008-09-11 23:05:26 +0000152 pipe (FROM_CHILD, TO_PARENT);
Ted Kremenek9a3c7da2008-09-04 00:02:34 +0000153 my $pid = fork();
154 if ($pid == 0) {
Ted Kremenek13462682008-09-11 23:05:26 +0000155 close FROM_CHILD;
156 open(STDOUT,">&", \*TO_PARENT);
157 open(STDERR,">&", \*TO_PARENT);
Ted Kremenek9a3c7da2008-09-04 00:02:34 +0000158 exec $Cmd, @CmdArgs;
159 }
Ted Kremenek13462682008-09-11 23:05:26 +0000160
161 close TO_PARENT;
162 my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir);
163
164 while (<FROM_CHILD>) {
165 print $ofh $_;
166 print STDERR $_;
167 }
168
169 waitpid($pid,0);
Ted Kremenek9a3c7da2008-09-04 00:02:34 +0000170 my $Result = $?;
171
172 # Did the command die because of a signal?
173 if ($Result & 127 and $Cmd eq $Clang and defined $HtmlDir) {
Ted Kremenekc3998fa2008-09-25 00:51:44 +0000174 ProcessClangFailure($Clang, $Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
Ted Kremenek9a3c7da2008-09-04 00:02:34 +0000175 "Crash", $ofile);
176 }
177 elsif ($Result) {
Ted Kremenekc3998fa2008-09-25 00:51:44 +0000178 ProcessClangFailure($Clang, $Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
Ted Kremenek5daa3be2009-01-27 01:19:08 +0000179 $ParserRejects, $ofile);
Ted Kremenek9a3c7da2008-09-04 00:02:34 +0000180 }
181
182 `rm -f $ofile`;
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000183}
Ted Kremenek61cd9882008-05-24 15:58:54 +0000184
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000185##----------------------------------------------------------------------------##
186# Lookup tables.
187##----------------------------------------------------------------------------##
188
189my %CompileOptionMap = (
190 '-nostdinc' => 0,
Anders Carlsson06c58b12008-12-19 20:56:23 +0000191 '-fblocks' => 0,
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000192 '-fobjc-gc-only' => 0,
193 '-fobjc-gc' => 0,
194 '-include' => 1,
195 '-idirafter' => 1,
196 '-iprefix' => 1,
197 '-iquote' => 1,
198 '-isystem' => 1,
199 '-iwithprefix' => 1,
200 '-iwithprefixbefore' => 1
201);
202
203my %LinkerOptionMap = (
204 '-framework' => 1
205);
206
207my %CompilerLinkerOptionMap = (
208 '-isysroot' => 1,
209 '-arch' => 1,
Ted Kremeneke4f69522008-09-29 22:45:28 +0000210 '-v' => 0,
Ted Kremenekb10362a2008-09-30 23:40:25 +0000211 '-fpascal-strings' => 0,
212 '-mmacosx-version-min' => 0 # This is really a 1 argument, but always has '='
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000213);
214
215my %IgnoredOptionMap = (
Ted Kremenek94026092008-07-24 03:52:21 +0000216 '-MT' => 1, # Ignore these preprocessor options.
217 '-MF' => 1,
218
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000219 '-fsyntax-only' => 0,
220 '-save-temps' => 0,
221 '-install_name' => 1,
222 '-exported_symbols_list' => 1,
223 '-current_version' => 1,
224 '-compatibility_version' => 1,
225 '-init' => 1,
226 '-e' => 1,
227 '-seg1addr' => 1,
228 '-bundle_loader' => 1,
229 '-multiply_defined' => 1,
230 '-sectorder' => 3,
231 '--param' => 1,
232 '-u' => 1
233);
234
235my %LangMap = (
236 'c' => 'c',
237 'cpp' => 'c++',
238 'cc' => 'c++',
239 'i' => 'c-cpp-output',
240 'm' => 'objective-c',
241 'mi' => 'objective-c-cpp-output'
242);
243
Ted Kremeneka30730e2008-09-29 16:15:20 +0000244my %UniqueOptions = (
245 '-isysroot' => 0
246);
247
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000248##----------------------------------------------------------------------------##
249# Main Logic.
250##----------------------------------------------------------------------------##
251
252my $Action = 'link';
253my @CompileOpts;
254my @LinkOpts;
255my @Files;
256my $Lang;
257my $Output;
Ted Kremeneka30730e2008-09-29 16:15:20 +0000258my %Uniqued;
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000259
260# Forward arguments to gcc.
Ted Kremenekf17ef3c2008-08-21 21:47:09 +0000261my $Status = system($CC,@ARGV);
Ted Kremenekcb344d02008-08-28 01:18:44 +0000262if ($Status) { exit($Status >> 8); }
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000263
264# Get the analysis options.
265my $Analyses = $ENV{'CCC_ANALYZER_ANALYSIS'};
266if (!defined($Analyses)) { $Analyses = '-checker-cfref'; }
267
Zhongxing Xu07c37672008-10-27 14:26:32 +0000268# Get the store model.
269my $StoreModel = $ENV{'CCC_ANALYZER_STORE_MODEL'};
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000270if (!defined $StoreModel) { $StoreModel = "basic"; }
271
272# Get the constraints engine.
273my $ConstraintsModel = $ENV{'CCC_ANALYZER_CONSTRAINTS_MODEL'};
274if (!defined $ConstraintsModel) { $ConstraintsModel = "basic"; }
Zhongxing Xu07c37672008-10-27 14:26:32 +0000275
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000276# Get the output format.
277my $OutputFormat = $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'};
Ted Kremenek3891a152009-02-17 05:01:10 +0000278if (!defined $OutputFormat) { $OutputFormat = "html"; }
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000279
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000280# Determine the level of verbosity.
281my $Verbose = 0;
282if (defined $ENV{CCC_ANALYZER_VERBOSE}) { $Verbose = 1; }
283if (defined $ENV{CCC_ANALYZER_LOG}) { $Verbose = 2; }
284
285# Determine what clang executable to use.
286my $Clang = $ENV{'CLANG'};
287if (!defined $Clang) { $Clang = 'clang'; }
288
289# Get the HTML output directory.
290my $HtmlDir = $ENV{'CCC_ANALYZER_HTML'};
291
Ted Kremenek27783eb2008-09-25 20:17:57 +0000292my %ArchsSeen;
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000293
294# Process the arguments.
295foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
Ted Kremenek89c4fcf2008-10-19 06:42:38 +0000296 my $Arg = $ARGV[$i];
297 my ($ArgKey) = split /=/,$Arg,2;
298
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000299 # Modes ccc-analyzer supports
300 if ($Arg eq '-E') { $Action = 'preprocess'; }
301 elsif ($Arg eq '-c') { $Action = 'compile'; }
302 elsif ($Arg =~ /^-print-prog-name/) { exit 0; }
Ted Kremenek27783eb2008-09-25 20:17:57 +0000303
304 # Specially handle duplicate cases of -arch
305 if ($Arg eq "-arch") {
306 my $arch = $ARGV[$i+1];
307 $ArchsSeen{$arch} = 1;
308 ++$i;
309 next;
310 }
311
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000312 # Options with possible arguments that should pass through to compiler.
Ted Kremenek89c4fcf2008-10-19 06:42:38 +0000313 if (defined $CompileOptionMap{$ArgKey}) {
314 my $Cnt = $CompileOptionMap{$ArgKey};
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000315 push @CompileOpts,$Arg;
316 while ($Cnt > 0) { ++$i; --$Cnt; push @CompileOpts, $ARGV[$i]; }
317 next;
318 }
319
320 # Options with possible arguments that should pass through to linker.
Ted Kremenek89c4fcf2008-10-19 06:42:38 +0000321 if (defined $LinkerOptionMap{$ArgKey}) {
322 my $Cnt = $LinkerOptionMap{$ArgKey};
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000323 push @LinkOpts,$Arg;
324 while ($Cnt > 0) { ++$i; --$Cnt; push @LinkOpts, $ARGV[$i]; }
325 next;
326 }
327
328 # Options with possible arguments that should pass through to both compiler
329 # and the linker.
Ted Kremenek89c4fcf2008-10-19 06:42:38 +0000330 if (defined $CompilerLinkerOptionMap{$ArgKey}) {
331 my $Cnt = $CompilerLinkerOptionMap{$ArgKey};
Ted Kremenek47fc25f2008-09-29 23:06:09 +0000332
Ted Kremeneka30730e2008-09-29 16:15:20 +0000333 # Check if this is an option that should have a unique value, and if so
334 # determine if the value was checked before.
335 if ($UniqueOptions{$Arg}) {
336 if (defined $Uniqued{$Arg}) {
337 $i += $Cnt;
338 next;
339 }
340 $Uniqued{$Arg} = 1;
341 }
342
Ted Kremenek47fc25f2008-09-29 23:06:09 +0000343 push @CompileOpts,$Arg;
344 push @LinkOpts,$Arg;
345
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000346 while ($Cnt > 0) {
347 ++$i; --$Cnt;
348 push @CompileOpts, $ARGV[$i];
349 push @LinkOpts, $ARGV[$i];
350 }
351 next;
352 }
Ted Kremenek61cd9882008-05-24 15:58:54 +0000353
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000354 # Ignored options.
Ted Kremenek89c4fcf2008-10-19 06:42:38 +0000355 if (defined $IgnoredOptionMap{$ArgKey}) {
356 my $Cnt = $IgnoredOptionMap{$ArgKey};
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000357 while ($Cnt > 0) {
358 ++$i; --$Cnt;
359 }
360 next;
361 }
Ted Kremenek61cd9882008-05-24 15:58:54 +0000362
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000363 # Compile mode flags.
364 if ($Arg =~ /^-[D,I,U](.*)$/) {
365 my $Tmp = $Arg;
366 if ($1 eq '') {
367 # FIXME: Check if we are going off the end.
368 ++$i;
369 $Tmp = $Arg . $ARGV[$i];
370 }
371 push @CompileOpts,$Tmp;
372 next;
373 }
374
375 # Language.
376 if ($Arg eq '-x') {
377 $Lang = $ARGV[$i+1];
378 ++$i; next;
379 }
Ted Kremenek61cd9882008-05-24 15:58:54 +0000380
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000381 # Output file.
382 if ($Arg eq '-o') {
383 ++$i;
384 $Output = $ARGV[$i];
385 next;
386 }
387
388 # Get the link mode.
389 if ($Arg =~ /^-[l,L,O]/) {
390 if ($Arg eq '-O') { push @LinkOpts,'-O1'; }
391 elsif ($Arg eq '-Os') { push @LinkOpts,'-O2'; }
392 else { push @LinkOpts,$Arg; }
393 next;
394 }
395
396 if ($Arg =~ /^-std=/) {
397 push @CompileOpts,$Arg;
398 next;
399 }
400
401# if ($Arg =~ /^-f/) {
402# # FIXME: Not sure if the remaining -fxxxx options have no arguments.
403# push @CompileOpts,$Arg;
404# push @LinkOpts,$Arg; # FIXME: Not sure if these are link opts.
405# }
406
407 # Get the compiler/link mode.
408 if ($Arg =~ /^-F(.+)$/) {
409 my $Tmp = $Arg;
410 if ($1 eq '') {
411 # FIXME: Check if we are going off the end.
412 ++$i;
413 $Tmp = $Arg . $ARGV[$i];
414 }
415 push @CompileOpts,$Tmp;
416 push @LinkOpts,$Tmp;
417 next;
418 }
Ted Kremenek61cd9882008-05-24 15:58:54 +0000419
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000420 # Input files.
421 if ($Arg eq '-filelist') {
422 # FIXME: Make sure we aren't walking off the end.
423 open(IN, $ARGV[$i+1]);
424 while (<IN>) { s/\015?\012//; push @Files,$_; }
425 close(IN);
426 ++$i; next;
427 }
428
429 if (!($Arg =~ /^-/)) {
430 push @Files,$Arg; next;
431 }
432}
Ted Kremenek61cd9882008-05-24 15:58:54 +0000433
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000434if ($Action eq 'compile' or $Action eq 'link') {
435 foreach my $file (@Files) {
436 # Determine the language for the file.
437 my $FileLang = $Lang;
438
439 if (!defined($FileLang)) {
440 # Infer the language from the extension.
441 if ($file =~ /[.]([^.]+)$/) {
442 $FileLang = $LangMap{$1};
443 }
444 }
Ted Kremenek1262fc42008-05-14 20:10:33 +0000445
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000446 next if (!defined $FileLang);
447
448 my @AnalyzeArgs;
449
450 if ($FileLang ne 'unknown') {
451 push @AnalyzeArgs,'-x';
452 push @AnalyzeArgs,$FileLang;
453 }
Ted Kremenekb0982882008-03-25 22:35:32 +0000454
Zhongxing Xu07c37672008-10-27 14:26:32 +0000455 if (defined $StoreModel) {
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000456 push @AnalyzeArgs, "-analyzer-store=$StoreModel";
Zhongxing Xu07c37672008-10-27 14:26:32 +0000457 }
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000458
459 if (defined $ConstraintsModel) {
460 push @AnalyzeArgs, "-analyzer-constraints=$ConstraintsModel";
461 }
462
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000463 if (defined $OutputFormat) {
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000464 push @AnalyzeArgs, "-analyzer-output=" . $OutputFormat;
Ted Kremenekddf32da2009-01-21 00:42:24 +0000465 if ($OutputFormat eq "plist") {
466 # Change "Output" to be a file.
467 my ($h, $f) = tempfile("report-XXXXXX", SUFFIX => ".plist",
468 DIR => $HtmlDir);
469 $ResultFile = $f;
470 $CleanupFile = $f;
471 }
Ted Kremenekdb4f5f22008-11-04 00:02:53 +0000472 }
Zhongxing Xu07c37672008-10-27 14:26:32 +0000473
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000474 push @AnalyzeArgs,@CompileOpts;
475 push @AnalyzeArgs,$file;
Zhongxing Xu07c37672008-10-27 14:26:32 +0000476
Ted Kremenek27783eb2008-09-25 20:17:57 +0000477 my @Archs = keys %ArchsSeen;
478 if (scalar @Archs) {
479 foreach my $arch (@Archs) {
480 my @NewArgs;
481 push @NewArgs, '-arch';
482 push @NewArgs, $arch;
483 push @NewArgs, @AnalyzeArgs;
484 Analyze($Clang, \@NewArgs, $FileLang, $Output,
485 $Verbose, $HtmlDir, $file, $Analyses);
486 }
487 }
488 else {
489 Analyze($Clang, \@AnalyzeArgs, $FileLang, $Output,
490 $Verbose, $HtmlDir, $file, $Analyses);
491 }
Ted Kremenekfbeeca82008-07-19 06:11:04 +0000492 }
493}
Ted Kremenekb0982882008-03-25 22:35:32 +0000494
Ted Kremenek948e06b2008-08-27 22:30:34 +0000495exit($Status >> 8);
496