================ @@ -478,6 +480,43 @@ template <class Emitter> class SourceLocScope final { bool Enabled = false; }; +template <class Emitter> class StoredOpaqueValueScope final { +public: + StoredOpaqueValueScope(ByteCodeExprGen<Emitter> *Ctx) : Ctx(Ctx) {} + + bool VisitAndStoreOpaqueValue(const OpaqueValueExpr *Ove) { + assert(Ove && "OpaqueValueExpr is a nullptr!"); + assert(!Ctx->OpaqueExprs.contains(Ove) && + "OpaqueValueExpr already stored!"); + + std::optional<PrimType> CommonTy = Ctx->classify(Ove); + std::optional<unsigned> LocalIndex = Ctx->allocateLocalPrimitive( + Ove, *CommonTy, Ove->getType().isConstQualified()); + if (!LocalIndex) + return false; + + if (!Ctx->visit(Ove)) + return false; + + if (!Ctx->emitSetLocal(*CommonTy, *LocalIndex, Ove)) + return false; + + Ctx->OpaqueExprs.insert({Ove, *LocalIndex}); + StoredValues.emplace_back(Ove); + + return true; ---------------- tbaederr wrote:
I think all the visiting logic should go into `ByteCodeExprGen.cpp`. https://github.com/llvm/llvm-project/pull/68039 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits