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 | bd93351c42974332fd5805c5b3952918056423a0 (patch) | |
tree | 23b7ee0090f76c1eb38940dd279761db877831f0 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 9fa1ab7d0c71a8ee69323e735fdfa6b8417485a2 (diff) | |
download | bcm5719-llvm-bd93351c42974332fd5805c5b3952918056423a0.tar.gz bcm5719-llvm-bd93351c42974332fd5805c5b3952918056423a0.zip |
Fix struct field's debug info.
llvm-svn: 67062
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0dac6ba920e..b0cf07789b5 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/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 |