]> granicus.if.org Git - clang/commitdiff
Set field info for unions.
authorAnders Carlsson <andersca@mac.com>
Thu, 23 Jul 2009 04:59:05 +0000 (04:59 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 23 Jul 2009 04:59:05 +0000 (04:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76856 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGRecordLayoutBuilder.cpp

index 1631c43eb99d9f728739da564f11e9e08f9a7b04..fa096bd63067dc9b08876eea82a268c23cede987 100644 (file)
@@ -151,6 +151,7 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
   
   const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D);
   
+  const FieldDecl *FD = 0;
   const llvm::Type *Ty = 0;
   uint64_t Size = 0;
   unsigned Align = 0;
@@ -182,12 +183,21 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
       Ty = FieldTy;
       Align = FieldAlign;
       Size = FieldSize;
+      FD = *Field;
     }
   }
   
   // Now add our field.
-  if (Ty)
+  if (FD) {
     AppendField(0, Size, Ty);
+    Types.addFieldInfo(FD, 0);
+    
+    if (FD->isBitField()) {
+      uint64_t FieldSize = 
+        FD->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue();
+      Types.addBitFieldInfo(FD, 0, FieldSize);
+    }
+  }
   
   // Append tail padding.
   if (Layout.getSize() / 8 > Size)