diff options
author | Devang Patel <dpatel@apple.com> | 2009-03-16 23:47:53 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-03-16 23:47:53 +0000 |
commit | ec9b5d510b4068bf6cf87cc8729ee7d5018c2b32 (patch) | |
tree | b4f8e859d0cc48f07780b1140a2372e57459e7a4 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 1ac02dcb60177c1c1b36526323be76a57efcc468 (diff) |
Fix struct field's debug info.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67062 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
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 |