diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index cfcef067b92bd..24a33c32df140 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -601,8 +601,8 @@ bool ByteCodeExprGen::VisitComplexBinOp(const BinaryOperator *E) { const Expr *LHS = E->getLHS(); const Expr *RHS = E->getRHS(); - PrimType LHSElemT = *this->classifyComplexElementType(LHS->getType()); - PrimType RHSElemT = *this->classifyComplexElementType(RHS->getType()); + PrimType LHSElemT = this->classifyComplexElementType(LHS->getType()); + PrimType RHSElemT = this->classifyComplexElementType(RHS->getType()); unsigned LHSOffset = this->allocateLocalPrimitive(LHS, PT_Ptr, true, false); unsigned RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, true, false); @@ -2992,7 +2992,7 @@ bool ByteCodeExprGen::emitComplexReal(const Expr *SubExpr) { // Since our _Complex implementation does not map to a primitive type, // we sometimes have to do the lvalue-to-rvalue conversion here manually. if (!SubExpr->isLValue()) - return this->emitLoadPop(*classifyComplexElementType(SubExpr->getType()), + return this->emitLoadPop(classifyComplexElementType(SubExpr->getType()), SubExpr); return true; } diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index df4cb736299cb..63ea8292b5876 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -282,12 +282,12 @@ class ByteCodeExprGen : public ConstStmtVisitor, bool>, } bool emitPrimCast(PrimType FromT, PrimType ToT, QualType ToQT, const Expr *E); - std::optional classifyComplexElementType(QualType T) const { + PrimType classifyComplexElementType(QualType T) const { assert(T->isAnyComplexType()); QualType ElemType = T->getAs()->getElementType(); - return this->classify(ElemType); + return *this->classify(ElemType); } bool emitComplexReal(const Expr *SubExpr);