Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / max-nodes-suppress-on-sink.cpp
blob814b302789d95ced6532ac2a06a5893b1f94873a
1 // RUN: %clang_analyze_cc1 -x c++ -fcxx-exceptions -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config max-nodes=12 -verify %s
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.
7 typedef __typeof(sizeof(int)) size_t;
8 void *malloc(size_t);
10 void clang_analyzer_warnIfReached(void);
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
17 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
18 clang_analyzer_warnIfReached(); // no-warning
20 throw 0;
23 // FIXME: Handled throws shouldn't be suppressing us!
24 void test_handled_throw_treated_as_noreturn() {
25 void *p = malloc(1); // no-warning
27 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
28 clang_analyzer_warnIfReached(); // no-warning
30 try {
31 throw 0;
32 } catch (int i) {