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

Eli Friedman eli.friedman at gmail.com
Tue May 27 08:51:49 PDT 2008


Author: efriedma
Date: Tue May 27 10:51:49 2008
New Revision: 51596

URL: http://llvm.org/viewvc/llvm-project?rev=51596&view=rev
Log:
A few more cases for aggregate values.


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

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Tue May 27 10:51:49 2008
@@ -68,6 +68,8 @@
   void VisitMemberExpr(MemberExpr *ME) { EmitAggLoadOfLValue(ME); }
   void VisitUnaryDeref(UnaryOperator *E) { EmitAggLoadOfLValue(E); }
   void VisitStringLiteral(StringLiteral *E) { EmitAggLoadOfLValue(E); }
+  void VisitCompoundLiteralExpr(CompoundLiteralExpr *E)
+      { EmitAggLoadOfLValue(E); }
 
   void VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
     EmitAggLoadOfLValue(E);
@@ -90,6 +92,7 @@
   void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
     Visit(DAE->getExpr());
   }
+  void VisitVAArgExpr(VAArgExpr *E);
 
   void EmitInitializationToLValue(Expr *E, LValue Address);
   void EmitNullInitializationToLValue(LValue Address, QualType T);
@@ -273,6 +276,13 @@
   CGF.EmitBlock(ContBlock);
 }
 
+void AggExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
+  llvm::Value *ArgValue = CGF.EmitLValue(VE->getSubExpr()).getAddress();
+  llvm::Value *V = Builder.CreateVAArg(ArgValue, CGF.ConvertType(VE->getType()));
+  if (DestPtr)
+    Builder.CreateStore(V, DestPtr);
+}
+
 void AggExprEmitter::EmitNonConstInit(InitListExpr *E) {
 
   const llvm::PointerType *APType =

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

==============================================================================
--- cfe/trunk/test/CodeGen/struct.c (original)
+++ cfe/trunk/test/CodeGen/struct.c Tue May 27 10:51:49 2008
@@ -145,3 +145,17 @@
 /* flexible array members */
 struct a15 {char a; int b[];} c15;
 int a16(void) {c15.a = 1;}
+
+/* compound literals */
+void f13()
+{
+  a13 x; x = (a13){1,2};
+}
+
+/* va_arg */
+int f14(int i, ...) {
+  __builtin_va_list l;
+  __builtin_va_start(l,i);
+  a13 b = __builtin_va_arg(l, a13);
+  return b.b;
+}





More information about the cfe-commits mailing list