We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0392ef9 commit ca8dfa9Copy full SHA for ca8dfa9
clang/docs/analyzer/checkers/mismatched_deallocator_example.cpp
@@ -6,6 +6,10 @@ void test() {
6
7
// C, C++
8
void __attribute((ownership_returns(malloc))) *user_malloc(size_t);
9
+void __attribute((ownership_takes(malloc, 1))) *user_free(void *);
10
+
11
+void __attribute((ownership_returns(malloc1))) *user_malloc1(size_t);
12
+void __attribute((ownership_takes(malloc1, 1))) *user_free1(void *);
13
14
void test() {
15
int *p = (int *)user_malloc(sizeof(int));
@@ -24,6 +28,12 @@ void test() {
24
28
realloc(p, sizeof(long)); // warn
25
29
}
26
30
31
+// C, C++
32
+void test() {
33
+ int *p = user_malloc(10);
34
+ user_free1(p); // warn
35
+}
36
27
37
38
template <typename T>
39
struct SimpleSmartPointer {
0 commit comments