[llvm-branch-commits] [cfe-branch] r112959 - in /cfe/branches/Apple/whitney-IB/src/tools/clang: ./ lib/CodeGen/CGRecordLayout.h lib/CodeGen/CGRecordLayoutBuilder.cpp

Daniel Dunbar daniel at zuster.org
Fri Sep 3 07:59:02 PDT 2010


Author: ddunbar
Date: Fri Sep  3 09:59:02 2010
New Revision: 112959

URL: http://llvm.org/viewvc/llvm-project?rev=112959&view=rev
Log:
--- Merging r112913 into 'src/tools/clang':
U    src/tools/clang/lib/CodeGen/CGRecordLayout.h
U    src/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp


Modified:
    cfe/branches/Apple/whitney-IB/src/tools/clang/   (props changed)
    cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayout.h
    cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp

Propchange: cfe/branches/Apple/whitney-IB/src/tools/clang/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  3 09:59:02 2010
@@ -1,2 +1,2 @@
-/cfe/trunk:112263,112268,112274,112914,112917,112943
+/cfe/trunk:112263,112268,112274,112913-112914,112917,112943
 /llvm/branches/Apple/Pertwee/tools/clang:110850,110961

Modified: cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayout.h?rev=112959&r1=112958&r2=112959&view=diff
==============================================================================
--- cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayout.h (original)
+++ cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayout.h Fri Sep  3 09:59:02 2010
@@ -144,6 +144,21 @@
 
   void print(llvm::raw_ostream &OS) const;
   void dump() const;
+
+  /// \brief Given a bit-field decl, build an appropriate helper object for
+  /// accessing that field (which is expected to have the given offset and
+  /// size).
+  static CGBitFieldInfo MakeInfo(class CodeGenTypes &Types, const FieldDecl *FD,
+                                 uint64_t FieldOffset, uint64_t FieldSize);
+
+  /// \brief Given a bit-field decl, build an appropriate helper object for
+  /// accessing that field (which is expected to have the given offset and
+  /// size). The field decl should be known to be contained within a type of at
+  /// least the given size and with the given alignment.
+  static CGBitFieldInfo MakeInfo(CodeGenTypes &Types, const FieldDecl *FD,
+                                 uint64_t FieldOffset, uint64_t FieldSize,
+                                 uint64_t ContainingTypeSizeInBits,
+                                 unsigned ContainingTypeAlign);
 };
 
 /// CGRecordLayout - This class handles struct and union layout info while

Modified: cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=112959&r1=112958&r2=112959&view=diff
==============================================================================
--- cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/branches/Apple/whitney-IB/src/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp Fri Sep  3 09:59:02 2010
@@ -157,15 +157,12 @@
   LayoutFields(D);
 }
 
-static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types,
-                                          const FieldDecl *FD,
-                                          uint64_t FieldOffset,
-                                          uint64_t FieldSize) {
-  const RecordDecl *RD = FD->getParent();
-  const ASTRecordLayout &RL = Types.getContext().getASTRecordLayout(RD);
-  uint64_t ContainingTypeSizeInBits = RL.getSize();
-  unsigned ContainingTypeAlign = RL.getAlignment();
-
+CGBitFieldInfo CGBitFieldInfo::MakeInfo(CodeGenTypes &Types,
+                               const FieldDecl *FD,
+                               uint64_t FieldOffset,
+                               uint64_t FieldSize,
+                               uint64_t ContainingTypeSizeInBits,
+                               unsigned ContainingTypeAlign) {
   const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(FD->getType());
   uint64_t TypeSizeInBytes = Types.getTargetData().getTypeAllocSize(Ty);
   uint64_t TypeSizeInBits = TypeSizeInBytes * 8;
@@ -255,6 +252,19 @@
   return CGBitFieldInfo(FieldSize, NumComponents, Components, IsSigned);
 }
 
+CGBitFieldInfo CGBitFieldInfo::MakeInfo(CodeGenTypes &Types,
+                                        const FieldDecl *FD,
+                                        uint64_t FieldOffset,
+                                        uint64_t FieldSize) {
+  const RecordDecl *RD = FD->getParent();
+  const ASTRecordLayout &RL = Types.getContext().getASTRecordLayout(RD);
+  uint64_t ContainingTypeSizeInBits = RL.getSize();
+  unsigned ContainingTypeAlign = RL.getAlignment();
+
+  return MakeInfo(Types, FD, FieldOffset, FieldSize, ContainingTypeSizeInBits,
+                  ContainingTypeAlign);
+}
+
 void CGRecordLayoutBuilder::LayoutBitField(const FieldDecl *D,
                                            uint64_t FieldOffset) {
   uint64_t FieldSize =
@@ -287,7 +297,8 @@
 
   // Add the bit field info.
   LLVMBitFields.push_back(
-    LLVMBitFieldInfo(D, ComputeBitFieldInfo(Types, D, FieldOffset, FieldSize)));
+    LLVMBitFieldInfo(D, CGBitFieldInfo::MakeInfo(Types, D, FieldOffset,
+                                                 FieldSize)));
 
   AppendBytes(NumBytesToAppend);
 
@@ -379,7 +390,8 @@
 
     // Add the bit field info.
     LLVMBitFields.push_back(
-      LLVMBitFieldInfo(Field, ComputeBitFieldInfo(Types, Field, 0, FieldSize)));
+      LLVMBitFieldInfo(Field, CGBitFieldInfo::MakeInfo(Types, Field,
+                                                       0, FieldSize)));
     return FieldTy;
   }
 





More information about the llvm-branch-commits mailing list