1 // RUN: %clang_analyze_cc1 \
2 // RUN:  -analyzer-checker=core -analyzer-config \
3 // RUN:   silence-checkers=core \
4 // RUN:  -verify %s
5 
6 // RUN: %clang_analyze_cc1 \
7 // RUN:  -analyzer-checker=core -analyzer-config \
8 // RUN:   silence-checkers="core.DivideZero;core.NullDereference" \
9 // RUN:  -verify %s
10 
11 // RUN: not %clang_analyze_cc1 -verify %s \
12 // RUN:  -analyzer-checker=core -analyzer-config \
13 // RUN:   silence-checkers=core.NullDeref \
14 // RUN:  2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-ERROR
15 
16 // CHECK-CHECKER-ERROR:      (frontend): no analyzer checkers or packages
17 // CHECK-CHECKER-ERROR-SAME:             are associated with 'core.NullDeref'
18 
19 // RUN: not %clang_analyze_cc1 -verify %s \
20 // RUN:  -analyzer-checker=core -analyzer-config \
21 // RUN:   silence-checkers=coreModeling \
22 // RUN:  2>&1 | FileCheck %s -check-prefix=CHECK-PACKAGE-ERROR
23 
24 // CHECK-PACKAGE-ERROR:      (frontend): no analyzer checkers or packages
25 // CHECK-PACKAGE-ERROR-SAME:             are associated with 'coreModeling'
26 
test_disable_core_div_by_zero()27 void test_disable_core_div_by_zero() {
28   (void)(1 / 0);
29   // expected-warning@-1 {{division by zero is undefined}}
30   // no-warning: 'Division by zero'
31 }
32 
test_disable_null_deref(int * p)33 void test_disable_null_deref(int *p) {
34   if (p)
35     return;
36 
37   int x = p[0];
38   // no-warning: Array access (from variable 'p') results in a null pointer dereference
39 }
40