[PATCH] D136751: [clang][Interp] This pointers are writable in constructors

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 6 07:43:56 PST 2023


aaron.ballman added inline comments.


================
Comment at: clang/lib/AST/Interp/Interp.cpp:264-270
+  const Function *Func = S.Current->getFunction();
+  if (Func && Func->isConstructor()) {
+    // The This pointer is writable in constructors, even if
+    // isConst() returns true.
+    if (Ptr.block() == S.Current->getThis().block())
+      return true;
+  }
----------------
The same is true for destructors as well: https://godbolt.org/z/a49aEErz8


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136751



More information about the cfe-commits mailing list