forked from OSchip/llvm-project
[analyzer] scan-build: Fix silencing multiple core checkers.
It was only silencing one checker because -analyzer-config flags can only carry one value at a time.
This commit is contained in:
parent
3bbbe4c4b6
commit
0b2a922246
|
@ -0,0 +1,8 @@
|
|||
int test(int x) {
|
||||
if (x) {
|
||||
int *p = 0;
|
||||
return *p; // Null dereference.
|
||||
} else {
|
||||
return 1 / x; // Division by zero.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// FIXME: Actually, "perl".
|
||||
REQUIRES: shell
|
||||
|
||||
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
|
||||
RUN: %scan-build -o %t.output_dir \
|
||||
RUN: %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
|
||||
RUN: | FileCheck %s -check-prefix CHECK-TWO-BUGS
|
||||
|
||||
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
|
||||
RUN: %scan-build -o %t.output_dir \
|
||||
RUN: -disable-checker core.DivideZero \
|
||||
RUN: %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
|
||||
RUN: | FileCheck %s -check-prefix CHECK-ONE-BUG
|
||||
|
||||
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
|
||||
RUN: %scan-build -o %t.output_dir \
|
||||
RUN: -disable-checker core.NullDereference \
|
||||
RUN: %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
|
||||
RUN: | FileCheck %s -check-prefix CHECK-ONE-BUG
|
||||
|
||||
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
|
||||
RUN: %scan-build -o %t.output_dir \
|
||||
RUN: -disable-checker core.NullDereference \
|
||||
RUN: -disable-checker core.DivideZero \
|
||||
RUN: %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
|
||||
RUN: | FileCheck %s -check-prefix CHECK-NO-BUGS
|
||||
|
||||
CHECK-NO-BUGS: scan-build: No bugs found.
|
||||
CHECK-ONE-BUG: scan-build: 1 bug found.
|
||||
CHECK-TWO-BUGS: scan-build: 2 bugs found.
|
|
@ -1973,11 +1973,13 @@ my $CCC_ANALYZER_ANALYSIS = join ' ', @AnalysesToRun;
|
|||
my $CCC_ANALYZER_PLUGINS = join ' ', map { "-load ".$_ } @{$Options{PluginsToLoad}};
|
||||
my $CCC_ANALYZER_CONFIG = join ' ', map { "-analyzer-config ".$_ } @{$Options{ConfigOptions}};
|
||||
|
||||
foreach (sort { $Options{SilenceCheckers}{$a} <=> $Options{SilenceCheckers}{$b} }
|
||||
keys %{$Options{SilenceCheckers}}) {
|
||||
# Add checkers in order they were silenced.
|
||||
if (%{$Options{SilenceCheckers}}) {
|
||||
$CCC_ANALYZER_CONFIG =
|
||||
$CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers=".$_;
|
||||
$CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers="
|
||||
.join(';', sort {
|
||||
$Options{SilenceCheckers}{$a} <=>
|
||||
$Options{SilenceCheckers}{$b}
|
||||
} keys %{$Options{SilenceCheckers}});
|
||||
}
|
||||
|
||||
my %EnvVars = (
|
||||
|
|
Loading…
Reference in New Issue