diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-03-24 02:38:23 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-24 02:38:23 +0000 |
| commit | 9034558f2f9ac1dc6bd2e74f4481ca62fce28718 (patch) | |
| tree | b7a5787917bfc9926ce15268194ea3f2ed905d1d /lib/CodeGen/CGExpr.cpp | |
| parent | d7d5f0223bd30dfd618762349c6209dd1d5ea3e6 (diff) | |
| download | clang-9034558f2f9ac1dc6bd2e74f4481ca62fce28718.tar.gz clang-9034558f2f9ac1dc6bd2e74f4481ca62fce28718.tar.bz2 clang-9034558f2f9ac1dc6bd2e74f4481ca62fce28718.tar.xz | |
Support member reference on ?: of struct type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67603 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 45cd6a70a5..b52c81eb0b 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -179,6 +179,8 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { case Expr::MemberExprClass: return EmitMemberExpr(cast<MemberExpr>(E)); case Expr::CompoundLiteralExprClass: return EmitCompoundLiteralLValue(cast<CompoundLiteralExpr>(E)); + case Expr::ConditionalOperatorClass: + return EmitConditionalOperator(cast<ConditionalOperator>(E)); case Expr::ChooseExprClass: return EmitLValue(cast<ChooseExpr>(E)->getChosenSubExpr(getContext())); case Expr::ImplicitCastExprClass: @@ -1009,6 +1011,24 @@ LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr* E){ return Result; } +LValue CodeGenFunction::EmitConditionalOperator(const ConditionalOperator* E) { + // We don't handle vectors yet. + if (E->getType()->isVectorType()) + return EmitUnsupportedLValue(E, "conditional operator"); + + // ?: here should be an aggregate. + assert((hasAggregateLLVMType(E->getType()) && + !E->getType()->isAnyComplexType()) && + "Unexpected conditional operator!"); + + llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType())); + EmitAggExpr(E, Temp, false); + + return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers(), + getContext().getObjCGCAttrKind(E->getType())); + +} + /// EmitCastLValue - Casts are never lvalues. If a cast is needed by the code /// generator in an lvalue context, then it must mean that we need the address /// of an aggregate in order to access one of its fields. This can happen for |
