[PATCH] D132111: [clang][Interp] Implement pointer (de)ref operations and DeclRefExprs

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 18 06:21:01 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:215
+        return false;
+      return DiscardResult ? this->emitPopPtr(BO) : true;
     default:
----------------
erichkeane wrote:
> Can you explain what this is doing for me?
The `Store` operation pops the value to store from the stack, but leaves the pointer it stores the value to on the stack (it only `peek()`s the pointer). So after the `emitStore`, there's still the pointer we stored to on the stack, and we need to get rid of it if `DiscardResult` is true (that's the case for a simple `i = 5;` on a single line). Otherwise, we leave it no the stack for the caller to read from.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132111/new/

https://reviews.llvm.org/D132111



More information about the cfe-commits mailing list