[clang] [clang] Implement -fstrict-bool (PR #160790)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 05:29:44 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:

Oops, I spoke too soon.

> 75502309+apple-fcloutier at users.noreply.github.com

@apple-fcloutier we ask for public emails when landing changes as part of our developer policy: https://llvm.org/docs/DeveloperPolicy.html#email-addresses

Would you mind making your email public? I'll wait for the ObjC test coverage as well since we're already waiting a bit.

https://github.com/llvm/llvm-project/pull/160790


More information about the cfe-commits mailing list