brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 2239b37 Raw
41 lines · c
1// RUN: %clang_analyze_cc1 %s \2// RUN:   -analyzer-checker=core \3// RUN:   -analyzer-checker=debug.ExprInspection \4// RUN:   -analyzer-config eagerly-assume=false \5// RUN:   -verify6 7void clang_analyzer_warnIfReached(void);8void clang_analyzer_eval(_Bool);9 10void test_simplification_to_concrete_int_infeasible(int b, int c) {11  if (c + b != 0)     // c + b == 012    return;13  if (b != 1)         // b == 1  --> c + 1 == 014    return;15  if (c != 1)         // c == 1  --> 1 + 1 == 0 contradiction16    return;17  clang_analyzer_warnIfReached(); // no-warning18 19  // Keep the symbols and the constraints! alive.20  (void)(b * c);21  return;22}23 24void test_simplification_to_concrete_int_feasible(int b, int c) {25  if (c + b != 0)26    return;27                      // c + b == 028  if (b != 1)29    return;30                      // b == 1   -->  c + 1 == 031  if (c != -1)32    return;33                      // c == -1  --> -1 + 1 == 0 OK34  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}35  clang_analyzer_eval(c == -1);   // expected-warning{{TRUE}}36 37  // Keep the symbols and the constraints! alive.38  (void)(b * c);39  return;40}41