[clang] b14b5d9 - [clang][bytecode][NFC] Remove useless if statement (#217583)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 20 04:59:18 PDT 2026
Author: Timm Baeder
Date: 2026-08-20T13:59:14+02:00
New Revision: b14b5d9075ff2df046ccd5ef78de074ae25da880
URL: https://github.com/llvm/llvm-project/commit/b14b5d9075ff2df046ccd5ef78de074ae25da880
DIFF: https://github.com/llvm/llvm-project/commit/b14b5d9075ff2df046ccd5ef78de074ae25da880.diff
LOG: [clang][bytecode][NFC] Remove useless if statement (#217583)
We already assert Ptr.isBlockPointer() above.
Added:
Modified:
clang/lib/AST/ByteCode/Interp.h
Removed:
################################################################################
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