]> granicus.if.org Git - clang/commitdiff
Add a utility to get a RValue for a given LValue for an aggregate; switch a few place...
authorEli Friedman <eli.friedman@gmail.com>
Sat, 3 Dec 2011 03:08:40 +0000 (03:08 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 3 Dec 2011 03:08:40 +0000 (03:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145747 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGValue.h

index 4f2210f10e4f9c40e76afd08402d57b0f218b546..93bc1753ce89e831f1959853081b4900837fb8e9 100644 (file)
@@ -1463,8 +1463,7 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
       cast<CastExpr>(E)->getCastKind() == CK_LValueToRValue) {
     LValue L = EmitLValue(cast<CastExpr>(E)->getSubExpr());
     assert(L.isSimple());
-    args.add(RValue::getAggregate(L.getAddress(), L.isVolatileQualified()),
-             type, /*NeedsCopy*/true);
+    args.add(L.asAggregateRValue(), type, /*NeedsCopy*/true);
     return;
   }
 
@@ -1518,7 +1517,7 @@ void CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
         // FIXME: Volatile?
         EltRV = RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
       else if (CodeGenFunction::hasAggregateLLVMType(EltTy))
-        EltRV = RValue::getAggregate(LV.getAddress());
+        EltRV = LV.asAggregateRValue();
       else
         EltRV = EmitLoadOfLValue(LV);
       ExpandTypeToArgs(EltTy, EltRV, Args, IRFuncTy);
@@ -1539,7 +1538,7 @@ void CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
         // FIXME: Volatile?
         FldRV = RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
       else if (CodeGenFunction::hasAggregateLLVMType(FT))
-        FldRV = RValue::getAggregate(LV.getAddress());
+        FldRV = LV.asAggregateRValue();
       else
         FldRV = EmitLoadOfLValue(LV);
       ExpandTypeToArgs(FT, FldRV, Args, IRFuncTy);
index 0996339d3adc4c1ba107fa0dcf12a2f587af96b6..c55630da633e1d9f7d9f08abdbb417ec14034170 100644 (file)
@@ -263,9 +263,7 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, RValue Src, bool Ignore) {
 void AggExprEmitter::EmitFinalDestCopy(const Expr *E, LValue Src, bool Ignore) {
   assert(Src.isSimple() && "Can't have aggregate bitfield, vector, etc");
 
-  EmitFinalDestCopy(E, RValue::getAggregate(Src.getAddress(),
-                                            Src.isVolatileQualified()),
-                    Ignore);
+  EmitFinalDestCopy(E, Src.asAggregateRValue(), Ignore);
 }
 
 //===----------------------------------------------------------------------===//
index c83000bb978357cd10c5a9324ffe616b7b331d79..fd85fb24894a936b1dbc6cb736d28a1d45a35368 100644 (file)
@@ -300,6 +300,11 @@ public:
     R.Initialize(type, type.getQualifiers());
     return R;
   }
+
+  RValue asAggregateRValue() const {
+    // FIMXE: Alignment
+    return RValue::getAggregate(getAddress(), isVolatileQualified());
+  }
 };
 
 /// An aggregate value slot.