================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to