aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-03-16 23:47:53 +0000
committerDevang Patel <dpatel@apple.com>2009-03-16 23:47:53 +0000
commitec9b5d510b4068bf6cf87cc8729ee7d5018c2b32 (patch)
treeb4f8e859d0cc48f07780b1140a2372e57459e7a4 /lib/CodeGen/CGDebugInfo.cpp
parent1ac02dcb60177c1c1b36526323be76a57efcc468 (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.cpp18
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