================ @@ -187,6 +195,34 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) { return true; } + case CK_IntegralToPointer: { + QualType IntType = SubExpr->getType(); + assert(IntType->isIntegralOrEnumerationType()); + if (!this->visit(SubExpr)) + return false; + // FIXME: I think the discard is wrong since the int->ptr cast might cause a + // diagnostic. + PrimType T = classifyPrim(IntType); + if (DiscardResult) + return this->emitPop(T, CE); + + QualType PtrType = CE->getType(); + assert(PtrType->isPointerType()); + + const Descriptor *Desc; + if (std::optional<PrimType> T = classify(PtrType->getPointeeType())) { + Desc = P.createDescriptor(SubExpr, *T); + } else if (PtrType->getPointeeType()->isVoidType()) + Desc = nullptr; + else { + Desc = P.createDescriptor(CE, PtrType->getPointeeType().getTypePtr(), + Descriptor::InlineDescMD, true, false, + /*IsMutable=*/false, nullptr); + } ---------------- AaronBallman wrote:
```suggestion if (std::optional<PrimType> T = classify(PtrType->getPointeeType())) Desc = P.createDescriptor(SubExpr, *T); else if (PtrType->getPointeeType()->isVoidType()) Desc = nullptr; else Desc = P.createDescriptor(CE, PtrType->getPointeeType().getTypePtr(), Descriptor::InlineDescMD, true, false, /*IsMutable=*/false, nullptr); ``` https://github.com/llvm/llvm-project/pull/84159 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits