Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / inlining / eager-reclamation-path-notes.c
blob92d5992196d556b4ce3d51d5400541ebe69f1ef6
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -analyzer-config graph-trim-interval=5 -verify %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config graph-trim-interval=5 %s -o %t.plist
3 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/eager-reclamation-path-notes.c.plist -
5 void use(int *ptr, int val) {
6 *ptr = val; // expected-warning {{Dereference of null pointer (loaded from variable 'ptr')}}
7 // expected-note@-1 {{Dereference of null pointer (loaded from variable 'ptr')}}
10 int compute(void) {
11 // Do something that will take enough processing to trigger trimming.
12 // FIXME: This is actually really sensitive. If the interval timing is just
13 // wrong, the node for the actual dereference may also be collected, and all
14 // the path notes will disappear.
15 return 2 + 3 + 4 + 5 + 6;
18 void testSimple(void) {
19 int *p = 0;
20 // expected-note@-1 {{'p' initialized to a null pointer value}}
21 use(p, compute());
22 // expected-note@-1 {{Passing null pointer value via 1st parameter 'ptr'}}
23 // expected-note@-2 {{Calling 'use'}}
27 void use2(int *ptr, int val) {
28 *ptr = val; // expected-warning {{Dereference of null pointer (loaded from variable 'ptr')}}
29 // expected-note@-1 {{Dereference of null pointer (loaded from variable 'ptr')}}
32 void passThrough(int *p) {
33 use2(p, compute());
34 // expected-note@-1 {{Passing null pointer value via 1st parameter 'ptr'}}
35 // expected-note@-2 {{Calling 'use2'}}
38 void testChainedCalls(void) {
39 int *ptr = 0;
40 // expected-note@-1 {{'ptr' initialized to a null pointer value}}
41 passThrough(ptr);
42 // expected-note@-1 {{Passing null pointer value via 1st parameter 'p'}}
43 // expected-note@-2 {{Calling 'passThrough'}}