Don't crash (assert failure) when generating blocks for C++ types with a non-const copy constructor.

This was caused by the code deciding the number of fields in the byref structure using a different test to the part of the code creating the GEPs into said structure.  

llvm-svn: 154013
This commit is contained in:
David Chisnall 2012-04-04 13:07:13 +00:00
parent d01a99ea41
commit 5221a947a5
2 changed files with 21 additions and 1 deletions

View File

@ -1850,7 +1850,8 @@ llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) {
// int32_t __size;
types.push_back(Int32Ty);
bool HasCopyAndDispose = getContext().BlockRequiresCopying(Ty);
bool HasCopyAndDispose =
(Ty->isObjCRetainableType()) || getContext().getBlockVarCopyInits(D);
if (HasCopyAndDispose) {
/// void *__copy_helper;
types.push_back(Int8PtrTy);

View File

@ -0,0 +1,19 @@
// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks
// Just test that this doesn't crash the compiler...
void func(void*);
struct Test
{
virtual void use() { func((void*)this); }
Test(Test&c) { func((void*)this); }
Test() { func((void*)this); }
};
void useBlock(void (^)(void));
int main (void) {
__block Test t;
useBlock(^(void) { t.use(); });
}