https://github.com/erichkeane created https://github.com/llvm/llvm-project/pull/157477
We are checking the 'type' of 'pointer' before we are checking whether it is null or not! This is clearly incorrect, so this patch reorders the asserts. >From b0d937cc90e9797094248a7df1f5c5d8b373c015 Mon Sep 17 00:00:00 2001 From: erichkeane <eke...@nvidia.com> Date: Mon, 8 Sep 2025 07:36:02 -0700 Subject: [PATCH] [CIR] Fix assertion order in 'Address' We are checking the 'type' of 'pointer' before we are checking whether it is null or not! This is clearly incorrect, so this patch reorders the asserts. --- clang/lib/CIR/CodeGen/Address.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/CIR/CodeGen/Address.h b/clang/lib/CIR/CodeGen/Address.h index a851d06321cc1..fb74aa0f3bb00 100644 --- a/clang/lib/CIR/CodeGen/Address.h +++ b/clang/lib/CIR/CodeGen/Address.h @@ -44,13 +44,13 @@ class Address { clang::CharUnits alignment) : pointerAndKnownNonNull(pointer, false), elementType(elementType), alignment(alignment) { - assert(mlir::isa<cir::PointerType>(pointer.getType()) && - "Expected cir.ptr type"); - assert(pointer && "Pointer cannot be null"); assert(elementType && "Element type cannot be null"); assert(!alignment.isZero() && "Alignment cannot be zero"); + assert(mlir::isa<cir::PointerType>(pointer.getType()) && + "Expected cir.ptr type"); + assert(mlir::cast<cir::PointerType>(pointer.getType()).getPointee() == elementType); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits