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.)

llvm-svn: 46904
This commit is contained in:
Eli Friedman 2008-02-09 08:50:58 +00:00
parent 6aabf837fe
commit a62f3e1352
2 changed files with 13 additions and 3 deletions

View File

@ -454,7 +454,6 @@ EmitOCUVectorElementExpr(const OCUVectorElementExpr *E) {
}
LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
llvm::Value *V;
bool isUnion = false;
Expr *BaseExpr = E->getBase();
llvm::Value *BaseValue = NULL;
@ -476,8 +475,15 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
}
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 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType,
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]));

View File

@ -71,6 +71,7 @@ namespace clang {
class BlockVarDecl;
class EnumConstantDecl;
class ParmVarDecl;
class FieldDecl;
namespace CodeGen {
class CodeGenModule;
class CodeGenTypes;
@ -415,6 +416,9 @@ public:
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E);
LValue EmitMemberExpr(const MemberExpr *E);
LValue EmitLValueForField(llvm::Value* Base, FieldDecl* Field,
bool isUnion);
//===--------------------------------------------------------------------===//
// Scalar Expression Emission