diff options
| author | George Karpenkov <ekarpenkov@apple.com> | 2018-02-12 22:39:57 +0000 |
|---|---|---|
| committer | George Karpenkov <ekarpenkov@apple.com> | 2018-02-12 22:39:57 +0000 |
| commit | 1235a63df528def66205b746d8947a9b02008f8b (patch) | |
| tree | 0d4bd9027db61d7de793f2fadd5bb52b94f0e233 /clang/test | |
| parent | 095d72989d88467b674ec9282a28405a2aa4c729 (diff) | |
| download | bcm5719-llvm-1235a63df528def66205b746d8947a9b02008f8b.tar.gz bcm5719-llvm-1235a63df528def66205b746d8947a9b02008f8b.zip | |
[analyzer] Exploration strategy prioritizing unexplored coverage first
See reviews.llvm.org/M1 for evaluation, and
lists.llvm.org/pipermail/cfe-dev/2018-January/056718.html for
discussion.
Differential Revision: https://reviews.llvm.org/D42775
llvm-svn: 324956
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/exploration_order/prefer_unexplored.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/Analysis/exploration_order/prefer_unexplored.cc b/clang/test/Analysis/exploration_order/prefer_unexplored.cc new file mode 100644 index 00000000000..e9f25edf459 --- /dev/null +++ b/clang/test/Analysis/exploration_order/prefer_unexplored.cc @@ -0,0 +1,39 @@ +// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-config exploration_strategy=unexplored_first -analyzer-output=text -verify %s | FileCheck %s + +extern int coin(); + +int foo() { + int *x = 0; // expected-note {{'x' initialized to a null pointer value}} + while (coin()) { // expected-note{{Loop condition is true}} + if (coin()) // expected-note {{Taking true branch}} + return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} + // expected-note@-1{{Dereference of null pointer (loaded from variable 'x')}} + } + return 0; +} + +void bar() { + while(coin()) // expected-note{{Loop condition is true}} + if (coin()) // expected-note {{Assuming the condition is true}} + foo(); // expected-note{{Calling 'foo'}} +} + +int foo2() { + int *x = 0; // expected-note {{'x' initialized to a null pointer value}} + while (coin()) { // expected-note{{Loop condition is true}} + if (coin()) // expected-note {{Taking false branch}} + return false; + else + return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} + // expected-note@-1{{Dereference of null pointer (loaded from variable 'x')}} + } + return 0; +} + +void bar2() { + while(coin()) // expected-note{{Loop condition is true}} + if (coin()) // expected-note {{Assuming the condition is false}} + return false; + else + foo(); // expected-note{{Calling 'foo'}} +} |

