]> granicus.if.org Git - clang/commitdiff
Fix ivar's size encoding.
authorDevang Patel <dpatel@apple.com>
Fri, 20 Mar 2009 18:24:39 +0000 (18:24 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 20 Mar 2009 18:24:39 +0000 (18:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67389 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index ebf403038e07c36ac86f7d752ad0bebac51cc0da..c349e4863a69ecd970760bef3aeff813d24772ee 100644 (file)
@@ -367,12 +367,25 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *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);
-    uint64_t FieldOffset = RL.getFieldOffset(FieldNo);    
+      // 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);    
+    
     unsigned Flags = 0;
     if (Field->getAccessControl() == ObjCIvarDecl::Protected)
       Flags = llvm::DIType::FlagProtected;