[clang] [clang] Implement -fstrict-bool (PR #160790)
Bruno De Fraine via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 27 05:50:31 PDT 2025
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/160790 at github.com>
================
@@ -2198,8 +2211,16 @@ llvm::Value *CodeGenFunction::EmitFromMemory(llvm::Value *Value, QualType Ty) {
}
llvm::Type *ResTy = ConvertType(Ty);
- if (Ty->hasBooleanRepresentation() || Ty->isBitIntType() ||
- Ty->isExtVectorBoolType())
+ bool IsBitInt = Ty->isBitIntType();
+ bool HasBoolRep = Ty->hasBooleanRepresentation();
+ if (HasBoolRep && !IsBitInt &&
----------------
brunodf-snps wrote:
Since there is [0,2) range information today for types that have `hasBooleanRepresentation()` and not `isVectorType()` (see [this line](https://github.com/llvm/llvm-project/blob/cb59da20a645bcb663a8d9cc7225b94f13d03916/clang/lib/CodeGen/CGExpr.cpp#L2017)) and you will suppress this range information for all such types in case of -fno-strict-bool, I would suggest that you change the truncate in a non-zero check under exactly those same conditions when -fno-strict-bool=nonzero, does that make sense? This will include `BitInt(1)`.
https://github.com/llvm/llvm-project/pull/160790
More information about the cfe-commits
mailing list