summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-07-18 21:48:39 +0000
committerAnders Carlsson <andersca@mac.com>2009-07-18 21:48:39 +0000
commit118ce16bf545a47c8754adceb699f71527c31c56 (patch)
tree91276159e943fe9e1a14f1ea71f5d46d2b479869
parentcb3f64f94564385430bc876d1363b3c6c6e14f8c (diff)
downloadbcm5719-llvm-118ce16bf545a47c8754adceb699f71527c31c56.tar.gz
bcm5719-llvm-118ce16bf545a47c8754adceb699f71527c31c56.zip
Refactor field layout into a separate function.
llvm-svn: 76343
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp14
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.h1
2 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index f4257b7d0ef..41272fdbfea 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -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;
diff --git a/clang/lib/AST/RecordLayoutBuilder.h b/clang/lib/AST/RecordLayoutBuilder.h
index cff407c5417..4a71b2b0ebb 100644
--- a/clang/lib/AST/RecordLayoutBuilder.h
+++ b/clang/lib/AST/RecordLayoutBuilder.h
@@ -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
OpenPOWER on IntegriCloud