Minor efficiency refactor related to 193661. No functional change.
authorWarren Hunt <whunt@google.com>
Wed, 30 Oct 2013 00:14:55 +0000 (00:14 +0000)
committerWarren Hunt <whunt@google.com>
Wed, 30 Oct 2013 00:14:55 +0000 (00:14 +0000)
llvm-svn: 193665

clang/lib/CodeGen/CGRecordLayoutBuilder.cpp

index e67f517..a4e938f 100644 (file)
@@ -201,11 +201,9 @@ public:
 }
 
 void CGRecordLayoutBuilder::Layout(const RecordDecl *D) {
-  Alignment = Types.getContext().getASTRecordLayout(D).getAlignment();
-  Packed = D->hasAttr<PackedAttr>();
   const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D);
-  if (Layout.getSize() % Layout.getAlignment() != 0)
-    Packed = true;
+  Alignment = Layout.getAlignment();
+  Packed = D->hasAttr<PackedAttr>() || Layout.getSize() % Alignment != 0;
 
   if (D->isUnion()) {
     LayoutUnion(D);