[clang] [clang] Fix handling of asm string literals (PR #169803)
Abhina Sree via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 11:03:52 PST 2026
================
@@ -260,6 +276,31 @@ ExprResult Sema::ActOnGCCAsmStmtString(Expr *Expr, bool ForAsmLabel) {
Diag(Expr->getBeginLoc(), diag::err_asm_operand_empty_string);
}
+ // The evaluated string is in the literal encoding (-fexec-charset).
+ // Convert it back to UTF-8
+ if (llvm::TextEncodingConverter *FromLiteral =
+ PP.getTextEncoding().getFromLiteralEncodingConverter()) {
+ unsigned Size = V.getArraySize();
+ std::string Raw;
+ Raw.reserve(Size);
+ for (unsigned I = 0; I < Size; ++I)
+ Raw.push_back(static_cast<char>(
+ V.getArrayInitializedElt(I).getInt().getExtValue()));
----------------
abhina-sree wrote:
thanks this is done
https://github.com/llvm/llvm-project/pull/169803
More information about the cfe-commits
mailing list