]> granicus.if.org Git - clang/commitdiff
Teach complex compound assignment IR-generation that the RHS of
authorJohn McCall <rjmccall@apple.com>
Tue, 16 Nov 2010 05:45:35 +0000 (05:45 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 16 Nov 2010 05:45:35 +0000 (05:45 +0000)
a compound assignment is always already in the computation type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119330 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprComplex.cpp

index 25824260aa4818dd2180a0369accdbd849b4ffe5..5697a8b1bf47e381fe8559d18c6feb0e2dfc4195 100644 (file)
@@ -540,10 +540,14 @@ EmitCompoundAssign(const CompoundAssignOperator *E,
 
   // Load the RHS and LHS operands.
   // __block variables need to have the rhs evaluated first, plus this should
-  // improve codegen a little.  It is possible for the RHS to be complex or
-  // scalar.
+  // improve codegen a little.
   OpInfo.Ty = E->getComputationResultType();
-  OpInfo.RHS = EmitCast(CK_Unknown, E->getRHS(), OpInfo.Ty);
+
+  // The RHS should have been converted to the computation type.
+  assert(OpInfo.Ty->isAnyComplexType());
+  assert(CGF.getContext().hasSameUnqualifiedType(OpInfo.Ty,
+                                                 E->getRHS()->getType()));
+  OpInfo.RHS = Visit(E->getRHS());
   
   LValue LHS = CGF.EmitLValue(E->getLHS());
   // We know the LHS is a complex lvalue.