[PATCH] Add FreeBSD kernel printf extensions

Dimitry Andric dimitry at andric.com
Fri Jan 23 13:31:07 PST 2015

Hi rsmith, aaron.ballman, hans, joerg,

In FreeBSD, we have been carrying around a custom patch for clang, since about four and a half years, to enable checking the FreeBSD kernel specific printf format specifiers: %b, %D, %r and %y.  This patch was based on an earlier custom patch for gcc, with similar functionality, and it added a new -fformat-extensions option to enable those non-standard specifiers.

A few years ago we tried getting this patch upstreamed to llvm/clang, but it was not met with great enthusiasm.  I think this was mostly because adding an option was seen as ugly, and even then, the option name did not convey that it was specifically meant for FreeBSD only.

I have now tried to massage the patch so that it is hopefully more palatable:
* It adds a new __freebsd_kprintf__ format string type, which enables checking when used in __attribute__((format(...))) attributes
* Checks %b, %D, %r and %y specifiers, using existing diagnostic messages
* Adds test cases for all these specifiers

Now, I know the printf format checking might be due for a big overhaul, and this patch is not the prettiest around, but please consider that it implements functionality that we really need, and use.  So I would rather get this in, and have it be part of some later restructuring, instead of having to forward-port it each new release... :)



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7154.18692.patch
Type: text/x-patch
Size: 15897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150123/25fcf5c7/attachment.bin>

More information about the cfe-commits mailing list