1 | // RUN: %clang_analyze_cc1 -x c++ -fcxx-exceptions -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config max-nodes=12 -verify %s |
2 | |
3 | // Here we test how "suppress on sink" feature of certain bugtypes interacts |
4 | // with reaching analysis limits. See comments in max-nodes-suppress-on-sink.c |
5 | // for more discussion. |
6 | |
7 | typedef __typeof(sizeof(int)) size_t; |
8 | void *malloc(size_t); |
9 | |
10 | void clang_analyzer_warnIfReached(void); |
11 | |
12 | // Because we don't have a better approach, we currently treat throw as |
13 | // noreturn. |
14 | void test_throw_treated_as_noreturn() { |
15 | void *p = malloc(1); // no-warning |
16 | |
17 | clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} |
18 | clang_analyzer_warnIfReached(); // no-warning |
19 | |
20 | throw 0; |
21 | } |
22 | |
23 | // FIXME: Handled throws shouldn't be suppressing us! |
24 | void test_handled_throw_treated_as_noreturn() { |
25 | void *p = malloc(1); // no-warning |
26 | |
27 | clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}} |
28 | clang_analyzer_warnIfReached(); // no-warning |
29 | |
30 | try { |
31 | throw 0; |
32 | } catch (int i) { |
33 | } |
34 | } |
35 | |