[RFC] new format string attributes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFC] new format string attributes

suyash singh via cfe-dev
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?
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] new format string attributes

suyash singh via cfe-dev
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

On 24.03.20 03:28, Marcus Johnson via cfe-dev wrote:

> 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?
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev