diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 1f56bb7e1684..a4fb431f8ed6 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -124,10 +124,9 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF, // 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( - LTy, FieldNo, BitOffset, BitFieldSize, IvarTy->isSignedIntegerType()); + new (CGF.CGM.getContext()) CGBitFieldInfo(BitFieldSize, + IvarTy->isSignedIntegerType()); // We always construct a single, possibly unaligned, access for this case. Info->setNumComponents(1); diff --git a/clang/lib/CodeGen/CGRecordLayout.h b/clang/lib/CodeGen/CGRecordLayout.h index 86ae27e2bb51..dd60dbd593bf 100644 --- a/clang/lib/CodeGen/CGRecordLayout.h +++ b/clang/lib/CodeGen/CGRecordLayout.h @@ -77,9 +77,6 @@ public: }; private: - /// The number of access components to use. - unsigned NumComponents; - /// The components to use to access the bit-field. We may need up to three /// separate components to support up to i64 bit-field access (4 + 2 + 1 byte /// accesses). @@ -87,19 +84,19 @@ private: // FIXME: De-hardcode this, just allocate following the struct. AccessInfo Components[3]; -public: - CGBitFieldInfo(const llvm::Type *FieldTy, unsigned FieldNo, - unsigned Start, unsigned Size, bool IsSigned) - : FieldTy(FieldTy), FieldNo(FieldNo), - Start(Start), Size(Size), IsSigned(IsSigned) {} - - const llvm::Type *FieldTy; - unsigned FieldNo; - - unsigned Start; + /// The total size of the bit-field, in bits. unsigned Size; + + /// The number of access components to use. + unsigned NumComponents; + + /// Whether the bit-field is signed. bool IsSigned : 1; +public: + CGBitFieldInfo(unsigned Size, bool IsSigned) + : Size(Size), IsSigned(IsSigned) {} + public: /// \brief Check whether this bit-field access is (i.e., should be sign /// extended on loads). diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 45acb03450f0..cfdae2445e6f 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -153,15 +153,15 @@ static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types, uint64_t TypeSizeInBytes = Types.getTargetData().getTypeAllocSize(Ty); uint64_t TypeSizeInBits = TypeSizeInBytes * 8; + unsigned StartBit = FieldOffset % TypeSizeInBits; bool IsSigned = FD->getType()->isSignedIntegerType(); - CGBitFieldInfo BFI(Ty, FieldOffset / TypeSizeInBits, - FieldOffset % TypeSizeInBits, FieldSize, IsSigned); + CGBitFieldInfo BFI(FieldSize, IsSigned); // The current policy is to always access the bit-field using the source type // of the bit-field. With the C bit-field rules, this implies that we always // use either one or two accesses, and two accesses can only occur with a // packed structure when the bit-field straddles an alignment boundary. - unsigned LowBits = std::min(FieldSize, TypeSizeInBits - BFI.Start); + unsigned LowBits = std::min(FieldSize, TypeSizeInBits - StartBit); bool NeedsHighAccess = LowBits != FieldSize; BFI.setNumComponents(1 + NeedsHighAccess); @@ -170,7 +170,7 @@ static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types, LowAccess.FieldIndex = 0; LowAccess.FieldByteOffset = TypeSizeInBytes * ((FieldOffset / 8) / TypeSizeInBytes); - LowAccess.FieldBitStart = BFI.Start; + LowAccess.FieldBitStart = StartBit; LowAccess.AccessWidth = TypeSizeInBits; // FIXME: This might be wrong! LowAccess.AccessAlignment = 0; @@ -565,9 +565,6 @@ void CGRecordLayout::dump() const { void CGBitFieldInfo::print(llvm::raw_ostream &OS) const { OS << "