[PATCH] D138802: [clang][Interp] Implement DecompositionDecls

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 23 07:01:18 PST 2023


aaron.ballman added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:34-35
 
+  virtual ~DeclScope() override { this->emitDestruction(); }
+
   void addExtended(const Scope::Local &Local) override {
----------------
The destructor for `LocalScope` already calls `emitDestruction()` which is a virtual function, so is this necessary?


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1370-1372
+        BD && BD->getDecomposedDecl()->getType()->isReferenceType()) {
+      VarT = PT_Ptr;
+    }
----------------



================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1386-1389
+        if (Init && Init->isLValue() && *VarT != PT_Ptr) {
+          if (!this->emitLoadPop(*VarT, VD))
+            return false;
+        }
----------------



================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1417-1418
+      assert(!BD->getHoldingVar()); // FIXME
+      if (!this->allocateVariable(BD, BD->getBinding()))
+        return false;
+    }
----------------
<uncertain>Is this correct? IIRC, the decomposition declaration is its own object, but the bindings themselves are references back to the decomposition declaration object directly and so they're not distinct objects themselves (they're more like aliases).</uncertain>


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

https://reviews.llvm.org/D138802



More information about the cfe-commits mailing list