diff options
-rw-r--r-- | CodeGen/CGExpr.cpp | 21 | ||||
-rw-r--r-- | CodeGen/CGStmt.cpp | 11 | ||||
-rw-r--r-- | CodeGen/CodeGenFunction.h | 7 |
3 files changed, 9 insertions, 30 deletions
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp index 549402892f..61fcc80ae3 100644 --- a/CodeGen/CGExpr.cpp +++ b/CodeGen/CGExpr.cpp @@ -368,27 +368,6 @@ EmitOCUVectorElementExpr(const OCUVectorElementExpr *E) { // Expression Emission //===--------------------------------------------------------------------===// -/// EmitAnyExpr - Emit an expression of any type: scalar, complex, aggregate, -/// returning an rvalue corresponding to it. If NeedResult is false, the -/// result of the expression doesn't need to be generated into memory. -RValue CodeGenFunction::EmitAnyExpr(const Expr *E, bool NeedResult) { - if (!hasAggregateLLVMType(E->getType())) - return RValue::get(EmitScalarExpr(E)); - - llvm::Value *DestMem = 0; - if (NeedResult) - DestMem = CreateTempAlloca(ConvertType(E->getType())); - - if (!E->getType()->isComplexType()) { - EmitAggExpr(E, DestMem, false); - } else if (NeedResult) - EmitComplexExprIntoAddr(E, DestMem, false); - else - EmitComplexExpr(E); - - return RValue::getAggregate(DestMem); -} - RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) { if (const ImplicitCastExpr *IcExpr = diff --git a/CodeGen/CGStmt.cpp b/CodeGen/CGStmt.cpp index 32d5f47fec..04c9c1d3eb 100644 --- a/CodeGen/CGStmt.cpp +++ b/CodeGen/CGStmt.cpp @@ -28,10 +28,15 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { switch (S->getStmtClass()) { default: - // Must be an expression in a stmt context. Emit the value and ignore the - // result. + // Must be an expression in a stmt context. Emit the value (to get + // side-effects) and ignore the result. if (const Expr *E = dyn_cast<Expr>(S)) { - EmitAnyExpr(E, false); + if (!hasAggregateLLVMType(E->getType())) + EmitScalarExpr(E); + else if (E->getType()->isComplexType()) + EmitComplexExpr(E); + else + EmitAggExpr(E, 0, false); } else { printf("Unimplemented stmt!\n"); S->dump(); diff --git a/CodeGen/CodeGenFunction.h b/CodeGen/CodeGenFunction.h index 5202085a6d..1af8c79458 100644 --- a/CodeGen/CodeGenFunction.h +++ b/CodeGen/CodeGenFunction.h @@ -328,13 +328,8 @@ public: RValue EmitCompoundAssignmentResult(const CompoundAssignOperator *E, LValue LHSLV, RValue ResV); - /// EmitAnyExpr - Emit an expression of any type: scalar, complex, aggregate, - /// returning an rvalue corresponding to it. If NeedResult is false, the - /// result of the expression doesn't need to be generated into memory. - RValue EmitAnyExpr(const Expr *E, bool NeedResult = true); - RValue EmitCallExpr(const CallExpr *E); - RValue EmitBuiltinExpr(unsigned builtinID, const CallExpr *E); + RValue EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E); |