mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 15:26:41 +00:00

Summary: This patch introduces a new `analyzer-config` configuration: `-analyzer-config silence-checkers` which could be used to silence the given checkers. It accepts a semicolon separated list, packed into quotation marks, e.g: `-analyzer-config silence-checkers="core.DivideZero;core.NullDereference"` It could be used to "disable" core checkers, so they model the analysis as before, just if some of them are too noisy it prevents to emit reports. This patch also adds support for that new option to the scan-build. Passing the option `-disable-checker core.DivideZero` to the scan-build will be transferred to `-analyzer-config silence-checkers=core.DivideZero`. Reviewed By: NoQ, Szelethus Differential Revision: https://reviews.llvm.org/D66042 llvm-svn: 369078
19 lines
479 B
C++
19 lines
479 B
C++
// RUN: %clang_analyze_cc1 \
|
|
// RUN: -analyzer-checker=core -analyzer-config \
|
|
// RUN: silence-checkers=core.DivideZero \
|
|
// RUN: -verify %s
|
|
|
|
void test_disable_core_div_by_zero() {
|
|
(void)(1 / 0);
|
|
// expected-warning@-1 {{division by zero is undefined}}
|
|
// no-warning: 'Division by zero'
|
|
}
|
|
|
|
void test_disable_null_deref(int *p) {
|
|
if (p)
|
|
return;
|
|
|
|
int x = p[0];
|
|
// expected-warning@-1 {{Array access (from variable 'p') results in a null pointer dereference}}
|
|
}
|