]> granicus.if.org Git - clang/commitdiff
Refactor field layout into a separate function.
authorAnders Carlsson <andersca@mac.com>
Sat, 18 Jul 2009 21:48:39 +0000 (21:48 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 18 Jul 2009 21:48:39 +0000 (21:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76343 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/RecordLayoutBuilder.cpp
lib/AST/RecordLayoutBuilder.h

index f4257b7d0ef2a9d4502841c896f4edb5e916babf..41272fdbfead8e0942570d636250b35dff8fde4a 100644 (file)
@@ -32,11 +32,7 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
   if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
     UpdateAlignment(AA->getAlignment());
   
-  // Layout each field, for now, just sequentially, respecting alignment.  In
-  // the future, this will need to be tweakable by targets.
-  for (RecordDecl::field_iterator Field = D->field_begin(), 
-       FieldEnd = D->field_end(); Field != FieldEnd; ++Field)
-    LayoutField(*Field);
+  LayoutFields(D);
   
   // Finally, round the size of the total struct up to the alignment of the
   // struct itself.
@@ -73,6 +69,14 @@ void ASTRecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D,
   FinishLayout();
 }
 
+void ASTRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
+  // Layout each field, for now, just sequentially, respecting alignment.  In
+  // the future, this will need to be tweakable by targets.
+  for (RecordDecl::field_iterator Field = D->field_begin(), 
+       FieldEnd = D->field_end(); Field != FieldEnd; ++Field)
+    LayoutField(*Field);
+}
+
 void ASTRecordLayoutBuilder::LayoutField(const FieldDecl *D) {
   unsigned FieldPacking = StructPacking;
   uint64_t FieldOffset = IsUnion ? 0 : Size;
index cff407c5417121d512a415901038a073bef9d83d..4a71b2b0ebb3be5a889533fa61710429e23e0a9c 100644 (file)
@@ -37,6 +37,7 @@ class ASTRecordLayoutBuilder {
   void Layout(const ObjCInterfaceDecl *D,
               const ObjCImplementationDecl *Impl);
 
+  void LayoutFields(const RecordDecl *D);
   void LayoutField(const FieldDecl *D);
 
   /// FinishLayout - Finalize record layout. Adjust record size based on the