From 4f29b49de11e5815952c256bbe66ffe33f4e3d00 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 16 Nov 2010 23:07:28 +0000 Subject: Support compound complex operations as l-values in C++. Add a test case based on CodeGen/volatile-1.c which tests the current C++ semantics, and note the many, many places we fall short of them. llvm-svn: 119402 --- clang/lib/CodeGen/CGExprComplex.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'clang/lib/CodeGen/CGExprComplex.cpp') diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index df65d5a..26bda79 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -760,3 +760,26 @@ ComplexPairTy CodeGenFunction::LoadComplexFromAddr(llvm::Value *SrcAddr, bool SrcIsVolatile) { return ComplexExprEmitter(*this).EmitLoadOfComplex(SrcAddr, SrcIsVolatile); } + +LValue CodeGenFunction::EmitComplexAssignmentLValue(const BinaryOperator *E) { + ComplexPairTy Val; // ignored + + ComplexPairTy(ComplexExprEmitter::*Op)(const ComplexExprEmitter::BinOpInfo &); + + switch (E->getOpcode()) { + case BO_Assign: + return ComplexExprEmitter(*this).EmitBinAssignLValue(E, Val); + + case BO_MulAssign: Op = &ComplexExprEmitter::EmitBinMul; break; + case BO_DivAssign: Op = &ComplexExprEmitter::EmitBinDiv; break; + case BO_SubAssign: Op = &ComplexExprEmitter::EmitBinSub; break; + case BO_AddAssign: Op = &ComplexExprEmitter::EmitBinAdd; break; + + default: + llvm_unreachable("unexpected complex compound assignment"); + Op = 0; + } + + return ComplexExprEmitter(*this).EmitCompoundAssignLValue( + cast(E), Op, Val); +} -- cgit v1.1