================ @@ -389,10 +391,28 @@ template <class Emitter> class LocalScope : public VariableScope<Emitter> { if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) { this->Ctx->emitGetPtrLocal(Local.Offset, SourceInfo{}); this->Ctx->emitRecordDestruction(Local.Desc); + removeIfStoredOpaqueValue(Local); } } } + void removeStoredOpaqueValues() { + if (!Idx) + return; + + for (Scope::Local &Local : this->Ctx->Descriptors[*Idx]) { + removeIfStoredOpaqueValue(Local); + } + } + + void removeIfStoredOpaqueValue(const Scope::Local &Local) { + if (auto *OVE = + llvm::dyn_cast_or_null<OpaqueValueExpr>(Local.Desc->asExpr()); + OVE && this->Ctx->OpaqueExprs.contains(OVE)) { + this->Ctx->OpaqueExprs.erase(OVE); + }; + } + ---------------- isuckatcs wrote:
There might be cases like loops or recursive functions, where we might want to evaluate the same `OpaqueValueExpr` multiple times, but we will fail if it is left in the map. I'm just trying to be careful here. https://github.com/llvm/llvm-project/pull/70053 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits