diff options
author | Anders Carlsson <andersca@mac.com> | 2009-05-27 01:45:47 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-05-27 01:45:47 +0000 |
commit | 482656833a71b63f67f3e93ee8c2d45b3d351ca8 (patch) | |
tree | c7051c44017ea662a88c01df1d79d669b69565df /lib/CodeGen/CGExpr.cpp | |
parent | ff4bf3bd6174f6a02da4ee2efc6064c005295d44 (diff) |
Add support for emitting calls to functions that return references (as lvalues only for now)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index f6081c61f9..45e19f139a 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1161,8 +1161,17 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { } LValue CodeGenFunction::EmitCallExprLValue(const CallExpr *E) { - // Can only get l-value for call expression returning aggregate type RValue RV = EmitCallExpr(E); + + if (RV.isScalar()) { + assert(E->getCallReturnType()->isReferenceType() && + "Can't have a scalar return unless the return type is a " + "reference type!"); + + return LValue::MakeAddr(RV.getScalarVal(), E->getType().getCVRQualifiers(), + getContext().getObjCGCAttrKind(E->getType())); + } + return LValue::MakeAddr(RV.getAggregateAddr(), E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType())); |