summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-24 02:38:23 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-24 02:38:23 +0000
commitbf1fe8c36c9cba6782990bd291220c92cfa5a82c (patch)
tree4532162f8ae58d574e53deb6b1d5e67f1572cd33 /clang/lib/CodeGen
parenta45cf5b6b0790e829ad47cf946c149d8f1007324 (diff)
downloadbcm5719-llvm-bf1fe8c36c9cba6782990bd291220c92cfa5a82c.tar.gz
bcm5719-llvm-bf1fe8c36c9cba6782990bd291220c92cfa5a82c.zip
Support member reference on ?: of struct type.
llvm-svn: 67603
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp20
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 45cd6a70a5d..b52c81eb0bc 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/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
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 9771c83d84c..acac86d8c2b 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -608,6 +608,7 @@ public:
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E);
LValue EmitMemberExpr(const MemberExpr *E);
LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E);
+ LValue EmitConditionalOperator(const ConditionalOperator *E);
LValue EmitCastLValue(const CastExpr *E);
llvm::Value *EmitIvarOffset(ObjCInterfaceDecl *Interface,
OpenPOWER on IntegriCloud