Skip to content

Commit b0d937c

Browse files
committed
[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.
1 parent ed33690 commit b0d937c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/lib/CIR/CodeGen/Address.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class Address {
4444
clang::CharUnits alignment)
4545
: pointerAndKnownNonNull(pointer, false), elementType(elementType),
4646
alignment(alignment) {
47-
assert(mlir::isa<cir::PointerType>(pointer.getType()) &&
48-
"Expected cir.ptr type");
49-
5047
assert(pointer && "Pointer cannot be null");
5148
assert(elementType && "Element type cannot be null");
5249
assert(!alignment.isZero() && "Alignment cannot be zero");
5350

51+
assert(mlir::isa<cir::PointerType>(pointer.getType()) &&
52+
"Expected cir.ptr type");
53+
5454
assert(mlir::cast<cir::PointerType>(pointer.getType()).getPointee() ==
5555
elementType);
5656
}

0 commit comments

Comments
 (0)