[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
Wed Jul 17 04:40:54 PDT 2024
================
@@ -60,6 +67,41 @@ void testMalloc8() {
operator delete[](p); // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not operator delete[]}}
}
+void testMalloc9() {
+ int *p = (int *)my_malloc(sizeof(int));
+ my_free(p); // no warning
+}
+
+void testMalloc10() {
+ int *p = (int *)my_malloc1(sizeof(int));
+ my_free1(p); // no warning
+}
+
+void testMalloc11() {
+ int *p = (int *)my_malloc2(sizeof(int));
+ my_free23(p); // no warning
+}
+
+void testMalloc12() {
+ int *p = (int *)my_malloc1(sizeof(int));
+ my_free(p); // expected-warning{{Memory allocated by my_malloc1() should be deallocated by function that takes ownership of 'malloc1', not my_free(), which takes ownership of 'malloc'}}
----------------
steakhal wrote:
Ah, I see. The phrasing wasn't clear to me. Maybe because we don't have a clear spec for this attribute, thus it's difficult to make out things that have special meaning.
I think we should quote function names, yes.
https://github.com/llvm/llvm-project/pull/98941
More information about the cfe-commits
mailing list