[clang] [clang][Interp] Integral pointers (PR #84159)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 05:55:48 PST 2024


================
@@ -88,6 +126,12 @@ APValue Pointer::toAPValue() const {
   if (isZero())
     return APValue(static_cast<const Expr *>(nullptr), CharUnits::Zero(), Path,
                    /*IsOnePastEnd=*/false, /*IsNullPtr=*/true);
+  if (isIntegralPointer()) {
+    return APValue(static_cast<const Expr *>(nullptr),
+                   CharUnits::fromQuantity(asIntPointer().Value + this->Offset),
+                   Path,
+                   /*IsOnePastEnd=*/false, /*IsNullPtr=*/false);
+  }
----------------
AaronBallman wrote:

```suggestion
  if (isIntegralPointer())
    return APValue(static_cast<const Expr *>(nullptr),
                   CharUnits::fromQuantity(asIntPointer().Value + this->Offset),
                   Path,
                   /*IsOnePastEnd=*/false, /*IsNullPtr=*/false);
```

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


More information about the cfe-commits mailing list