https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/217583
We already assert Ptr.isBlockPointer() above. >From 2d022c793e28af926f13e993fcf696692f981e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Thu, 20 Aug 2026 12:46:38 +0200 Subject: [PATCH] [clang][bytecode][NFC] Remove useless if statement We already assert Ptr.isBlockPointer() above. --- clang/lib/AST/ByteCode/Interp.h | 34 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 9c90321da1c36..cdcd0b717b779 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -2609,27 +2609,25 @@ std::optional<Pointer> OffsetHelper(InterpState &S, CodePtr OpPC, Invalid = true; }; - if (Ptr.isBlockPointer()) { - uint64_t IOffset = static_cast<uint64_t>(Offset); - uint64_t MaxOffset = MaxIndex - Index; + uint64_t IOffset = static_cast<uint64_t>(Offset); + uint64_t MaxOffset = MaxIndex - Index; - if constexpr (Op == ArithOp::Add) { - // If the new offset would be negative, bail out. - if (Offset.isNegative() && (Offset.isMin() || -IOffset > Index)) - DiagInvalidOffset(); + if constexpr (Op == ArithOp::Add) { + // If the new offset would be negative, bail out. + if (Offset.isNegative() && (Offset.isMin() || -IOffset > Index)) + DiagInvalidOffset(); - // If the new offset would be out of bounds, bail out. - if (Offset.isPositive() && IOffset > MaxOffset) - DiagInvalidOffset(); - } else { - // If the new offset would be negative, bail out. - if (Offset.isPositive() && Index < IOffset) - DiagInvalidOffset(); + // If the new offset would be out of bounds, bail out. + if (Offset.isPositive() && IOffset > MaxOffset) + DiagInvalidOffset(); + } else { + // If the new offset would be negative, bail out. + if (Offset.isPositive() && Index < IOffset) + DiagInvalidOffset(); - // If the new offset would be out of bounds, bail out. - if (Offset.isNegative() && (Offset.isMin() || -IOffset > MaxOffset)) - DiagInvalidOffset(); - } + // If the new offset would be out of bounds, bail out. + if (Offset.isNegative() && (Offset.isMin() || -IOffset > MaxOffset)) + DiagInvalidOffset(); } if (Invalid && (S.getLangOpts().CPlusPlus || Ptr.inArray())) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
