[clang] fa01d04 - [clang][Interp][NFC] Change pointer offset to uint64

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 20 23:31:10 PDT 2024


Author: Timm Bäder
Date: 2024-04-21T08:30:58+02:00
New Revision: fa01d04c9b9a3c8454194a36a0e64daf43cddaf2

URL: https://github.com/llvm/llvm-project/commit/fa01d04c9b9a3c8454194a36a0e64daf43cddaf2
DIFF: https://github.com/llvm/llvm-project/commit/fa01d04c9b9a3c8454194a36a0e64daf43cddaf2.diff

LOG: [clang][Interp][NFC] Change pointer offset to uint64

To accomodate for recent changes in array index calculations.

Added: 
    

Modified: 
    clang/lib/AST/Interp/Pointer.cpp
    clang/lib/AST/Interp/Pointer.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp
index e163e658d462b2..5ef31671ae7be5 100644
--- a/clang/lib/AST/Interp/Pointer.cpp
+++ b/clang/lib/AST/Interp/Pointer.cpp
@@ -23,7 +23,7 @@ Pointer::Pointer(Block *Pointee)
     : Pointer(Pointee, Pointee->getDescriptor()->getMetadataSize(),
               Pointee->getDescriptor()->getMetadataSize()) {}
 
-Pointer::Pointer(Block *Pointee, unsigned BaseAndOffset)
+Pointer::Pointer(Block *Pointee, uint64_t BaseAndOffset)
     : Pointer(Pointee, BaseAndOffset, BaseAndOffset) {}
 
 Pointer::Pointer(const Pointer &P)
@@ -34,7 +34,7 @@ Pointer::Pointer(const Pointer &P)
     PointeeStorage.BS.Pointee->addPointer(this);
 }
 
-Pointer::Pointer(Block *Pointee, unsigned Base, unsigned Offset)
+Pointer::Pointer(Block *Pointee, unsigned Base, uint64_t Offset)
     : Offset(Offset), StorageKind(Storage::Block) {
   assert((Base == RootPtrMark || Base % alignof(void *) == 0) && "wrong base");
 

diff  --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index b4475577b74625..c4d701bc71b7bf 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -89,10 +89,10 @@ class Pointer {
     PointeeStorage.Int.Desc = nullptr;
   }
   Pointer(Block *B);
-  Pointer(Block *B, unsigned BaseAndOffset);
+  Pointer(Block *B, uint64_t BaseAndOffset);
   Pointer(const Pointer &P);
   Pointer(Pointer &&P);
-  Pointer(uint64_t Address, const Descriptor *Desc, unsigned Offset = 0)
+  Pointer(uint64_t Address, const Descriptor *Desc, uint64_t Offset = 0)
       : Offset(Offset), StorageKind(Storage::Int) {
     PointeeStorage.Int.Value = Address;
     PointeeStorage.Int.Desc = Desc;
@@ -134,14 +134,14 @@ class Pointer {
   std::optional<APValue> toRValue(const Context &Ctx) const;
 
   /// Offsets a pointer inside an array.
-  [[nodiscard]] Pointer atIndex(unsigned Idx) const {
+  [[nodiscard]] Pointer atIndex(uint64_t Idx) const {
     if (isIntegralPointer())
       return Pointer(asIntPointer().Value, asIntPointer().Desc, Idx);
 
     if (asBlockPointer().Base == RootPtrMark)
       return Pointer(asBlockPointer().Pointee, RootPtrMark,
                      getDeclDesc()->getSize());
-    unsigned Off = Idx * elemSize();
+    uint64_t Off = Idx * elemSize();
     if (getFieldDesc()->ElemDesc)
       Off += sizeof(InlineDescriptor);
     else
@@ -630,7 +630,7 @@ class Pointer {
   friend class DeadBlock;
   friend struct InitMap;
 
-  Pointer(Block *Pointee, unsigned Base, unsigned Offset);
+  Pointer(Block *Pointee, unsigned Base, uint64_t Offset);
 
   /// Returns the embedded descriptor preceding a field.
   InlineDescriptor *getInlineDesc() const {
@@ -656,7 +656,7 @@ class Pointer {
   }
 
   /// Offset into the storage.
-  unsigned Offset = 0;
+  uint64_t Offset = 0;
 
   /// Previous link in the pointer chain.
   Pointer *Prev = nullptr;


        


More information about the cfe-commits mailing list