llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

Return `Offset` directly, except for block pointers. This also allows us to 
remove `getRawOffset()`.

---
Full diff: https://github.com/llvm/llvm-project/pull/223382.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.h (+2-2) 
- (modified) clang/lib/AST/ByteCode/Pointer.h (+2-10) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 7c716355617080..3d8c7c813f719d 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2614,9 +2614,9 @@ std::optional<Pointer> OffsetHelper(InterpState &S, 
CodePtr OpPC,
   } else if (Ptr.isStringPointer()) {
     int64_t NewOffset;
     if constexpr (Op == ArithOp::Add)
-      NewOffset = Ptr.getRawOffset() + static_cast<int64_t>(Offset);
+      NewOffset = Ptr.getByteOffset() + static_cast<int64_t>(Offset);
     else
-      NewOffset = Ptr.getRawOffset() - static_cast<int64_t>(Offset);
+      NewOffset = Ptr.getByteOffset() - static_cast<int64_t>(Offset);
     if (NewOffset < 0 ||
         NewOffset > (Ptr.asStringPointer().getLiteral()->getLength() + 1)) {
       S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_array_index)
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 5b43df9db49c4c..9f46dc615f4615 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -968,19 +968,11 @@ class Pointer {
 
   /// Returns the byte offset from the start.
   uint64_t getByteOffset() const {
-    if (isIntegralPointer())
-      return Int.Value + Offset;
-    if (isTypeidPointer())
-      return reinterpret_cast<uintptr_t>(Typeid.TypePtr) + Offset;
-    if (isOpaquePointer())
-      return Offset;
-    if (isOnePastEnd())
-      return PtrView::PastEndMark;
+    if (isBlockPointer())
+      return isOnePastEnd() ? PtrView::PastEndMark : Offset;
     return Offset;
   }
 
-  uint64_t getRawOffset() const { return Offset; }
-
   /// Returns the number of elements.
   unsigned getNumElems() const {
     if (isStringPointer())

``````````

</details>


https://github.com/llvm/llvm-project/pull/223382
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to