[cfe-commits] r104673 - in /cfe/trunk/lib/AST: RecordLayoutBuilder.cpp RecordLayoutBuilder.h

Anders Carlsson andersca at mac.com
Tue May 25 22:10:47 PDT 2010


Author: andersca
Date: Wed May 26 00:10:47 2010
New Revision: 104673

URL: http://llvm.org/viewvc/llvm-project?rev=104673&view=rev
Log:
Fold the other Layout overload into its sole call site.

Modified:
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
    cfe/trunk/lib/AST/RecordLayoutBuilder.h

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=104673&r1=104672&r2=104673&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed May 26 00:10:47 2010
@@ -967,8 +967,43 @@
   const ASTRecordLayout *Entry = ASTRecordLayouts[D];
   if (Entry) return *Entry;
 
-  const ASTRecordLayout *NewEntry =
-    ASTRecordLayoutBuilder::ComputeLayout(*this, D);
+  const ASTRecordLayout *NewEntry;
+
+  if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
+    ASTRecordLayoutBuilder Builder(*this);
+    Builder.Layout(RD);
+
+    // FIXME: This is not always correct. See the part about bitfields at
+    // http://www.codesourcery.com/public/cxx-abi/abi.html#POD for more info.
+    // FIXME: IsPODForThePurposeOfLayout should be stored in the record layout.
+    bool IsPODForThePurposeOfLayout = cast<CXXRecordDecl>(D)->isPOD();
+
+    // FIXME: This should be done in FinalizeLayout.
+    uint64_t DataSize =
+      IsPODForThePurposeOfLayout ? Builder.Size : Builder.DataSize;
+    uint64_t NonVirtualSize =
+      IsPODForThePurposeOfLayout ? DataSize : Builder.NonVirtualSize;
+
+    NewEntry = 
+      new (*this) ASTRecordLayout(*this, Builder.Size, Builder.Alignment,
+                                  DataSize, Builder.FieldOffsets.data(),
+                                  Builder.FieldOffsets.size(),
+                                  NonVirtualSize,
+                                  Builder.NonVirtualAlignment,
+                                  Builder.SizeOfLargestEmptySubobject,
+                                  Builder.PrimaryBase,
+                                  Builder.Bases, Builder.VBases);
+  } else {
+    ASTRecordLayoutBuilder Builder(*this);
+    Builder.Layout(D);
+  
+    NewEntry =
+      new (*this) ASTRecordLayout(*this, Builder.Size, Builder.Alignment,
+                                  Builder.Size,
+                                  Builder.FieldOffsets.data(),
+                                  Builder.FieldOffsets.size());
+  }
+
   ASTRecordLayouts[D] = NewEntry;
 
   if (getLangOptions().DumpRecordLayouts) {

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.h?rev=104673&r1=104672&r2=104673&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.h (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.h Wed May 26 00:10:47 2010
@@ -93,7 +93,6 @@
   ASTRecordLayoutBuilder(ASTContext &Ctx);
 
   void Layout(const RecordDecl *D);
-  void Layout(const CXXRecordDecl *D);
   void Layout(const ObjCInterfaceDecl *D);
 
   void LayoutFields(const RecordDecl *D);





More information about the cfe-commits mailing list