[RFC] format attribute support for non-builtin types?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[RFC] format attribute support for non-builtin types?

Vassil Vassilev via cfe-dev
I want to extend Clang's FormatStringLiteral class in Sema to support char16_t, char32_t, and wchar_t in not just C++, but C as well.




C++ has char16_t and char32_t as builtin types, and as of C++20 char8_t is a builtin type as well.

the problem is that C does not have char16_t and char32_t as builtin types.

in C, char16_t and char32_t are `#define'd` in the <uchar.h> header to be uint_least16_t and uint_least32_t types, which is usually defined to be unsigned short and unsigned int, but it depends on the platform.

but the real underlying problem is that Clang's Sema currently only supports builtin types in the FormatStringLiteral class.

So, a solution to this problem is we can allow any user provided type to work with FormatStringLiteral, but that is probably not the best solution.

another solution is to traverse the AST to check if the underlying type is simply a null terminated array of basic types char, short, or int.

but I still think that leaves a lot of room for ambiguity.

is there a better way, where we can canonize certain typedefs as valid character types, and have FormatStringLiteral accept only C++'s builtins and these canonized types?
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev