Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / exploration_order / prefer_unexplored.cpp
blob29e763357727e9503d92ee1b48e073af8302ae85
1 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config exploration_strategy=unexplored_first -analyzer-output=text -verify %s
2 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config exploration_strategy=unexplored_first_queue -analyzer-output=text -verify %s
4 extern int coin();
6 int foo() {
7 int *x = 0; // expected-note {{'x' initialized to a null pointer value}}
8 while (coin()) { // expected-note{{Loop condition is true}}
9 if (coin()) // expected-note {{Taking true branch}}
10 // expected-note@-1 {{Assuming the condition is true}}
11 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
12 // expected-note@-1{{Dereference of null pointer (loaded from variable 'x')}}
14 return 0;
17 void bar() {
18 while(coin())
19 if (coin())
20 foo();
23 int foo2() {
24 int *x = 0; // expected-note {{'x' initialized to a null pointer value}}
25 while (coin()) { // expected-note{{Loop condition is true}}
26 if (coin()) // expected-note {{Taking false branch}}
27 // expected-note@-1 {{Assuming the condition is false}}
28 return false;
29 else
30 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
31 // expected-note@-1{{Dereference of null pointer (loaded from variable 'x')}}
33 return 0;
36 void bar2() {
37 while(coin()) // expected-note{{Loop condition is true}}
38 if (coin()) // expected-note {{Assuming the condition is false}}
39 // expected-note@-1 {{Taking false branch}}
40 return;
41 else
42 foo(); // expected-note{{Calling 'foo'}}