Emulate gcc driver-driver functionality: run analyzer separately for each separate -arch option.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56618 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/ccc-analyzer b/utils/ccc-analyzer
index 4f76250..3f5ef26 100755
--- a/utils/ccc-analyzer
+++ b/utils/ccc-analyzer
@@ -246,6 +246,7 @@
# Get the HTML output directory.
my $HtmlDir = $ENV{'CCC_ANALYZER_HTML'};
+my %ArchsSeen;
# Process the arguments.
foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
@@ -255,7 +256,15 @@
if ($Arg eq '-E') { $Action = 'preprocess'; }
elsif ($Arg eq '-c') { $Action = 'compile'; }
elsif ($Arg =~ /^-print-prog-name/) { exit 0; }
-
+
+ # Specially handle duplicate cases of -arch
+ if ($Arg eq "-arch") {
+ my $arch = $ARGV[$i+1];
+ $ArchsSeen{$arch} = 1;
+ ++$i;
+ next;
+ }
+
# Options with possible arguments that should pass through to compiler.
if (defined $CompileOptionMap{$Arg}) {
my $Cnt = $CompileOptionMap{$Arg};
@@ -390,11 +399,23 @@
push @AnalyzeArgs,@CompileOpts;
push @AnalyzeArgs,$file;
- Analyze($Clang, \@AnalyzeArgs, $FileLang, $Output,
- $Verbose, $HtmlDir, $file, $Analyses);
+ my @Archs = keys %ArchsSeen;
+ if (scalar @Archs) {
+ foreach my $arch (@Archs) {
+ my @NewArgs;
+ push @NewArgs, '-arch';
+ push @NewArgs, $arch;
+ push @NewArgs, @AnalyzeArgs;
+ Analyze($Clang, \@NewArgs, $FileLang, $Output,
+ $Verbose, $HtmlDir, $file, $Analyses);
+ }
+ }
+ else {
+ Analyze($Clang, \@AnalyzeArgs, $FileLang, $Output,
+ $Verbose, $HtmlDir, $file, $Analyses);
+ }
}
}
exit($Status >> 8);
-