From bf65be5cea5c4499c62f5e1cb896c0f5d2592030 Mon Sep 17 00:00:00 2001 From: Peter McNeeley Date: Thu, 3 Jul 2025 11:15:26 -0400 Subject: [PATCH 1/2] Minor fix for signedness of asuint bitcast --- tools/clang/lib/AST/ExprConstant.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/clang/lib/AST/ExprConstant.cpp b/tools/clang/lib/AST/ExprConstant.cpp index c24e44022f..2c61440759 100644 --- a/tools/clang/lib/AST/ExprConstant.cpp +++ b/tools/clang/lib/AST/ExprConstant.cpp @@ -3784,6 +3784,9 @@ static bool HandleIntrinsicCall(SourceLocation CallLoc, unsigned opcode, assert(Args.size() == 1 && "else call should be invalid"); if (ArgValues[0].isInt()) { Result = ArgValues[0]; + // The result of bitwise cast to uint will be unsigned. + const bool isUnsignedTrue = true; + Result.getInt().setIsSigned(!isUnsignedTrue); } else if (ArgValues[0].isFloat()) { const bool isUnsignedTrue = true; From 21d48598c48725650eb84f7db04fd1de3f66eda2 Mon Sep 17 00:00:00 2001 From: Peter McNeeley Date: Thu, 3 Jul 2025 11:29:50 -0400 Subject: [PATCH 2/2] Cleaner without the constant --- tools/clang/lib/AST/ExprConstant.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/clang/lib/AST/ExprConstant.cpp b/tools/clang/lib/AST/ExprConstant.cpp index 2c61440759..fae94fbc96 100644 --- a/tools/clang/lib/AST/ExprConstant.cpp +++ b/tools/clang/lib/AST/ExprConstant.cpp @@ -3785,8 +3785,7 @@ static bool HandleIntrinsicCall(SourceLocation CallLoc, unsigned opcode, if (ArgValues[0].isInt()) { Result = ArgValues[0]; // The result of bitwise cast to uint will be unsigned. - const bool isUnsignedTrue = true; - Result.getInt().setIsSigned(!isUnsignedTrue); + Result.getInt().setIsSigned(false); } else if (ArgValues[0].isFloat()) { const bool isUnsignedTrue = true;