[clang] dee02ee - [clang][Interp][NFC] Complex elements can only be primitives

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 24 03:56:28 PST 2024


Author: Timm Bäder
Date: 2024-01-24T12:56:16+01:00
New Revision: dee02ee9f8ffc74fea6c54f4c00df16e7ca4c8a1

URL: https://github.com/llvm/llvm-project/commit/dee02ee9f8ffc74fea6c54f4c00df16e7ca4c8a1
DIFF: https://github.com/llvm/llvm-project/commit/dee02ee9f8ffc74fea6c54f4c00df16e7ca4c8a1.diff

LOG: [clang][Interp][NFC] Complex elements can only be primitives

So, return a PrimType directly from classifyComplexElementType().

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index cfcef067b92bdc3..24a33c32df14042 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -601,8 +601,8 @@ bool ByteCodeExprGen<Emitter>::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<Emitter>::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 df4cb736299cb62..63ea8292b587675 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -282,12 +282,12 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
   }
 
   bool emitPrimCast(PrimType FromT, PrimType ToT, QualType ToQT, const Expr *E);
-  std::optional<PrimType> classifyComplexElementType(QualType T) const {
+  PrimType classifyComplexElementType(QualType T) const {
     assert(T->isAnyComplexType());
 
     QualType ElemType = T->getAs<ComplexType>()->getElementType();
 
-    return this->classify(ElemType);
+    return *this->classify(ElemType);
   }
 
   bool emitComplexReal(const Expr *SubExpr);


        


More information about the cfe-commits mailing list