[PATCH] D141858: [clang][Interp] Fix Pointer::toAPValue() for expressions

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 16 09:00:22 PST 2023


tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is now relevant because we generate pointers for expressions more often, since `MaterializeTemporaryExpr`s work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141858

Files:
  clang/lib/AST/Interp/Pointer.cpp


Index: clang/lib/AST/Interp/Pointer.cpp
===================================================================
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
     if (isUnknownSizeArray()) {
       IsOnePastEnd = false;
       Offset = CharUnits::Zero();
+    } else if (getFieldDesc()->asExpr()) {
+      // Pointer pointing to a an expression.
+      IsOnePastEnd = false;
+      Offset = CharUnits::Zero();
     } else {
       // TODO: compute the offset into the object.
       Offset = CharUnits::Zero();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141858.489579.patch
Type: text/x-patch
Size: 556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230116/a7940f2f/attachment.bin>


More information about the cfe-commits mailing list