brintos

brintos / llvm-project-archived public Read only

0
0
Text · 944 B · e38433e Raw
23 lines · cpp
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 %s2 3void clang_analyzer_eval(bool);4 5typedef __typeof__(sizeof(int)) size_t;6 7void *malloc(size_t size);8 9void *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 18void 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'}}23