[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / malloc-bodyfarms.c
blobc613a6f52dbc954c8daf66b79657d4b8f53c6ec4
1 // RUN: %clang_analyze_cc1 -fblocks -analyzer-checker core,unix -verify %s
3 typedef __typeof(sizeof(int)) size_t;
4 void *calloc(size_t, size_t);
6 typedef struct dispatch_queue_s *dispatch_queue_t;
7 typedef void (^dispatch_block_t)(void);
8 void dispatch_sync(dispatch_queue_t, dispatch_block_t);
10 void test_no_state_change_in_body_farm(dispatch_queue_t queue) {
11 dispatch_sync(queue, ^{}); // no-crash
12 calloc(1, 1);
13 } // expected-warning{{Potential memory leak}}
15 void test_no_state_change_in_body_farm_2(dispatch_queue_t queue) {
16 void *p = calloc(1, 1);
17 dispatch_sync(queue, ^{}); // no-crash
18 p = 0;
19 } // expected-warning{{Potential leak of memory pointed to by 'p'}}