[clang] [Clang SA]: add support for mismatched ownership_returns+ownership_takes calls for custom allocation classes (PR #98941)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 16 23:45:32 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);
----------------
steakhal wrote:
What happens if you have a forward declaration to a malloc function without the attribute, then later have another redeclaration with the `ownership_returns` attribute?
A similar case to test would be the opposite: 1st declaration has the attribute, the second redeclaration would not have the attribute.
I suspect that the FunctionDecl of the callees will refer to the last seen declaration of the function, thus, will not recognize the attribute for the second case I mentioned here.
Could you test these cases?
https://github.com/llvm/llvm-project/pull/98941
More information about the cfe-commits
mailing list