[clang] [clang][Interp] Implement integral->complex casts (PR #75590)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 18 19:19:26 PST 2023
================
@@ -283,6 +283,28 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
case CK_ToVoid:
return discard(SubExpr);
+ case CK_IntegralRealToComplex:
+ case CK_FloatingRealToComplex: {
+ // We're creating a complex value here, so we need to
+ // allocate storage for it.
+ if (!Initializing) {
+ std::optional<unsigned> LocalIndex =
+ allocateLocal(CE, /*IsExtended=*/true);
+ if (!LocalIndex)
+ return false;
+ if (!this->emitGetPtrLocal(*LocalIndex, CE))
+ return false;
+ }
+
+ if (!this->visitArrayElemInit(0, SubExpr))
----------------
shafik wrote:
Why the different init for first and second element? Complex is basiclly an array underneath: https://eel.is/c++draft/complex.numbers#general-4 but I am not sure I understand the difference in how we init the first and second element.
Seems like a comment would be helpful.
https://github.com/llvm/llvm-project/pull/75590
More information about the cfe-commits
mailing list