[clang] [llvm] Enable fexec-charset option (PR #138895)

Abhina Sree via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 05:37:48 PST 2026


================
@@ -367,6 +373,25 @@ static unsigned ProcessCharEscape(const char *ThisTokBegin,
     HadError = true;
   }
 
+  if (Transcode && Converter) {
+    // Invalid escapes are written as '?' and then translated.
+    char ByteChar = Invalid ? '?' : ResultChar;
+    SmallString<8> ResultCharConv;
+    std::error_code EC =
+        Converter->convert(StringRef(&ByteChar, 1), ResultCharConv);
+    if (EC) {
+      Diag(Diags, Features, Loc, ThisTokBegin, EscapeBegin, ThisTokBuf,
+           diag::err_exec_charset_conversion_failed)
+          << EC.message();
+      HadError = true;
+    } else {
+      if (ResultCharConv.size() > 1)
+        Diag(Diags, Features, Loc, ThisTokBegin, EscapeBegin, ThisTokBuf,
+             diag::err_char_size_increased_after_conversion)
+            << ByteChar;
+      ResultChar = ResultCharConv[0];
----------------
abhina-sree wrote:

Thanks, I've moved this to a function called convertCharacter

https://github.com/llvm/llvm-project/pull/138895


More information about the cfe-commits mailing list