]> granicus.if.org Git - clang/commitdiff
More fix for bitfield ivar meta-data and code gen accessing it.
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 9 Mar 2009 20:44:22 +0000 (20:44 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 9 Mar 2009 20:44:22 +0000 (20:44 +0000)
Now, we can actually execute dejagnu test with bitfield ivars
in non-fragile abi mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66448 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp

index 9922d82fc2b5d2af73067241cd3d785cf79ba7d6..5ae32e8737d271b9704e900b33ab80fe37ada9db 100644 (file)
@@ -1842,10 +1842,15 @@ llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD,
 
 uint64_t CGObjCCommonMac::GetIvarBaseOffset(const llvm::StructLayout *Layout,
                                             FieldDecl *Field) {
-  return Field->isBitField() 
-           ? CGM.getTypes().getLLVMFieldNo(Field) 
-           : Layout->getElementOffset(
-               CGM.getTypes().getLLVMFieldNo(Field));
+  if (!Field->isBitField())
+    return Layout->getElementOffset(
+            CGM.getTypes().getLLVMFieldNo(Field));
+  // FIXME. Must be a better way of getting a bitfield base offset.
+  uint64_t offset = CGM.getTypes().getLLVMFieldNo(Field);
+  const llvm::Type *Ty = CGM.getTypes().ConvertTypeForMemRecursive(Field->getType());
+  uint64_t size = CGM.getTypes().getTargetData().getTypePaddedSizeInBits(Ty);
+  offset = (offset*size)/8; 
+  return offset;
 }
 
 llvm::GlobalVariable *
@@ -4485,10 +4490,14 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
   llvm::Type *ptrIvarTy = llvm::PointerType::getUnqual(IvarTy);
   V = CGF.Builder.CreateBitCast(V, ptrIvarTy);
   
-  if (Ivar->isBitField())
-    return CGF.EmitLValueForBitfield(V, const_cast<FieldDecl *>(Field), 
-                                     CVRQualifiers);
-  
+  if (Ivar->isBitField()) {
+    CodeGenTypes::BitFieldInfo bitFieldInfo =
+                                 CGM.getTypes().getBitFieldInfo(Field);
+    return LValue::MakeBitfield(V, bitFieldInfo.Begin, bitFieldInfo.Size,
+                                Field->getType()->isSignedIntegerType(),
+                                Field->getType().getCVRQualifiers()|CVRQualifiers);
+  }
+
   LValue LV = LValue::MakeAddr(V, 
               Ivar->getType().getCVRQualifiers()|CVRQualifiers,
               CGM.getContext().getObjCGCAttrKind(Ivar->getType()));