Skip to content

Commit 3bdcfbb

Browse files
committed
[clang][scan-build] Treat --use-cc and --use-c++ as shell commands
So that things like --use-cc="ccache gcc" work. Fixes #26594. Also use the slightly simpler shellwords instead of quotewords.
1 parent c4eec9e commit 3bdcfbb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clang/tools/scan-build/libexec/ccc-analyzer

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ sub SearchInPath {
6363
}
6464

6565
my $Compiler;
66+
my @CompilerArgs;
6667
my $Clang;
6768
my $DefaultCCompiler;
6869
my $DefaultCXXCompiler;
@@ -89,7 +90,7 @@ if (`uname -s` =~ m/Darwin/) {
8990
}
9091

9192
if ($FindBin::Script =~ /c\+\+-analyzer/) {
92-
$Compiler = $ENV{'CCC_CXX'};
93+
($Compiler, @CompilerArgs) = shellwords($ENV{'CCC_CXX'});
9394
if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCXXCompiler; }
9495

9596
$Clang = $ENV{'CLANG_CXX'};
@@ -98,7 +99,7 @@ if ($FindBin::Script =~ /c\+\+-analyzer/) {
9899
$IsCXX = 1
99100
}
100101
else {
101-
$Compiler = $ENV{'CCC_CC'};
102+
($Compiler, @CompilerArgs) = shellwords($ENV{'CCC_CC'});
102103
if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCCompiler; }
103104

104105
$Clang = $ENV{'CLANG'};
@@ -199,7 +200,7 @@ sub GetCCArgs {
199200
die "could not find clang line\n" if (!defined $line);
200201
# Strip leading and trailing whitespace characters.
201202
$line =~ s/^\s+|\s+$//g;
202-
my @items = quotewords('\s+', 0, $line);
203+
my @items = shellwords($line);
203204
my $cmd = shift @items;
204205
die "cannot find 'clang' in 'clang' command\n" if (!($cmd =~ /clang/ || basename($cmd) =~ /llvm/));
205206
# If this is the llvm-driver the internal command will look like "llvm clang ...".
@@ -462,9 +463,9 @@ my $Output;
462463
my %Uniqued;
463464

464465
# Forward arguments to gcc.
465-
my $Status = system($Compiler,@ARGV);
466+
my $Status = system($Compiler,@CompilerArgs,@ARGV);
466467
if (defined $ENV{'CCC_ANALYZER_LOG'}) {
467-
print STDERR "$Compiler @ARGV\n";
468+
print STDERR "$Compiler @CompilerArgs @ARGV\n";
468469
}
469470
if ($Status) { exit($Status >> 8); }
470471

0 commit comments

Comments
 (0)