From: Fariborz Jahanian Date: Thu, 28 Apr 2011 23:43:23 +0000 (+0000) Subject: Fixes debug info generation problem for ms_struct structs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fbc3cc69d2028eccb85bb456d762457b38a65e3b;p=clang Fixes debug info generation problem for ms_struct structs. // rdar://8823265 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130458 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 11a0fac2ea..4b2b908516 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -618,18 +618,31 @@ void CGDebugInfo:: CollectRecordFields(const RecordDecl *record, llvm::DIFile tunit, llvm::SmallVectorImpl &elements) { unsigned fieldNo = 0; + const FieldDecl *LastFD = 0; + bool IsMsStruct = record->hasAttr(); + const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(record); for (RecordDecl::field_iterator I = record->field_begin(), E = record->field_end(); I != E; ++I, ++fieldNo) { FieldDecl *field = *I; + if (IsMsStruct) { + // Zero-length bitfields following non-bitfield members are ignored + if (CGM.getContext().ZeroBitfieldFollowsNonBitfield((field), LastFD)) { + --fieldNo; + continue; + } + LastFD = field; + } llvm::StringRef name = field->getName(); QualType type = field->getType(); // Ignore unnamed fields unless they're anonymous structs/unions. - if (name.empty() && !type->isRecordType()) + if (name.empty() && !type->isRecordType()) { + LastFD = field; continue; + } llvm::DIType fieldType = createFieldType(name, type, field->getBitWidth(),