mirror of https://github.com/microsoft/clang.git
Objective-C. Fixes an assert where because of captured
variable in block is over-aligned with an align attribute causing block metadata size not be multiple of alignment. rdar://17878679 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215449 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1cb6d934f5
commit
b452261a38
|
@ -539,6 +539,16 @@ static void computeBlockInfo(CodeGenModule &CGM, CodeGenFunction *CGF,
|
|||
// multiple of alignment.
|
||||
for (SmallVectorImpl<BlockLayoutChunk>::iterator
|
||||
li = layout.begin(), le = layout.end(); li != le; ++li) {
|
||||
if (endAlign < li->Alignment) {
|
||||
// size may not be multiple of alignment. This can only happen with
|
||||
// an over-aligned variable. We will be adding a padding field to
|
||||
// make the size be multiple of alignment.
|
||||
CharUnits padding = li->Alignment - endAlign;
|
||||
elementTypes.push_back(llvm::ArrayType::get(CGM.Int8Ty,
|
||||
padding.getQuantity()));
|
||||
blockSize += padding;
|
||||
endAlign = getLowBit(blockSize);
|
||||
}
|
||||
assert(endAlign >= li->Alignment);
|
||||
li->setIndex(info, elementTypes.size());
|
||||
elementTypes.push_back(li->Type);
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s
|
||||
// rdar://17878679
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int i;
|
||||
} GAXBackboardState __attribute__ ((aligned(32))); // minimum alignment is 32-byte boundary
|
||||
|
||||
@interface GAXSpringboard @end
|
||||
|
||||
@implementation GAXSpringboard
|
||||
{
|
||||
GAXBackboardState _reflectedBackboardState;
|
||||
}
|
||||
|
||||
- (void) MyMethod
|
||||
{
|
||||
GAXBackboardState newBackboardState;
|
||||
^{
|
||||
_reflectedBackboardState = newBackboardState;
|
||||
return newBackboardState.i;
|
||||
}();
|
||||
}
|
||||
@end
|
||||
|
Loading…
Reference in New Issue