]> granicus.if.org Git - clang/commitdiff
Support IRgen of va_arg of structure as l-value.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 11 Feb 2009 20:59:32 +0000 (20:59 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 11 Feb 2009 20:59:32 +0000 (20:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64325 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
lib/CodeGen/CodeGenFunction.h

index f7bbb606a7beab23e761a14ed13f9953d13126f2..4d6c3f1c2867383a2c597ff3dd30c4b12ad84a0c 100644 (file)
@@ -137,6 +137,8 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
   case Expr::CallExprClass: 
   case Expr::CXXOperatorCallExprClass:
     return EmitCallExprLValue(cast<CallExpr>(E));
+  case Expr::VAArgExprClass:
+    return EmitVAArgExprLValue(cast<VAArgExpr>(E));
   case Expr::DeclRefExprClass: 
   case Expr::QualifiedDeclRefExprClass:
     return EmitDeclRefLValue(cast<DeclRefExpr>(E));
@@ -996,11 +998,17 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
 LValue CodeGenFunction::EmitCallExprLValue(const CallExpr *E) {
   // Can only get l-value for call expression returning aggregate type
   RValue RV = EmitCallExpr(E);
-  // FIXME: can this be volatile?
   return LValue::MakeAddr(RV.getAggregateAddr(),
                           E->getType().getCVRQualifiers());
 }
 
+LValue CodeGenFunction::EmitVAArgExprLValue(const VAArgExpr *E) {
+  // FIXME: This shouldn't require another copy.
+  llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType()));
+  EmitAggExpr(E, Temp, false);
+  return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers());
+}
+
 LValue
 CodeGenFunction::EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E) {
   EmitLocalBlockVarDecl(*E->getVarDecl());
index fcd0ebaa0a87959c5787ae7e4c24af4660ee1070..39f1c1d6cafaf62d45cdc2e6cd16d1e9a40ea1f6 100644 (file)
@@ -555,8 +555,10 @@ public:
 
   // Note: only availabe for agg return types
   LValue EmitBinaryOperatorLValue(const BinaryOperator *E);
-  // Note: only availabe for agg return types
+  // Note: only available for agg return types
   LValue EmitCallExprLValue(const CallExpr *E);
+  // Note: only available for agg return types
+  LValue EmitVAArgExprLValue(const VAArgExpr *E);
   LValue EmitDeclRefLValue(const DeclRefExpr *E);
   LValue EmitStringLiteralLValue(const StringLiteral *E);
   LValue EmitPredefinedFunctionName(unsigned Type);