]> granicus.if.org Git - clang/commitdiff
eliminate EmitAnyExpr, inlining it and simplifying it into its only caller.
authorChris Lattner <sabre@nondot.org>
Sun, 26 Aug 2007 22:58:05 +0000 (22:58 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 Aug 2007 22:58:05 +0000 (22:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41468 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGExpr.cpp
CodeGen/CGStmt.cpp
CodeGen/CodeGenFunction.h

index 549402892f8cda8d10d0a435ffe4bd9d6474430c..61fcc80ae3db0f38abb197ff52200bbd0e17ab20 100644 (file)
@@ -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 = 
index 32d5f47feca154e148fb9e723c307f72002ca940..04c9c1d3eb706d62ae7b86797dab86a3f19baabc 100644 (file)
@@ -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();
index 5202085a6d1d03a461f8524bc7d38ef6c1f64a29..1af8c794585c43f5fafcb681c51ee7b209349f33 100644 (file)
@@ -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);