]> granicus.if.org Git - clang/commitdiff
[objc-gnustep] Fix encoding of ivar size for _Bool.
authorDavid Chisnall <csdavec@swan.ac.uk>
Sun, 3 Feb 2019 15:05:52 +0000 (15:05 +0000)
committerDavid Chisnall <csdavec@swan.ac.uk>
Sun, 3 Feb 2019 15:05:52 +0000 (15:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352995 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCGNU.cpp
test/CodeGenObjC/gnustep2-ivar-offset.m

index b7254779e72a3f89890c063fe764cfc455ca65ee..7e2ac8184352f6f8ed4ab7903a21bf116b84bfea 100644 (file)
@@ -1728,7 +1728,6 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
           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 CGObjCGNUstep {
         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!
index 432fa567de3072b64906549e38a141361a0a0c67..49f24b40bea2ef748a7bdbb1de0fd12f00bbd5ee 100644 (file)
 @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