forked from OSchip/llvm-project
Added generation of destructors for member constant size arrays.
There's only one destructor call generated for each not empty array (at least for now this should be enough). llvm-svn: 117252
This commit is contained in:
parent
52e4bc1fed
commit
01769904d3
|
@ -552,7 +552,15 @@ void CFGBuilder::addImplicitDtorsForDestructor(const CXXDestructorDecl *DD) {
|
|||
// First destroy member objects.
|
||||
for (CXXRecordDecl::field_iterator FI = RD->field_begin(),
|
||||
FE = RD->field_end(); FI != FE; ++FI) {
|
||||
if (const CXXRecordDecl *CD = FI->getType()->getAsCXXRecordDecl())
|
||||
// Check for constant size array. Set type to array element type.
|
||||
QualType QT = FI->getType();
|
||||
if (const ConstantArrayType *AT = Context->getAsConstantArrayType(QT)) {
|
||||
if (AT->getSize() == 0)
|
||||
continue;
|
||||
QT = AT->getElementType();
|
||||
}
|
||||
|
||||
if (const CXXRecordDecl *CD = QT->getAsCXXRecordDecl())
|
||||
if (!CD->hasTrivialDestructor()) {
|
||||
autoCreateBlock();
|
||||
appendMemberDtor(Block, *FI);
|
||||
|
@ -2729,8 +2737,13 @@ static void print_elem(llvm::raw_ostream &OS, StmtPrinterHelper* Helper,
|
|||
|
||||
} else if (CFGMemberDtor ME = E.getAs<CFGMemberDtor>()) {
|
||||
FieldDecl *FD = ME.getFieldDecl();
|
||||
|
||||
const Type *T = FD->getType().getTypePtr();
|
||||
if (const Type *ET = T->getArrayElementTypeNoTypeQual())
|
||||
T = ET;
|
||||
|
||||
OS << "this->" << FD->getName();
|
||||
OS << ".~" << FD->getType()->getAsCXXRecordDecl()->getName() << "()";
|
||||
OS << ".~" << T->getAsCXXRecordDecl()->getName() << "()";
|
||||
OS << " (Member object destructor)\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,15 @@ public:
|
|||
|
||||
TestOrder::~TestOrder() {}
|
||||
|
||||
class TestArray {
|
||||
A a[2];
|
||||
A b[0];
|
||||
public:
|
||||
~TestArray();
|
||||
};
|
||||
|
||||
TestArray::~TestArray() {}
|
||||
|
||||
// CHECK: [ B2 (ENTRY) ]
|
||||
// CHECK: Predecessors (0):
|
||||
// CHECK: Successors (1): B1
|
||||
|
@ -39,3 +48,13 @@ TestOrder::~TestOrder() {}
|
|||
// CHECK: [ B0 (EXIT) ]
|
||||
// CHECK: Predecessors (1): B1
|
||||
// CHECK: Successors (0):
|
||||
// CHECK: [ B2 (ENTRY) ]
|
||||
// CHECK: Predecessors (0):
|
||||
// CHECK: Successors (1): B1
|
||||
// CHECK: [ B1 ]
|
||||
// CHECK: 1: this->a.~A() (Member object destructor)
|
||||
// CHECK: Predecessors (1): B2
|
||||
// CHECK: Successors (1): B0
|
||||
// CHECK: [ B0 (EXIT) ]
|
||||
// CHECK: Predecessors (1): B1
|
||||
// CHECK: Successors (0):
|
||||
|
|
Loading…
Reference in New Issue