summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 5373390..ac8fa05 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -107,24 +107,31 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
Qualifiers Quals = CGF.MakeQualifiers(IvarTy);
Quals.addCVRQualifiers(CVRQualifiers);
- if (Ivar->isBitField()) {
- // We need to compute the bit offset for the bit-field, the offset
- // is to the byte. Note, there is a subtle invariant here: we can
- // only call this routine on non-sythesized ivars but we may be
- // called for synthesized ivars. However, a synthesized ivar can
- // never be a bit-field so this is safe.
- uint64_t BitOffset = LookupFieldBitOffset(CGF.CGM, OID, 0, Ivar) % 8;
-
- uint64_t BitFieldSize =
- Ivar->getBitWidth()->EvaluateAsInt(CGF.getContext()).getZExtValue();
- return LValue::MakeBitfield(V, BitOffset, BitFieldSize,
- IvarTy->isSignedIntegerType(),
- Quals.getCVRQualifiers());
- }
-
-
- LValue LV = LValue::MakeAddr(V, Quals);
- return LV;
+ if (!Ivar->isBitField())
+ return LValue::MakeAddr(V, Quals);
+
+ // We need to compute the bit offset for the bit-field, the offset is to the
+ // byte. Note, there is a subtle invariant here: we can only call this routine
+ // on non-synthesized ivars but we may be called for synthesized ivars.
+ // However, a synthesized ivar can never be a bit-field, so this is safe.
+ uint64_t BitOffset = LookupFieldBitOffset(CGF.CGM, OID, 0, Ivar) % 8;
+ uint64_t BitFieldSize =
+ Ivar->getBitWidth()->EvaluateAsInt(CGF.getContext()).getZExtValue();
+
+ // Allocate a new CGBitFieldInfo object to describe this access.
+ //
+ // FIXME: This is incredibly wasteful, these should be uniqued or part of some
+ // layout object. However, this is blocked on other cleanups to the
+ // Objective-C code, so for now we just live with allocating a bunch of these
+ // objects.
+ unsigned FieldNo = 0; // This value is unused.
+ CGBitFieldInfo *Info =
+ new (CGF.CGM.getContext()) CGBitFieldInfo(FieldNo, BitOffset, BitFieldSize,
+ IvarTy->isSignedIntegerType());
+
+ // FIXME: We need to set a very conservative alignment on this, or make sure
+ // that the runtime is doing the right thing.
+ return LValue::MakeBitfield(V, *Info, Quals.getCVRQualifiers());
}
///
@@ -3128,7 +3135,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
const CGRecordLayout &RL =
CGM.getTypes().getCGRecordLayout(Field->getParent());
if (Field->isBitField()) {
- const CGRecordLayout::BitFieldInfo &Info = RL.getBitFieldInfo(Field);
+ const CGBitFieldInfo &Info = RL.getBitFieldInfo(Field);
const llvm::Type *Ty =
CGM.getTypes().ConvertTypeForMemRecursive(Field->getType());
OpenPOWER on IntegriCloud