Expose the logic for field address codegen; it is needed for aggregate
initializers, and I don't want to duplicate the bitfield-handling code.
(I'll send a patch for aggregate initializers to the mailing
list sometime soon.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46904 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index 9c78768..6baf17f 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -454,7 +454,6 @@
}
LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
- llvm::Value *V;
bool isUnion = false;
Expr *BaseExpr = E->getBase();
llvm::Value *BaseValue = NULL;
@@ -476,8 +475,15 @@
}
FieldDecl *Field = E->getMemberDecl();
- unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);
+ return EmitLValueForField(BaseValue, Field, isUnion);
+}
+LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
+ FieldDecl* Field,
+ bool isUnion)
+{
+ llvm::Value *V;
+ unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);
if (Field->isBitField()) {
const llvm::Type * FieldTy = ConvertType(Field->getType());
@@ -568,7 +574,7 @@
for (unsigned i = 0, e = NumArgs; i != e; ++i) {
QualType ArgTy = ArgExprs[i]->getType();
-
+
if (!hasAggregateLLVMType(ArgTy)) {
// Scalar argument is passed by-value.
Args.push_back(EmitScalarExpr(ArgExprs[i]));