diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 7 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprComplex.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 21 |
3 files changed, 27 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 6739fd679cf..3356cf46fbd 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1815,10 +1815,15 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { case CK_FloatingToIntegral: case CK_FloatingCast: case CK_FloatingRealToComplex: + case CK_FloatingComplexToReal: + case CK_FloatingComplexToBoolean: case CK_FloatingComplexCast: + case CK_FloatingComplexToIntegralComplex: case CK_IntegralRealToComplex: + case CK_IntegralComplexToReal: + case CK_IntegralComplexToBoolean: case CK_IntegralComplexCast: - case CK_IntegralToFloatingComplex: + case CK_IntegralComplexToFloatingComplex: case CK_DerivedToBaseMemberPointer: case CK_BaseToDerivedMemberPointer: case CK_MemberPointerToBoolean: diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index 637441f4e19..ad0786fd9b0 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -274,6 +274,8 @@ ComplexPairTy ComplexExprEmitter::EmitLoadOfComplex(llvm::Value *SrcPtr, bool isVolatile) { llvm::Value *Real=0, *Imag=0; + // FIXME: we should really not be suppressing volatile loads. + if (!IgnoreReal) { llvm::Value *RealP = Builder.CreateStructGEP(SrcPtr, 0, SrcPtr->getName() + ".realp"); diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 5b419c02f8b..8d72e47fb86 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1083,7 +1083,8 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { case CK_FloatingComplexCast: case CK_IntegralRealToComplex: case CK_IntegralComplexCast: - case CK_IntegralToFloatingComplex: + case CK_IntegralComplexToFloatingComplex: + case CK_FloatingComplexToIntegralComplex: case CK_ConstructorConversion: assert(0 && "Should be unreachable!"); break; @@ -1151,6 +1152,20 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { const MemberPointerType *MPT = E->getType()->getAs<MemberPointerType>(); return CGF.CGM.getCXXABI().EmitMemberPointerIsNotNull(CGF, MemPtr, MPT); } + + case CK_FloatingComplexToReal: + case CK_IntegralComplexToReal: + return CGF.EmitComplexExpr(E, false, true, false, true).first; + + case CK_FloatingComplexToBoolean: + case CK_IntegralComplexToBoolean: { + CodeGenFunction::ComplexPairTy V + = CGF.EmitComplexExpr(E, false, false, false, false); + + // TODO: kill this function off, inline appropriate case here + return EmitComplexToScalarConversion(V, E->getType(), DestTy); + } + } // Handle cases where the source is an non-complex type. @@ -1162,8 +1177,10 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return EmitScalarConversion(Src, E->getType(), DestTy); } + // Handle cases where the source is a complex type. + // TODO: when we're certain about cast kinds, we should just be able + // to assert that no complexes make it here. if (E->getType()->isAnyComplexType()) { - // Handle cases where the source is a complex type. bool IgnoreImag = true; bool IgnoreImagAssign = true; bool IgnoreReal = IgnoreResultAssign; |