[clang] [clang][bytecode] Add `PtrView` for non-tracking pointers (PR #184129)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 19:47:38 PST 2026


================
@@ -33,6 +33,244 @@ class Context;
 class Pointer;
 inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P);
 
+struct PtrView {
+  Block *Pointee; // XXX const?
+  unsigned Base;
+  uint64_t Offset;
+
+  bool isRoot() const {
+    return Base == Pointee->getDescriptor()->getMetadataSize();
+  }
+
+  InlineDescriptor *getInlineDesc() const {
+    assert(Base != sizeof(GlobalInlineDescriptor));
+    assert(Base <= Pointee->getSize());
+    assert(Base >= sizeof(InlineDescriptor));
+    return getDescriptor(Base);
+  }
+
+  InlineDescriptor *getDescriptor(unsigned Offset) const {
+    assert(Offset != 0 && "Not a nested pointer");
+    return reinterpret_cast<InlineDescriptor *>(Pointee->rawData() + Offset) -
+           1;
+  }
----------------
tbaederr wrote:

Well we have to encode the knowledge somewhere and `Block`s are currently just a dumb data storage, the knowledge is encoded in `Pointer` (and now in `PtrView`).

https://github.com/llvm/llvm-project/pull/184129


More information about the cfe-commits mailing list