diff options
author | John McCall <rjmccall@apple.com> | 2011-02-13 00:46:43 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-02-13 00:46:43 +0000 |
commit | 2b3c5538fa26f5301d4498b8d6c8949d68aa20c2 (patch) | |
tree | d4cb41556fb0188c5b05c0da837ff3024fee394f /clang/lib | |
parent | 2406b7d179a38907023ffecce0ed2ddb28f8c2b6 (diff) | |
download | bcm5719-llvm-2b3c5538fa26f5301d4498b8d6c8949d68aa20c2.tar.gz bcm5719-llvm-2b3c5538fa26f5301d4498b8d6c8949d68aa20c2.zip |
Look through array types when deciding whether a field requires non-trivial
destruction in the destructor-aliases logic. Fixes PR 9197.
llvm-svn: 125447
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Type.cpp | 11 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 36d501577c4..0130b13b947 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1576,3 +1576,14 @@ bool Type::hasSizedVLAType() const { return false; } + +QualType::DestructionKind QualType::isDestructedTypeImpl(QualType type) { + /// Currently, the only destruction kind we recognize is C++ objects + /// with non-trivial destructors. + const CXXRecordDecl *record = + type->getBaseElementTypeUnsafe()->getAsCXXRecordDecl(); + if (record && !record->hasTrivialDestructor()) + return DK_cxx_destructor; + + return DK_none; +} diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index d4bd9cbc9ab..7ffc6e73255 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -60,13 +60,12 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) { return true; } - // If any fields have a non-trivial destructor, we have to emit it - // separately. + // If any field has a non-trivial destructor, we have to emit the + // destructor separately. for (CXXRecordDecl::field_iterator I = Class->field_begin(), E = Class->field_end(); I != E; ++I) - if (const RecordType *RT = (*I)->getType()->getAs<RecordType>()) - if (!cast<CXXRecordDecl>(RT->getDecl())->hasTrivialDestructor()) - return true; + if ((*I)->getType().isDestructedType()) + return true; // Try to find a unique base class with a non-trivial destructor. const CXXRecordDecl *UniqueBase = 0; |