[cfe-commits] r43581 - in /cfe/trunk: CodeGen/CGExprAgg.cpp test/CodeGen/struct.c

Anders Carlsson andersca at mac.com
Wed Oct 31 15:04:46 PDT 2007


Author: andersca
Date: Wed Oct 31 17:04:46 2007
New Revision: 43581

URL: http://llvm.org/viewvc/llvm-project?rev=43581&view=rev
Log:
Handle function calls that return aggregate expressions.

Modified:
    cfe/trunk/CodeGen/CGExprAgg.cpp
    cfe/trunk/test/CodeGen/struct.c

Modified: cfe/trunk/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprAgg.cpp?rev=43581&r1=43580&r2=43581&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/CodeGen/CGExprAgg.cpp Wed Oct 31 17:04:46 2007
@@ -67,7 +67,7 @@
   //  case Expr::UnaryOperatorClass:
   //  case Expr::ImplicitCastExprClass:
   //  case Expr::CastExprClass: 
-  //  case Expr::CallExprClass:
+  void VisitCallExpr(const CallExpr *E);
   void VisitStmtExpr(const StmtExpr *E);
   void VisitBinaryOperator(const BinaryOperator *BO);
   void VisitBinAssign(const BinaryOperator *E);
@@ -132,6 +132,19 @@
 //                            Visitor Methods
 //===----------------------------------------------------------------------===//
 
+void AggExprEmitter::VisitCallExpr(const CallExpr *E)
+{
+  RValue RV = CGF.EmitCallExpr(E);
+  assert(RV.isAggregate() && "Return value must be aggregate value!");
+  
+  // If the result is ignored, don't copy from the value.
+  if (DestPtr == 0)
+    // FIXME: If the source is volatile, we must read from it.
+    return;
+  
+  EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
+}
+
 void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) {
   CGF.EmitCompoundStmt(*E->getSubStmt(), true, DestPtr, VolatileDest);
 }

Modified: cfe/trunk/test/CodeGen/struct.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/struct.c?rev=43581&r1=43580&r2=43581&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/struct.c (original)
+++ cfe/trunk/test/CodeGen/struct.c Wed Oct 31 17:04:46 2007
@@ -63,3 +63,17 @@
 void f5() {
   (f3())->d1 = 42;
 }
+
+/* Function calls */
+typedef struct {
+  int location;
+  int length;
+} range;
+
+extern range f6();
+void f7()
+{
+	range r = f6();
+}
+
+





More information about the cfe-commits mailing list