[RFC] new format string attributes

Hey guys,

I'd like to add an extension to Clang's format string checking, as well as extend the format string attributes to add UTF-16 (u) and UTF-32 (U) length modifiers to the c, C, s, and S type specifiers.

I've chosen lower case and upper case u to match the C and C++ standards for string literal specifiers, u"" and U"" telling the compiler to create a UTF-16 and UTF-32 string literals respectively.

as for the function attributes, my plan is to create uprintf and Uprintf arguments to the gcc style attributes e.g. __attribute__(__format__(uprintf)) and __attribute__(__format__(Uprintf))

I've chosen uprintf and Uprintf to match C and C++'s string type indicators as well, though it might be a better idea to go with u16printf and u32printf to match C++'s u16string and u32string types?

Hi,

did you see my post : http://lists.llvm.org/pipermail/cfe-dev/2020-March/064945.html ?

Also, I don't think there is a way to printf a utf16 string if not compiled with -fshort-wchar and viceversa. So I like your idea of havind a %us and %Us (same for %c). It's missing.

u16printf (and u16sprintf, etc.) would output in a utf16 string and u32printf would output a utf32 ? Great. Maybe we should add a utf8printf that use the new format ?

If you liked my post, it'll be great to have the compiler to be able to adapt the format litteral depending of the arguments, so we can just put %s, %c, %d for all types of strings, chars and integer, compiler adding the format attribute in the litteral as needed.

Jief