[clang] [llvm] Enable fexec-charset option (PR #138895)
Sergei Barannikov via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 30 07:51:15 PDT 2026
================
@@ -1854,23 +1892,60 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
HadError = true;
PP.Diag(Loc, diag::err_character_too_large);
}
+ if (!HadError && Converter) {
+ assert(isOrdinary() && "Only ordinary characters are supported");
+ std::string UTF8String;
+ convertUTF32ToUTF8String(
+ ArrayRef<char>(reinterpret_cast<const char *>(tmp_out_start),
+ 4),
+ UTF8String);
+ auto ErrorOrChar = convertCharacter(UTF8String, *Converter);
+ if (ErrorOrChar) {
+ *tmp_out_start = *ErrorOrChar;
+ } else {
+ HadError = true;
+ PP.Diag(Loc, diag::err_exec_charset_conversion_failed)
+ << ErrorOrChar.getError().message();
+ }
----------------
s-barannikov wrote:
I guess we use ConvertUTF8toUTF32 to get the value of a Unicode code point. Can we pass that value to a convertCharacter instead of UTF-8 string? Or better yet, to the converter class.
If iconv/icu don't support converting a single Unicode code point, we could convert it back to UTF-8 string internally and pass it to the library.
https://github.com/llvm/llvm-project/pull/138895
More information about the cfe-commits
mailing list