| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection,unix.Malloc -analyzer-config c++-allocator-inlining=true -analyzer-output=text -std=c++11 -verify %s |
| 2 |
|
| 3 |
void clang_analyzer_eval(bool); |
| 4 |
|
| 5 |
typedef __typeof__(sizeof(int)) size_t; |
| 6 |
|
| 7 |
void *malloc(size_t size); |
| 8 |
|
| 9 |
void *operator new(size_t size) throw() { |
| 10 |
void *x = malloc(size); // expected-note {{Memory is allocated}} |
| 11 |
if (!x) // expected-note {{Assuming 'x' is non-null}} |
| 12 |
// expected-note@-1 {{Taking false branch}} |
| 13 |
return nullptr; |
| 14 |
// expected-warning@-1 {{null returned from function that requires a non-null return value}} |
| 15 |
return x; |
| 16 |
} |
| 17 |
|
| 18 |
void checkNewAndConstructorInlining() { |
| 19 |
int *s = new int; // expected-note {{Calling 'operator new'}} |
| 20 |
// expected-note@-1{{Returning from 'operator new'}} |
| 21 |
} // expected-warning {{Potential leak of memory pointed to by 's'}} |
| 22 |
// expected-note@-1 {{Potential leak of memory pointed to by 's'}} |