[clang] [clang][bytecode][NFC] Remove useless if statement (PR #217583)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 20 03:49:01 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
We already assert Ptr.isBlockPointer() above.
---
Full diff: https://github.com/llvm/llvm-project/pull/217583.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Interp.h (+16-18)
``````````diff
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()))
``````````
</details>
https://github.com/llvm/llvm-project/pull/217583
More information about the cfe-commits
mailing list