From dee02ee9f8ffc74fea6c54f4c00df16e7ca4c8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 24 Jan 2024 12:47:51 +0100 Subject: [clang][Interp][NFC] Complex elements can only be primitives So, return a PrimType directly from classifyComplexElementType(). --- clang/lib/AST/Interp/ByteCodeExprGen.cpp | 6 +++--- clang/lib/AST/Interp/ByteCodeExprGen.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index cfcef06..24a33c3 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 df4cb73..63ea829 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -282,12 +282,12 @@ private: } 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); -- cgit v1.1