Skip to content

Commit b086d3e

Browse files
committed
[clang][scan-build] Trust users' compiler choice
If you went out of your way to specify the option, you probably knew what you wanted and didn't want the default you'd get from not specifying the option in the first place. We just let the error from from system() propagate to tell the user that the option they provided wasn't usable: $ scan-build-19 --use-cc="enoent gcc" make scan-build: Using '/usr/lib/llvm-19/bin/clang' for static analysis ... Can't exec "enoent": No such file or directory ...
1 parent e101c97 commit b086d3e

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

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

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ sub silent_system {
5151
# Compiler command setup.
5252
##===----------------------------------------------------------------------===##
5353

54-
# Search in the PATH if the compiler exists
55-
sub SearchInPath {
56-
my $file = shift;
57-
foreach my $dir (split (':', $ENV{PATH})) {
58-
if (-x "$dir/$file") {
59-
return 1;
60-
}
61-
}
62-
return 0;
63-
}
64-
6554
{
6655
my ($DefaultCCompiler, $DefaultCXXCompiler);
6756

@@ -81,13 +70,7 @@ sub SearchInPath {
8170
my ($is_cxx) = @_;
8271
my $default = $is_cxx ? $DefaultCXXCompiler : $DefaultCCompiler;
8372
my $opt = $ENV{$is_cxx ? 'CCC_CXX' : 'CCC_CC'};
84-
return $default unless defined $opt;
85-
my ($comp, @args) = shellwords($opt);
86-
if (!-x $comp && !SearchInPath($comp)) {
87-
warn "Can't execute '$comp'. Falling back to '$default'.\n";
88-
return $default;
89-
}
90-
return ($comp, @args);
73+
return defined $opt ? shellwords($opt) : $default;
9174
}
9275
}
9376

0 commit comments

Comments
 (0)