mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 17:43:57 +00:00
Fixes a Code Gen. Crash when calling destructor on a __block
variabe. Blocks and their construction/destruction is wip though. llvm-svn: 102985
This commit is contained in:
parent
f869d9adf2
commit
751f7bc03c
@ -649,6 +649,11 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
|
||||
DtorTy = getContext().getBaseElementType(Array);
|
||||
if (const RecordType *RT = DtorTy->getAs<RecordType>())
|
||||
if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
|
||||
llvm::Value *Loc = DeclPtr;
|
||||
if (isByRef)
|
||||
Loc = Builder.CreateStructGEP(DeclPtr, getByRefValueLLVMField(&D),
|
||||
D.getNameAsString());
|
||||
|
||||
if (!ClassDecl->hasTrivialDestructor()) {
|
||||
const CXXDestructorDecl *D = ClassDecl->getDestructor(getContext());
|
||||
assert(D && "EmitLocalBlockVarDecl - destructor is nul");
|
||||
@ -661,7 +666,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
|
||||
const llvm::Type *BasePtr = ConvertType(BaseElementTy);
|
||||
BasePtr = llvm::PointerType::getUnqual(BasePtr);
|
||||
llvm::Value *BaseAddrPtr =
|
||||
Builder.CreateBitCast(DeclPtr, BasePtr);
|
||||
Builder.CreateBitCast(Loc, BasePtr);
|
||||
EmitCXXAggrDestructorCall(D, Array, BaseAddrPtr);
|
||||
|
||||
// Make sure to jump to the exit block.
|
||||
@ -673,14 +678,14 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
|
||||
const llvm::Type *BasePtr = ConvertType(BaseElementTy);
|
||||
BasePtr = llvm::PointerType::getUnqual(BasePtr);
|
||||
llvm::Value *BaseAddrPtr =
|
||||
Builder.CreateBitCast(DeclPtr, BasePtr);
|
||||
Builder.CreateBitCast(Loc, BasePtr);
|
||||
EmitCXXAggrDestructorCall(D, Array, BaseAddrPtr);
|
||||
}
|
||||
} else {
|
||||
{
|
||||
DelayedCleanupBlock Scope(*this);
|
||||
EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false,
|
||||
DeclPtr);
|
||||
Loc);
|
||||
|
||||
// Make sure to jump to the exit block.
|
||||
EmitBranch(Scope.getCleanupExitBlock());
|
||||
@ -688,7 +693,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
|
||||
if (Exceptions) {
|
||||
EHCleanupBlock Cleanup(*this);
|
||||
EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false,
|
||||
DeclPtr);
|
||||
Loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
clang/test/CodeGenCXX/block-destruct.cpp
Normal file
9
clang/test/CodeGenCXX/block-destruct.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
|
||||
|
||||
struct A { ~A(); };
|
||||
|
||||
void f() {
|
||||
__block A a;
|
||||
}
|
||||
|
||||
// CHECK: call void @_ZN1AD1Ev
|
Loading…
Reference in New Issue
Block a user