aboutsummaryrefslogtreecommitdiff
path: root/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-30 22:53:42 +0000
committerChris Lattner <sabre@nondot.org>2007-10-30 22:53:42 +0000
commit7da36f642e907ff5a5ba4b18b5bfebfabf36ecc7 (patch)
tree1588aeb85410ca7e8ff9b487281a8bedf5e5edac /CodeGen/CGExpr.cpp
parent8f54c1faaa94c789883d426109796fd62b81a044 (diff)
__real__ and __imag__ can be lvalues. Add support to ast and codegen for them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CGExpr.cpp')
-rw-r--r--CodeGen/CGExpr.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index a0ef03bdc8..b996ecacda 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -283,9 +283,21 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
if (E->getOpcode() == UnaryOperator::Extension)
return EmitLValue(E->getSubExpr());
- assert(E->getOpcode() == UnaryOperator::Deref &&
- "'*' is the only unary operator that produces an lvalue");
- return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()));
+ switch (E->getOpcode()) {
+ default: assert(0 && "Unknown unary operator lvalue!");
+ case UnaryOperator::Deref:
+ return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()));
+ case UnaryOperator::Real:
+ case UnaryOperator::Imag:
+ LValue LV = EmitLValue(E->getSubExpr());
+
+ llvm::Constant *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
+ llvm::Constant *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty,
+ E->getOpcode() == UnaryOperator::Imag);
+ llvm::Value *Ops[] = {Zero, Idx};
+ return LValue::MakeAddr(Builder.CreateGEP(LV.getAddress(), Ops, Ops+2,
+ "idx"));
+ }
}
LValue CodeGenFunction::EmitStringLiteralLValue(const StringLiteral *E) {