[cfe-dev] Clang's string type?

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Thu Aug 23 14:35:21 PDT 2018


On 8/23/2018 12:53 PM, Marcus Johnson via cfe-dev wrote:
> I was looking over the code for Clang's format specifier checking 
> (Primarily the FormatStringHandler class) and I noticed that the issue 
> is that everything is built on standard C strings.
>
> Does Clang/LLVM even have a string class that supports Unicode (at 
> least UTF-16, and hopefully UTF-32)?

Not specifically.  You can use ArrayRef/SmallVector to store "strings" 
if necessary.  And include/llvm/Support/ConvertUTF.h has conversions.

> In order to support wprintf, we'd have to support UTF-16 in the API, 
> which would amount to a massive patch set for pretty much everything.

I don't follow; can't you just convert the format string from 
UTF-16/UTF-32 to UTF-8 before checking it?  (Granted, that's not 
particularly efficient, but it's rare enough that it probably doesn't 
matter.)

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180823/d016d73a/attachment.html>


More information about the cfe-dev mailing list