summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprComplex.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-12-04 08:14:53 +0000
committerJohn McCall <rjmccall@apple.com>2010-12-04 08:14:53 +0000
commite26a872b0274098dd5131c6ef1cac8407fba56df (patch)
tree027909a1f0f12c6bd12e82fc24b7b0bd4f6c94cf /clang/lib/CodeGen/CGExprComplex.cpp
parent29cb2fdbc1fff5ba4978c85dd886231858d0c112 (diff)
downloadbcm5719-llvm-e26a872b0274098dd5131c6ef1cac8407fba56df.tar.gz
bcm5719-llvm-e26a872b0274098dd5131c6ef1cac8407fba56df.zip
Remove some defensive calls to EmitLoadOfPropertyRefLValue that shouldn't
be required, and then fix up some missing loads on overloaded-operator paths which that exposed. llvm-svn: 120896
Diffstat (limited to 'clang/lib/CodeGen/CGExprComplex.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprComplex.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp
index fbb3d4860a8..28f324b1b28 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -60,7 +60,10 @@ public:
/// value l-value, this method emits the address of the l-value, then loads
/// and returns the result.
ComplexPairTy EmitLoadOfLValue(const Expr *E) {
- LValue LV = CGF.EmitLValue(E);
+ return EmitLoadOfLValue(CGF.EmitLValue(E));
+ }
+
+ ComplexPairTy EmitLoadOfLValue(LValue LV) {
if (LV.isSimple())
return EmitLoadOfComplex(LV.getAddress(), LV.isVolatileQualified());
@@ -72,6 +75,16 @@ public:
/// the real and imaginary pieces.
ComplexPairTy EmitLoadOfComplex(llvm::Value *SrcPtr, bool isVolatile);
+ /// EmitStoreThroughLValue - Given an l-value of complex type, store
+ /// a complex number into it.
+ void EmitStoreThroughLValue(ComplexPairTy Val, LValue LV) {
+ if (LV.isSimple())
+ return EmitStoreOfComplex(Val, LV.getAddress(), LV.isVolatileQualified());
+
+ assert(LV.isPropertyRef() && "Unknown LValue type!");
+ CGF.EmitStoreThroughPropertyRefLValue(RValue::getComplex(Val), LV);
+ }
+
/// EmitStoreOfComplex - Store the specified real/imag parts into the
/// specified value pointer.
void EmitStoreOfComplex(ComplexPairTy Val, llvm::Value *ResPtr, bool isVol);
@@ -540,13 +553,9 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,
OpInfo.RHS = Visit(E->getRHS());
LValue LHS = CGF.EmitLValue(E->getLHS());
- // We know the LHS is a complex lvalue.
- ComplexPairTy LHSComplexPair;
- if (LHS.isPropertyRef())
- LHSComplexPair = CGF.EmitLoadOfPropertyRefLValue(LHS).getComplexVal();
- else
- LHSComplexPair = EmitLoadOfComplex(LHS.getAddress(),
- LHS.isVolatileQualified());
+
+ // Load from the l-value.
+ ComplexPairTy LHSComplexPair = EmitLoadOfLValue(LHS);
OpInfo.LHS = EmitComplexToComplexCast(LHSComplexPair, LHSTy, OpInfo.Ty);
@@ -558,10 +567,7 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,
Val = Result;
// Store the result value into the LHS lvalue.
- if (LHS.isPropertyRef())
- CGF.EmitStoreThroughPropertyRefLValue(RValue::getComplex(Result), LHS);
- else
- EmitStoreOfComplex(Result, LHS.getAddress(), LHS.isVolatileQualified());
+ EmitStoreThroughLValue(Result, LHS);
return LHS;
}
@@ -603,10 +609,7 @@ LValue ComplexExprEmitter::EmitBinAssignLValue(const BinaryOperator *E,
LValue LHS = CGF.EmitLValue(E->getLHS());
// Store the result value into the LHS lvalue.
- if (LHS.isPropertyRef())
- CGF.EmitStoreThroughPropertyRefLValue(RValue::getComplex(Val), LHS);
- else
- EmitStoreOfComplex(Val, LHS.getAddress(), LHS.isVolatileQualified());
+ EmitStoreThroughLValue(Val, LHS);
return LHS;
}
OpenPOWER on IntegriCloud