Author: Nikita Popov Date: 2025-12-17T12:48:50+01:00 New Revision: 30ce1e9c7a507f188b34948daef6e2aa799f6e5c
URL: https://github.com/llvm/llvm-project/commit/30ce1e9c7a507f188b34948daef6e2aa799f6e5c DIFF: https://github.com/llvm/llvm-project/commit/30ce1e9c7a507f188b34948daef6e2aa799f6e5c.diff LOG: [CGExprScalar] Allow implicit truncation for CharacterLiteral The value is always stored as an unsigned number, even if the char type is signed, so we have to allow truncation here. Added: Modified: clang/lib/CodeGen/CGExprScalar.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 96274cf7f8220..b4daaef95bb8d 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -510,7 +510,10 @@ class ScalarExprEmitter return llvm::ConstantFP::get(VMContext, E->getValue()); } Value *VisitCharacterLiteral(const CharacterLiteral *E) { - return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue()); + // Character literals are always stored in an unsigned (even for signed + // char), so allow implicit truncation here. + return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue(), + /*IsSigned=*/false, /*ImplicitTrunc=*/true); } Value *VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E) { return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue()); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
