diff options
Diffstat (limited to 'clang/lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 44c9a90c76c..e3cba265efa 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2081,7 +2081,7 @@ llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM, llvm::SmallVector<unsigned char, 32> buffer; llvm::Constant *C = builder.buildBitmap(*this, buffer); - if (CGM.getLangOpts().ObjCGCBitmapPrint) { + if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { printf("\n block variable layout for block: "); builder.dump(buffer); } @@ -4861,6 +4861,9 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC, endOfLastScanInWords = endOfScanInWords; } + if (buffer.empty()) + return llvm::ConstantPointerNull::get(CGM.Int8PtrTy); + // For GC layouts, emit a skip to the end of the allocation so that we // have precise information about the entire thing. This isn't useful // or necessary for the ARC-style layout strings. @@ -4922,9 +4925,9 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, // up. // // ARC layout strings only include the class's ivars. In non-fragile - // runtimes, that means starting at InstanceStart. In fragile runtimes, - // there's no InstanceStart, so it means starting at the end of the - // superclass, rounded up to word alignment. + // runtimes, that means starting at InstanceStart, rounded up to word + // alignment. In fragile runtimes, there's no InstanceStart, so it means + // starting at the end of the superclass, rounded up to word alignment. // // MRC weak layout strings follow the ARC style. CharUnits baseOffset; @@ -4938,10 +4941,12 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, } else if (auto superClass = OI->getSuperClass()) { auto startOffset = CGM.getContext().getASTObjCInterfaceLayout(superClass).getSize(); - baseOffset = startOffset.RoundUpToAlignment(CGM.getPointerAlign()); + baseOffset = startOffset; } else { baseOffset = CharUnits::Zero(); } + + baseOffset = baseOffset.RoundUpToAlignment(CGM.getPointerAlign()); } else { CGM.getContext().DeepCollectObjCIvars(OI, true, ivars); @@ -4965,7 +4970,7 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, llvm::SmallVector<unsigned char, 4> buffer; llvm::Constant *C = builder.buildBitmap(*this, buffer); - if (CGM.getLangOpts().ObjCGCBitmapPrint) { + if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { printf("\n%s ivar layout for class '%s': ", ForStrongLayout ? "strong" : "weak", OMD->getClassInterface()->getName().str().c_str()); |