/// bitfield which follows the bitfield 'LastFD'.
bool BitfieldFollowsBitfield(const FieldDecl *FD,
const FieldDecl *LastFD) const;
+
+ /// NoneBitfieldFollowsBitfield - return 'true" if 'FD' is not a
+ /// bitfield which follows the bitfield 'LastFD'.
+ bool NoneBitfieldFollowsBitfield(const FieldDecl *FD,
+ const FieldDecl *LastFD) const;
+
+ /// BitfieldFollowsNoneBitfield - return 'true" if 'FD' is a
+ /// bitfield which follows the none bitfield 'LastFD'.
+ bool BitfieldFollowsNoneBitfield(const FieldDecl *FD,
+ const FieldDecl *LastFD) const;
// Access to the set of methods overridden by the given C++ method.
typedef CXXMethodVector::iterator overridden_cxx_method_iterator;
LastFD->getBitWidth()-> EvaluateAsInt(*this).getZExtValue());
}
+bool ASTContext::NoneBitfieldFollowsBitfield(const FieldDecl *FD,
+ const FieldDecl *LastFD) const {
+ return (!FD->isBitField() && LastFD && LastFD->isBitField() &&
+ LastFD->getBitWidth()-> EvaluateAsInt(*this).getZExtValue());
+}
+
+bool ASTContext::BitfieldFollowsNoneBitfield(const FieldDecl *FD,
+ const FieldDecl *LastFD) const {
+ return (FD->isBitField() && LastFD && !LastFD->isBitField() &&
+ FD->getBitWidth()-> EvaluateAsInt(*this).getZExtValue());
+}
+
ASTContext::overridden_cxx_method_iterator
ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos
// ignored:
else if (Context.ZeroBitfieldFollowsNonBitfield(FD, LastFD))
continue;
- else if (Context.BitfieldFollowsBitfield(FD, LastFD)) {
+ else if (Context.BitfieldFollowsBitfield(FD, LastFD) ||
+ Context.BitfieldFollowsNoneBitfield(FD, LastFD)) {
// Adjacent bit fields are packed into the same 1-, 2-, or
// 4-byte allocation unit if the integral types are the same
// size and if the next bit field fits into the current
// allocation unit without crossing the boundary imposed by the
// common alignment requirements of the bit fields.
+ // Also, establish a new alignment for a bitfield following
+ // a non-bitfield if size of their types differ.
std::pair<uint64_t, unsigned> FieldInfo =
Context.getTypeInfo(FD->getType());
uint64_t TypeSize = FieldInfo.first;
--- /dev/null
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+struct _struct_0
+{
+ int member_0 : 25 ;
+ short member_1 : 6 ;
+ char member_2 : 2 ;
+ unsigned short member_3 : 1 ;
+ unsigned char member_4 : 7 ;
+ short member_5 : 16 ;
+ int : 0 ;
+ char member_7 ;
+
+} ATTR;
+
+typedef struct _struct_0 struct_0;
+
+#define size_struct_0 20
+
+struct_0 test_struct_0 = { 18557917, 17, 3, 0, 80, 6487, 93 };
+static int a[(size_struct_0 == sizeof (struct_0)) -1];