| 1 |
// RUN: %clang_analyze_cc1 -fexceptions -fobjc-exceptions -fcxx-exceptions -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s |
| 2 |
|
| 3 |
void clang_analyzer_checkInlined(bool); |
| 4 |
|
| 5 |
typedef typeof(sizeof(int)) size_t; |
| 6 |
void *malloc(size_t); |
| 7 |
void free(void *); |
| 8 |
|
| 9 |
|
| 10 |
id getException(); |
| 11 |
void inlinedObjC() { |
| 12 |
clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} |
| 13 |
@throw getException(); |
| 14 |
} |
| 15 |
|
| 16 |
int testObjC() { |
| 17 |
int a; // uninitialized |
| 18 |
void *mem = malloc(4); // no-warning (ObjC exceptions are usually fatal) |
| 19 |
inlinedObjC(); |
| 20 |
free(mem); |
| 21 |
return a; // no-warning |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
void inlinedCXX() { |
| 26 |
clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} |
| 27 |
throw -1; |
| 28 |
} |
| 29 |
|
| 30 |
int testCXX() { |
| 31 |
int a; // uninitialized |
| 32 |
// FIXME: this should be reported as a leak, because C++ exceptions are |
| 33 |
// often not fatal. |
| 34 |
void *mem = malloc(4); |
| 35 |
inlinedCXX(); |
| 36 |
free(mem); |
| 37 |
return a; // no-warning |
| 38 |
} |