This patch adds support for C++20 char8_t.
Original patch by James Blachly [1], modified by me.
[1] http://lists.llvm.org/pipermail/lldb-dev/2019-August/015393.html
Differential D66447
Add char8_t support (C++20) JDevlieghere on Aug 19 2019, 3:13 PM. Authored by
Details
This patch adds support for C++20 char8_t. Original patch by James Blachly [1], modified by me. [1] http://lists.llvm.org/pipermail/lldb-dev/2019-August/015393.html
Diff Detail Event Timeline
Comment Actions Thank you for creating a revision and reviewing this. I made inline comments on the test harness and Dlang types / qualifiers. With removal of the Dlang types, where is the appropriate place to put them? Thanks again
Comment Actions Thanks James. I removed the DLang part from this patch because it's orthogonal to the char8_t support. The changes might be fine but they really should have their own differential and test. I'll try to put up another patch later today if I find the time. Comment Actions This looks good to me, but why are we using a nul character to test utf8 support? Shouldn't we insert some funnier characters too? I mean, one of the advantages of unicode is that it should not be affected by the system code pages and such, so hopefully this would not cause problems even on some more exotic setups. (And I am pretty sure I remember already seeing some chinese chars in some of our data formatter tests)
Comment Actions I only glanced at the proposal, but unless I misunderstand the type only fits UTF-8 characters representable in 1 byte, which are basically just ASCII. Comment Actions I have now too glanced at the proposal (just the cppreference page, really :) ). I think I understand where you got this impression from, but I don't think that is fully correct. It is true that a *single* char8_t variable can hold only 8 bit UTF8 code units (*not* characters), but that is not surprising since UTF8 is a variable length encoding, so you can't have a type that matches one character exactly. However, an *array* of char8_t is a completely different thing, and I am pretty sure that these are intended to hold utf8 strings containing any utf8 characters (otherwise, it wouldn't really deserve to call itself a utf8 type), and so we should print (and test) it as regular utf8. However, this actually surfaces the question of how should we format single char8_t variables. It makes sense to display the character value if the value happens to be ASCII, but I guess we shouldn't print something like "invalid utf8 character" if it does contain one unit of the multibyte characters. Comment Actions Sounds like I simply misunderstood your earlier comment. I thought you meant putting a full UTF-8 *character* in a `char8_t.
What about the current implementation that prints both the hex and the ASCII value? Comment Actions You may find the the C++ Evolution Working Groups entry on [N4197 Adding u8 character literals, [tiny] Why no u8 character literals?](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4540.html#119) and the proposal that add char8_t helpful in understanding the rationale and the proposal for char8_t runs through a lot of examples. Comment Actions I changed the test to use frame variable again. With target variable the UTF-8 formatting doesn't work. Given that this patch just copies the Char16 and Char32 implementation, I think that's something for a different patch. I'll file a PR when this gets in. (lldb) target variable ab (const char8_t *) ab = 0x0000000100000fa6 (lldb) target variable abc (char8_t [9]) abc = { [0] = 0xe4 u8' [1] = 0xbd u8'' [2] = 0xa0 u8'' [3] = 0xe5 u8' [4] = 0xa5 u8'' [5] = 0xbd u8'' [6] = 0x00 u8'\0' [7] = 0x00 u8'\0' [8] = 0x00 u8'\0' } Comment Actions Ah yes, I can see how that request could have been interpreted this way. I'm glad that we understand each other.
I think that's fine. lgtm. Comment Actions A couple inline comments. I think this is looking pretty good.
|
add to the end, or all LLDBRPC.framework calls that use this enumeration will fail for you.