]> granicus.if.org Git - clang/commitdiff
Expose the logic for field address codegen; it is needed for aggregate
authorEli Friedman <eli.friedman@gmail.com>
Sat, 9 Feb 2008 08:50:58 +0000 (08:50 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 9 Feb 2008 08:50:58 +0000 (08:50 +0000)
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

CodeGen/CGExpr.cpp
CodeGen/CodeGenFunction.h

index 9c7876830cb42e5e4156e8ebda7bbf05219e454e..6baf17fb10501186c7c311223126d5697165f1d3 100644 (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]));
index c741071d00d9afa4ff0df20c759ac9c2ea8eba91..e88575293311cd453559a4272ce5c94ee8153a3c 100644 (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