brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · c3fdfea Raw
48 lines · c
1// RUN: %clang_analyze_cc1 -w -analyzer-checker=core.DivideZero -analyzer-output=text -verify %s2 3// This test file verifies the "Assuming..." diagnostic pieces that are being4// reported when the branch condition was too complicated to explain.5// Therefore, if your change replaces the generic "Assuming the condition is6// true" with a more specific message, causing this test to fail, the condition7// should be replaced with a more complicated condition that we still cannot8// properly explain to the user. Once we reach the point at which all conditions9// are "diagnosable", this test (or this note) should probably be removed,10// together with the code section that handles generic messages for11// non-diagnosable conditions.12 13// Function calls are currently non-diagnosable.14int non_diagnosable(void);15 16void test_true(void) {17  if (non_diagnosable()) {18    // expected-note@-1{{Assuming the condition is true}}19    // expected-note@-2{{Taking true branch}}20    1 / 0;21    // expected-warning@-1{{Division by zero}}22    // expected-note@-2{{Division by zero}}23  }24}25 26void test_false(void) {27  if (non_diagnosable()) {28    // expected-note@-1{{Assuming the condition is false}}29    // expected-note@-2{{Taking false branch}}30  } else {31    1 / 0;32    // expected-warning@-1{{Division by zero}}33    // expected-note@-2{{Division by zero}}34  }35}36 37// Test that we're still reporting that the condition is true,38// when we encounter an exclamation mark (used to be broken).39void test_exclamation_mark(void) {40  if (!non_diagnosable()) {41    // expected-note@-1{{Assuming the condition is true}}42    // expected-note@-2{{Taking true branch}}43    1 / 0;44    // expected-warning@-1{{Division by zero}}45    // expected-note@-2{{Division by zero}}46  }47}48