================ @@ -2544,6 +2544,85 @@ bool ByteCodeExprGen<Emitter>::VisitCXXInheritedCtorInitExpr( return this->emitCall(F, 0, E); } +template <class Emitter> +bool ByteCodeExprGen<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) { + assert(classifyPrim(E->getType()) == PT_Ptr); + const Expr *Init = E->getInitializer(); + QualType ElementType = E->getAllocatedType(); + std::optional<PrimType> ElemT = classify(ElementType); + + const Descriptor *Desc; + if (ElemT) { + if (E->isArray()) + Desc = nullptr; // We're not going to use it in this case. + else + Desc = P.createDescriptor(E, *ElemT, Descriptor::InlineDescMD, + /*IsConst=*/false, /*IsTemporary=*/false, + /*IsMutable=*/false); + } else { + Desc = P.createDescriptor( + E, ElementType.getTypePtr(), + E->isArray() ? std::nullopt : Descriptor::InlineDescMD, + /*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false, Init); + } + + if (E->isArray()) { + std::optional<const Expr *> ArraySizeExpr = E->getArraySize(); + if (!ArraySizeExpr) ---------------- tbaederr wrote:
That works, we're getting the size expr from the `CXXNewExpr`. https://github.com/llvm/llvm-project/pull/70306 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits