Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Analysis / builtin_overflow_notes.c
blob20f333a4a6cca56ab4461d7e63cab9e774047273
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output text \
2 // RUN: -verify %s
4 void test_no_overflow_note(int a, int b)
6 int res;
8 if (__builtin_add_overflow(a, b, &res)) // expected-note {{Assuming no overflow}}
9 // expected-note@-1 {{Taking false branch}}
10 return;
12 if (res) { // expected-note {{Assuming 'res' is not equal to 0}}
13 // expected-note@-1 {{Taking true branch}}
14 int *ptr = 0; // expected-note {{'ptr' initialized to a null pointer value}}
15 int var = *(int *) ptr; //expected-warning {{Dereference of null pointer}}
16 //expected-note@-1 {{Dereference of null pointer}}
20 void test_overflow_note(int a, int b)
22 int res; // expected-note{{'res' declared without an initial value}}
24 if (__builtin_add_overflow(a, b, &res)) { // expected-note {{Assuming overflow}}
25 // expected-note@-1 {{Taking true branch}}
26 int var = res; // expected-warning{{Assigned value is garbage or undefined}}
27 // expected-note@-1 {{Assigned value is garbage or undefined}}
28 return;