[clang] [Clang][Sema] Add fortify warnings for poll, ppoll, and ppoll64 (PR #226261)

via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 26 00:46:13 PDT 2026


================
@@ -306,6 +320,33 @@ void call_recv_runtime(int fd, int n) {
   recvfrom(fd, buf, n, 0, (struct sockaddr *)0, 0);
 }
 
+void call_poll(void) {
+  struct pollfd fds[2];
+  struct pollfd single_fd;
+  poll(fds, 2, 0);
+  poll(fds, 3, 0); // expected-warning {{'poll' size argument is too large; destination buffer has size 16, but size argument is 24}}
+  poll(fds, -1, 0); // expected-warning {{'poll' size argument is too large; destination buffer has size 16, but size argument is }}
----------------
Expertcoderz wrote:

> Use the (sadly, undocumented) `expected-warning-re`? You can find examples throughout clang/test/ using this.

Regex matching appears to be somewhat documented in the internals manual: https://clang.llvm.org/docs/InternalsManual.html#diagnostic-text

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


More information about the cfe-commits mailing list