--- /tmp/llvm-toolchain-snapshot-9~svn351420/clang/tools/scan-build/libexec/ccc-analyzer 2019-02-15 11:27:10.000000000 +0200 +++ /usr/share/clang/scan-build-9/libexec/ccc-analyzer 2019-02-15 12:02:12.090480177 +0200 @@ -497,8 +497,9 @@ my $HasSDK = 0; # Process the arguments. -foreach (my $i = 0; $i < scalar(@ARGV); ++$i) { - my $Arg = $ARGV[$i]; +sub processArgs { + foreach (my $i = 0; $i < scalar(@_); ++$i) { + my $Arg = $_[$i]; my ($ArgKey) = split /=/,$Arg,2; # Be friendly to "" in the argument list. @@ -513,7 +514,7 @@ # Specially handle duplicate cases of -arch if ($Arg eq "-arch") { - my $arch = $ARGV[$i+1]; + my $arch = $_[$i+1]; # We don't want to process 'ppc' because of Clang's lack of support # for Altivec (also some #defines won't likely be defined correctly, etc.) if (!(defined $DisabledArchs{$arch})) { $ArchsSeen{$arch} = 1; } @@ -532,7 +533,7 @@ if (defined $CompileOptionMap{$ArgKey}) { my $Cnt = $CompileOptionMap{$ArgKey}; push @CompileOpts,$Arg; - while ($Cnt > 0) { ++$i; --$Cnt; push @CompileOpts, $ARGV[$i]; } + while ($Cnt > 0) { ++$i; --$Cnt; push @CompileOpts, $_[$i]; } next; } # Handle the case where there isn't a space after -iquote @@ -545,7 +546,7 @@ if (defined $LinkerOptionMap{$ArgKey}) { my $Cnt = $LinkerOptionMap{$ArgKey}; push @LinkOpts,$Arg; - while ($Cnt > 0) { ++$i; --$Cnt; push @LinkOpts, $ARGV[$i]; } + while ($Cnt > 0) { ++$i; --$Cnt; push @LinkOpts, $_[$i]; } next; } @@ -569,8 +570,8 @@ while ($Cnt > 0) { ++$i; --$Cnt; - push @CompileOpts, $ARGV[$i]; - push @LinkOpts, $ARGV[$i]; + push @CompileOpts, $_[$i]; + push @LinkOpts, $_[$i]; } next; } @@ -590,7 +591,7 @@ if ($1 eq '') { # FIXME: Check if we are going off the end. ++$i; - $Tmp = $Arg . $ARGV[$i]; + $Tmp = $Arg . $_[$i]; } push @CompileOpts,$Tmp; next; @@ -603,14 +604,14 @@ # Language. if ($Arg eq '-x') { - $Lang = $ARGV[$i+1]; + $Lang = $_[$i+1]; ++$i; next; } # Output file. if ($Arg eq '-o') { ++$i; - $Output = $ARGV[$i]; + $Output = $_[$i]; next; } @@ -636,7 +637,7 @@ if ($1 eq '') { # FIXME: Check if we are going off the end. ++$i; - $Tmp = $Arg . $ARGV[$i]; + $Tmp = $Arg . $_[$i]; } push @CompileOpts,$Tmp; push @LinkOpts,$Tmp; @@ -646,7 +647,7 @@ # Input files. if ($Arg eq '-filelist') { # FIXME: Make sure we aren't walking off the end. - open(IN, $ARGV[$i+1]); + open(IN, $_[$i+1]); while () { s/\015?\012//; push @Files,$_; } close(IN); ++$i; @@ -671,7 +672,17 @@ # FIXME: Check if we are going off the end. ++$i; push @CompileOpts, $Arg; - push @CompileOpts, $ARGV[$i]; + push @CompileOpts, $_[$i]; + next; + } + + if ($Arg =~ /^@/) { + my $filename = substr $Arg, 1; + open ATF,"$filename" or die "couldn't open \@file"; + my @atargs = ; + my $atargss = join(' ', @atargs); + @atargs = split(/\s+/, $atargss); + processArgs(@atargs); next; } @@ -679,8 +690,11 @@ push @Files, $Arg; next; } + } } +processArgs(@ARGV); + # Forcedly enable debugging if requested by user. if ($ForceAnalyzeDebugCode) { push @CompileOpts, '-UNDEBUG';