================
@@ -35,3 +35,19 @@ void leak_through_cleanup_frame(void) {
   p = malloc(10); // expected-note {{Memory is allocated}}
 } // expected-warning {{Potential leak of memory pointed to by 'p'}}
   // expected-note@-1 {{Potential leak of memory pointed to by 'p'}}
+
+//===----------------------------------------------------------------------===//
+// With the attribute split across lines, the "Calling ..." note is anchored
+// at the `cleanup` keyword, not at the function name on the next line.
+//===----------------------------------------------------------------------===//
+
+static void multiline_cleanup(int **p) {
+  **p = 1; // expected-warning {{Dereference of null pointer}}
+           // expected-note@-1 {{Dereference of null pointer}}
+}
+
+void null_deref_in_multiline_cleanup_attr(void) {
+  int *p __attribute__((cleanup( // expected-note {{Calling 
'multiline_cleanup'}}
+      multiline_cleanup)));
+  p = 0; // expected-note {{Null pointer value stored to 'p'}}
+}
----------------
necto wrote:

I read "multiple_cleanup" as it either cleans up multiple resources, or there 
are multiple clean up functions. here I guess it should actually mean that the 
attribute is split into multiple lines

https://github.com/llvm/llvm-project/pull/221110
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to