r352995 - [objc-gnustep] Fix encoding of ivar size for _Bool.

David Chisnall via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 3 07:05:52 PST 2019


Author: theraven
Date: Sun Feb  3 07:05:52 2019
New Revision: 352995

URL: http://llvm.org/viewvc/llvm-project?rev=352995&view=rev
Log:
[objc-gnustep] Fix encoding of ivar size for _Bool.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
    cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=352995&r1=352994&r2=352995&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Sun Feb  3 07:05:52 2019
@@ -1728,7 +1728,6 @@ class CGObjCGNUstep2 : public CGObjCGNUs
           CGM.getContext().getCharWidth());
       // struct objc_ivar ivars[]
       auto ivarArrayBuilder = ivarListBuilder.beginArray();
-      CodeGenTypes &Types = CGM.getTypes();
       for (const ObjCIvarDecl *IVD = classDecl->all_declared_ivar_begin(); IVD;
            IVD = IVD->getNextIvar()) {
         auto ivarTy = IVD->getType();
@@ -1762,8 +1761,7 @@ class CGObjCGNUstep2 : public CGObjCGNUs
         ivarBuilder.add(OffsetVar);
         // Ivar size
         ivarBuilder.addInt(Int32Ty,
-            td.getTypeSizeInBits(Types.ConvertType(ivarTy)) /
-              CGM.getContext().getCharWidth());
+            CGM.getContext().getTypeSizeInChars(ivarTy).getQuantity());
         // Alignment will be stored as a base-2 log of the alignment.
         int align = llvm::Log2_32(Context.getTypeAlignInChars(ivarTy).getQuantity());
         // Objects that require more than 2^64-byte alignment should be impossible!

Modified: cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m?rev=352995&r1=352994&r2=352995&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m (original)
+++ cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m Sun Feb  3 07:05:52 2019
@@ -19,10 +19,12 @@
 @package
 // CHECK: @__objc_ivar_offset_ANObject._intIvar.i = hidden global i32 16
   int         _intIvar;
+  _Bool       boolIvar;
 }
 @end
 @implementation ANObject @end
 
 // Check that the ivar metadata contains 3 entries of the correct form and correctly sets the size.
-// CHECK: @.objc_ivar_list = private global { i32, i64, [3 x { i8*, i8*, i32*, i32, i32 }] } { i32 3, i64 32,
-// Check that we're emitting the extended type encoding for the string ivar.
+// CHECK: @.objc_ivar_list = private global { i32, i64, [4 x { i8*, i8*, i32*, i32, i32 }] } { i32 4, i64 32,
+// Check that we emit 1 as the size of _Bool, not 0.
+// CHECK-SAME:  @__objc_ivar_offset_ANObject.boolIvar.B, i32 1, i32 4




More information about the cfe-commits mailing list