[Codegen] Don't crash if destructor is not accessible.

Testcase provided, in the PR, by Christian Shelton and
reduced by David Majnemer.

PR:		23584
Differential Revision:	http://reviews.llvm.org/D10508
Reviewed by:	rnk


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240242 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2015-06-21 16:33:50 +00:00
parent 14ff9b05ed
commit bcdd41a1b9
2 changed files with 23 additions and 0 deletions

View File

@ -1297,6 +1297,10 @@ HasTrivialDestructorBody(ASTContext &Context,
if (BaseClassDecl->hasTrivialDestructor())
return true;
// Give up if the destructor is not accessible.
if (!BaseClassDecl->getDestructor())
return false;
if (!BaseClassDecl->getDestructor()->hasTrivialBody())
return false;

View File

@ -0,0 +1,19 @@
// RUN: %clang_cc1 %s -emit-llvm -std=c++11 -o %t
struct A {
~A();
};
struct B {
A a;
};
struct C {
union {
B b;
};
~C() noexcept;
};
C::~C() noexcept {}