[cfe-commits] r69793 - /cfe/trunk/lib/CodeGen/CodeGenTypes.cpp

Daniel Dunbar daniel at zuster.org
Wed Apr 22 01:51:00 PDT 2009


Author: ddunbar
Date: Wed Apr 22 03:50:59 2009
New Revision: 69793

URL: http://llvm.org/viewvc/llvm-project?rev=69793&view=rev
Log:
Simplify.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=69793&r1=69792&r2=69793&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Wed Apr 22 03:50:59 2009
@@ -464,11 +464,20 @@
   
   const llvm::Type *ResultType;
   const RecordDecl *RD = cast<const RecordDecl>(TD);
-  if (TD->isStruct() || TD->isClass()) {
+
+  // There isn't any extra information for empty structures/unions.
+  if (RD->field_empty(getContext())) {
+    ResultType = llvm::StructType::get(std::vector<const llvm::Type*>());
+  } else {
     // Layout fields.
     RecordOrganizer RO(*this, *RD);
     
-    RO.layoutStructFields(Context.getASTRecordLayout(RD));
+    if (TD->isStruct() || TD->isClass())
+      RO.layoutStructFields(Context.getASTRecordLayout(RD));
+    else {
+      assert(TD->isUnion() && "unknown tag decl kind!");
+      RO.layoutUnionFields(Context.getASTRecordLayout(RD));
+    }
     
     // Get llvm::StructType.
     const Type *Key = 
@@ -476,27 +485,6 @@
     CGRecordLayouts[Key] = new CGRecordLayout(RO.getLLVMType(), 
                                               RO.getPaddingFields());
     ResultType = RO.getLLVMType();
-    
-  } else if (TD->isUnion()) {
-    // Just use the largest element of the union, breaking ties with the
-    // highest aligned member.
-    if (!RD->field_empty(getContext())) {
-      RecordOrganizer RO(*this, *RD);
-      
-      RO.layoutUnionFields(Context.getASTRecordLayout(RD));
-      
-      // Get llvm::StructType.
-      const Type *Key = 
-        Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
-      CGRecordLayouts[Key] = new CGRecordLayout(RO.getLLVMType(),
-                                                RO.getPaddingFields());
-      ResultType = RO.getLLVMType();
-    } else {       
-      ResultType = llvm::StructType::get(std::vector<const llvm::Type*>());
-    }
-  } else {
-    assert(0 && "FIXME: Unknown tag decl kind!");
-    abort();
   }
   
   // Refine our Opaque type to ResultType.  This can invalidate ResultType, so





More information about the cfe-commits mailing list