https://github.com/rafl created https://github.com/llvm/llvm-project/pull/131932
So that things like --use-cc="ccache gcc" work. Fixes #26594. Also use the slightly simpler shellwords instead of quotewords. Cc-ing the Clang static analyzer maintainers @haoNoQ, @Xazax-hun, and @steakhal. >From bebd0d1245abc93397b388e098fd5f2ccdc196db Mon Sep 17 00:00:00 2001 From: Florian Ragwitz <florian.ragw...@gmail.com> Date: Tue, 18 Mar 2025 15:35:42 -0700 Subject: [PATCH] [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. --- clang/tools/scan-build/libexec/ccc-analyzer | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/clang/tools/scan-build/libexec/ccc-analyzer b/clang/tools/scan-build/libexec/ccc-analyzer index 74f812aef8fdf..655ded4b102be 100755 --- a/clang/tools/scan-build/libexec/ccc-analyzer +++ b/clang/tools/scan-build/libexec/ccc-analyzer @@ -63,6 +63,7 @@ sub SearchInPath { } my $Compiler; +my @CompilerArgs; my $Clang; my $DefaultCCompiler; my $DefaultCXXCompiler; @@ -89,7 +90,7 @@ if (`uname -s` =~ m/Darwin/) { } if ($FindBin::Script =~ /c\+\+-analyzer/) { - $Compiler = $ENV{'CCC_CXX'}; + ($Compiler, @CompilerArgs) = shellwords($ENV{'CCC_CXX'}); if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCXXCompiler; } $Clang = $ENV{'CLANG_CXX'}; @@ -98,7 +99,7 @@ if ($FindBin::Script =~ /c\+\+-analyzer/) { $IsCXX = 1 } else { - $Compiler = $ENV{'CCC_CC'}; + ($Compiler, @CompilerArgs) = shellwords($ENV{'CCC_CC'}); if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { $Compiler = $DefaultCCompiler; } $Clang = $ENV{'CLANG'}; @@ -199,7 +200,7 @@ sub GetCCArgs { die "could not find clang line\n" if (!defined $line); # Strip leading and trailing whitespace characters. $line =~ s/^\s+|\s+$//g; - my @items = quotewords('\s+', 0, $line); + my @items = shellwords($line); my $cmd = shift @items; die "cannot find 'clang' in 'clang' command\n" if (!($cmd =~ /clang/ || basename($cmd) =~ /llvm/)); # If this is the llvm-driver the internal command will look like "llvm clang ...". @@ -462,9 +463,9 @@ my $Output; my %Uniqued; # Forward arguments to gcc. -my $Status = system($Compiler,@ARGV); +my $Status = system($Compiler,@CompilerArgs,@ARGV); if (defined $ENV{'CCC_ANALYZER_LOG'}) { - print STDERR "$Compiler @ARGV\n"; + print STDERR "$Compiler @CompilerArgs @ARGV\n"; } if ($Status) { exit($Status >> 8); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits