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 | return x; |
15 | } |
16 | |
17 | void checkNewAndConstructorInlining() { |
18 | int *s = new int; // expected-note {{Calling 'operator new'}} |
19 | // expected-note@-1{{Returning from 'operator new'}} |
20 | } // expected-warning {{Potential leak of memory pointed to by 's'}} |
21 | // expected-note@-1 {{Potential leak of memory pointed to by 's'}} |
22 | |