From: David Chisnall Date: Sun, 3 Feb 2019 15:05:52 +0000 (+0000) Subject: [objc-gnustep] Fix encoding of ivar size for _Bool. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e65e062ca5e874f355f5b51f7d65635fd86cfd58;p=clang [objc-gnustep] Fix encoding of ivar size for _Bool. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352995 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index b7254779e7..7e2ac81843 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -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! diff --git a/test/CodeGenObjC/gnustep2-ivar-offset.m b/test/CodeGenObjC/gnustep2-ivar-offset.m index 432fa567de..49f24b40be 100644 --- a/test/CodeGenObjC/gnustep2-ivar-offset.m +++ b/test/CodeGenObjC/gnustep2-ivar-offset.m @@ -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