[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / malloc-bodyfarms.cpp
blobf09b2fef9b5a78ca9bdf7be48b9b30d15d346dce
1 // RUN: %clang_analyze_cc1 -fblocks -analyzer-checker core,unix -verify %s
3 namespace std {
4 typedef struct once_flag_s {
5 int _M_once = 0;
6 } once_flag;
8 template <class Callable, class... Args>
9 void call_once(once_flag &o, Callable&& func, Args&&... args);
10 } // namespace std
12 typedef __typeof(sizeof(int)) size_t;
13 void *malloc(size_t);
15 void callee() {}
17 void test_no_state_change_in_body_farm() {
18 std::once_flag flag;
19 call_once(flag, callee); // no-crash
20 malloc(1);
21 } // expected-warning{{Potential memory leak}}
23 void test_no_state_change_in_body_farm_2() {
24 void *p = malloc(1);
25 std::once_flag flag;
26 call_once(flag, callee); // no-crash
27 p = 0;
28 } // expected-warning{{Potential leak of memory pointed to by 'p'}}