[clang] [clang][Sema] Stop format size estimator upon %p to adapt to linux kernel's extension (PR #65969)

Nick Desaulniers via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 09:23:17 PDT 2023


nickdesaulniers wrote:

> Is there some way we can narrow the scope of this patch so we don't lose warnings for normal `snprintf`s, only for the kernel one? If we really can't tell the difference from the source code, we could move the affected warnings to a different warning group instead, so the kernel can turn them off.

@zygoloid is this approach acceptable?

One thing I do worry about not having an explicit flag; we support clang-11+ for building the Linux kernel.

Let's say the kernel adds a new extension format specifiers `%pn`.  We need to fix up clang to recognize that now, too.  Then we fix clang in say clang-19.  clang-18 still warns and we can't turn it off.

Perhaps it would be better to have the flag to disable `%p` without disabling the rest of `-Wfortify-source`, than try to keep these two in sync.

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


More information about the cfe-commits mailing list