[cfe-dev] [PATCH] Let __attribute__((format(…))) accept OFStrings

Jonathan Schleifer js at webkeks.org
Wed Nov 27 08:03:16 PST 2013


Am 27.11.2013 um 16:58 schrieb Jean-Daniel Dupas <devlists at shadowlab.org>:

> Having a custom type is meaningless if clang can't interpret it as a literal string at compile time, as it would not be able to check the format argument.
> How are you planning to tell clang how to interpret a custom type into a string literal ?

You are right. You would need to tell it that it should have e.g. printf syntax, but accept a constant objc string whose type you give (Clang can always interpret it if it generates that constant string anyway). So maybe more like this:

#pragma clang format type(__OFString__, printf, OFString)

Then Clang would accept an OFString* and subclasses (like OFConstantString*) and Clang is able to interpret it (it can generate it after all and with my patch before, it could also handle it - the only difference is that it wouldn't be hardcoded). After that, new format specifiers / length modifiers could be added to that new format string type without modifying what printf accepts.

--
Jonathan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131127/48f738bb/attachment.sig>


More information about the cfe-dev mailing list