[clang] [clang][bytecode][NFC] Remove useless if statement (PR #217583)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 20 03:48:24 PDT 2026
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?= <tbaeder at redhat.com>
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()))
More information about the cfe-commits
mailing list