forked from OSchip/llvm-project
Rename variables in SemaExpr.cpp to give a more consistant naming scheme.
ExprResult LHS, RHS, Expr *LHSExpr, *RHSExpr QualType LHSType, RHSType Functions changed: handleComplexFloatToComplexFloatConverstion() handleComplexFloatConversion() llvm-svn: 139151
This commit is contained in:
parent
58704ee442
commit
5065cdd0ea
|
@ -569,23 +569,22 @@ static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &intExpr,
|
||||||
/// \brief Takes two complex float types and converts them to the same type.
|
/// \brief Takes two complex float types and converts them to the same type.
|
||||||
/// Helper function of UsualArithmeticConversions()
|
/// Helper function of UsualArithmeticConversions()
|
||||||
static QualType
|
static QualType
|
||||||
handleComplexFloatToComplexFloatConverstion(Sema &S, ExprResult &lhsExpr,
|
handleComplexFloatToComplexFloatConverstion(Sema &S, ExprResult &LHS,
|
||||||
ExprResult &rhsExpr, QualType lhs,
|
ExprResult &RHS, QualType LHSType,
|
||||||
QualType rhs, bool isCompAssign) {
|
QualType RHSType,
|
||||||
int order = S.Context.getFloatingTypeOrder(lhs, rhs);
|
bool isCompAssign) {
|
||||||
|
int order = S.Context.getFloatingTypeOrder(LHSType, RHSType);
|
||||||
|
|
||||||
if (order < 0) {
|
if (order < 0) {
|
||||||
// _Complex float -> _Complex double
|
// _Complex float -> _Complex double
|
||||||
if (!isCompAssign)
|
if (!isCompAssign)
|
||||||
lhsExpr = S.ImpCastExprToType(lhsExpr.take(), rhs,
|
LHS = S.ImpCastExprToType(LHS.take(), RHSType, CK_FloatingComplexCast);
|
||||||
CK_FloatingComplexCast);
|
return RHSType;
|
||||||
return rhs;
|
|
||||||
}
|
}
|
||||||
if (order > 0)
|
if (order > 0)
|
||||||
// _Complex float -> _Complex double
|
// _Complex float -> _Complex double
|
||||||
rhsExpr = S.ImpCastExprToType(rhsExpr.take(), lhs,
|
RHS = S.ImpCastExprToType(RHS.take(), LHSType, CK_FloatingComplexCast);
|
||||||
CK_FloatingComplexCast);
|
return LHSType;
|
||||||
return lhs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Converts otherExpr to complex float and promotes complexExpr if
|
/// \brief Converts otherExpr to complex float and promotes complexExpr if
|
||||||
|
@ -631,16 +630,17 @@ static QualType handleOtherComplexFloatConversion(Sema &S,
|
||||||
|
|
||||||
/// \brief Handle arithmetic conversion with complex types. Helper function of
|
/// \brief Handle arithmetic conversion with complex types. Helper function of
|
||||||
/// UsualArithmeticConversions()
|
/// UsualArithmeticConversions()
|
||||||
static QualType handleComplexFloatConversion(Sema &S, ExprResult &lhsExpr,
|
static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS,
|
||||||
ExprResult &rhsExpr, QualType lhs,
|
ExprResult &RHS, QualType LHSType,
|
||||||
QualType rhs, bool isCompAssign) {
|
QualType RHSType,
|
||||||
|
bool isCompAssign) {
|
||||||
// if we have an integer operand, the result is the complex type.
|
// if we have an integer operand, the result is the complex type.
|
||||||
if (!handleIntegerToComplexFloatConversion(S, rhsExpr, lhsExpr, rhs, lhs,
|
if (!handleIntegerToComplexFloatConversion(S, RHS, LHS, RHSType, LHSType,
|
||||||
/*skipCast*/false))
|
/*skipCast*/false))
|
||||||
return lhs;
|
return LHSType;
|
||||||
if (!handleIntegerToComplexFloatConversion(S, lhsExpr, rhsExpr, lhs, rhs,
|
if (!handleIntegerToComplexFloatConversion(S, LHS, RHS, LHSType, RHSType,
|
||||||
/*skipCast*/isCompAssign))
|
/*skipCast*/isCompAssign))
|
||||||
return rhs;
|
return RHSType;
|
||||||
|
|
||||||
// This handles complex/complex, complex/float, or float/complex.
|
// This handles complex/complex, complex/float, or float/complex.
|
||||||
// When both operands are complex, the shorter operand is converted to the
|
// When both operands are complex, the shorter operand is converted to the
|
||||||
|
@ -653,24 +653,25 @@ static QualType handleComplexFloatConversion(Sema &S, ExprResult &lhsExpr,
|
||||||
// when combining a "long double" with a "double _Complex", the
|
// when combining a "long double" with a "double _Complex", the
|
||||||
// "double _Complex" is promoted to "long double _Complex".
|
// "double _Complex" is promoted to "long double _Complex".
|
||||||
|
|
||||||
bool LHSComplexFloat = lhs->isComplexType();
|
bool LHSComplexFloat = LHSType->isComplexType();
|
||||||
bool RHSComplexFloat = rhs->isComplexType();
|
bool RHSComplexFloat = RHSType->isComplexType();
|
||||||
|
|
||||||
// If both are complex, just cast to the more precise type.
|
// If both are complex, just cast to the more precise type.
|
||||||
if (LHSComplexFloat && RHSComplexFloat)
|
if (LHSComplexFloat && RHSComplexFloat)
|
||||||
return handleComplexFloatToComplexFloatConverstion(S, lhsExpr, rhsExpr,
|
return handleComplexFloatToComplexFloatConverstion(S, LHS, RHS,
|
||||||
lhs, rhs, isCompAssign);
|
LHSType, RHSType,
|
||||||
|
isCompAssign);
|
||||||
|
|
||||||
// If only one operand is complex, promote it if necessary and convert the
|
// If only one operand is complex, promote it if necessary and convert the
|
||||||
// other operand to complex.
|
// other operand to complex.
|
||||||
if (LHSComplexFloat)
|
if (LHSComplexFloat)
|
||||||
return handleOtherComplexFloatConversion(
|
return handleOtherComplexFloatConversion(
|
||||||
S, lhsExpr, rhsExpr, lhs, rhs, /*convertComplexExpr*/!isCompAssign,
|
S, LHS, RHS, LHSType, RHSType, /*convertComplexExpr*/!isCompAssign,
|
||||||
/*convertOtherExpr*/ true);
|
/*convertOtherExpr*/ true);
|
||||||
|
|
||||||
assert(RHSComplexFloat);
|
assert(RHSComplexFloat);
|
||||||
return handleOtherComplexFloatConversion(
|
return handleOtherComplexFloatConversion(
|
||||||
S, rhsExpr, lhsExpr, rhs, lhs, /*convertComplexExpr*/true,
|
S, RHS, LHS, RHSType, LHSType, /*convertComplexExpr*/true,
|
||||||
/*convertOtherExpr*/ !isCompAssign);
|
/*convertOtherExpr*/ !isCompAssign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue