[clang] [clang] Implement -fstrict-bool (PR #160790)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 21 05:27:46 PDT 2026
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?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>
================
@@ -1236,7 +1236,12 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
uint64_t retTySize = CGM.getDataLayout().getTypeSizeInBits(retTy);
if (ivarSize > retTySize) {
bitcastType = llvm::Type::getIntNTy(getLLVMContext(), retTySize);
- ivarVal = Builder.CreateTrunc(ivarVal, bitcastType);
+ if (getterMethod->getReturnType()->hasBooleanRepresentation() &&
+ CGM.getCodeGenOpts().isConvertingBoolWithCmp0())
+ ivarVal = Builder.CreateICmpNE(
+ ivarVal, llvm::Constant::getNullValue(ivarVal->getType()));
+ else
+ ivarVal = Builder.CreateTrunc(ivarVal, bitcastType);
----------------
AaronBallman wrote:
I think it would be good to add the test coverage, but I'm going to land the changes on behalf of @apple-fcloutier so there's not another round of rebasing needed; I'm happy to land the test as an NFC patch on top of this one.
https://github.com/llvm/llvm-project/pull/160790
More information about the cfe-commits
mailing list