1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-output text -verify %s 2 3 typedef __typeof(sizeof(int)) size_t; 4 void *malloc(size_t size); 5 6 void inf_loop_break_callee() { 7 void* data = malloc(10); // expected-note{{Memory is allocated}} 8 while (1) { // expected-note{{Loop condition is true}} 9 (void)data; 10 break; // No note that we jump to the line above from this break 11 } // expected-note@-1{{Execution jumps to the end of the function}} 12 } // expected-warning{{Potential leak of memory pointed to by 'data'}} 13 // expected-note@-1 {{Potential leak of memory pointed to by 'data'}} 14 15 void inf_loop_break_caller() { 16 inf_loop_break_callee(); // expected-note{{Calling 'inf_loop_break_callee'}} 17 } 18 19 void inf_loop_break_top() { 20 void* data = malloc(10); // expected-note{{Memory is allocated}} 21 while (1) { // expected-note{{Loop condition is true}} 22 (void)data; 23 break; // No note that we jump to the line above from this break 24 } // expected-note@-1{{Execution jumps to the end of the function}} 25 } // expected-warning{{Potential leak of memory pointed to by 'data'}} 26 // expected-note@-1 {{Potential leak of memory pointed to by 'data'}} 27