From: Devang Patel Date: Mon, 16 Mar 2009 23:47:53 +0000 (+0000) Subject: Fix struct field's debug info. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec9b5d510b4068bf6cf87cc8729ee7d5018c2b32;p=clang Fix struct field's debug info. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67062 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 0dac6ba920..b0cf07789b 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -257,10 +257,22 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, SourceLocation FieldDefLoc = Field->getLocation(); llvm::DICompileUnit FieldDefUnit = getOrCreateCompileUnit(FieldDefLoc); unsigned FieldLine = SM.getInstantiationLineNumber(FieldDefLoc); + + QualType FType = Field->getType(); + uint64_t FieldSize = 0; + unsigned FieldAlign = 0; + if (!FType->isIncompleteArrayType()) { - // Bit size, align and offset of the type. - uint64_t FieldSize = M->getContext().getTypeSize(Ty); - unsigned FieldAlign = M->getContext().getTypeAlign(Ty); + // Bit size, align and offset of the type. + FieldSize = M->getContext().getTypeSize(FType); + Expr *BitWidth = Field->getBitWidth(); + if (BitWidth) + FieldSize = + BitWidth->getIntegerConstantExprValue(M->getContext()).getZExtValue(); + + FieldAlign = M->getContext().getTypeAlign(FType); + } + uint64_t FieldOffset = RL.getFieldOffset(FieldNo); // Create a DW_TAG_member node to remember the offset of this field in the