brintos

brintos / llvm-project-archived public Read only

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