[clang] [Clang SA]: add support for mismatched ownership_returns+ownership_takes calls for custom allocation classes (PR #98941)

Pavel Skripkin via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 00:57:34 PDT 2024


================
@@ -14,6 +14,13 @@
 void free(void *);
 void __attribute((ownership_takes(malloc, 1))) my_free(void *);
 
+void __attribute((ownership_returns(malloc1))) *my_malloc1(size_t);
+void __attribute((ownership_takes(malloc1, 1))) my_free1(void *);
+
+void __attribute((ownership_returns(malloc2))) *my_malloc2(size_t);
+void __attribute((ownership_returns(malloc2))) *my_malloc3(size_t);
+void __attribute((ownership_takes(malloc2, 1))) __attribute((ownership_takes(malloc3, 1))) my_free23(void *);
----------------
pskrgag wrote:

I also find this quite strange, but can't say if there are any real-world examples of function that takes ownership of 2 different classes.

Maybe it would be better to just disallow 2 different classes?

https://github.com/llvm/llvm-project/pull/98941


More information about the cfe-commits mailing list