Skip to content
Snippets Groups Projects
Commit c51570d2 authored by Davide Italiano's avatar Davide Italiano
Browse files

[Sema] Commit a better fix for r240242

Skip calls to HasTrivialDestructorBody() in the case where the
destructor is never invoked. Alternatively, Richard proposed to change
Sema to declare a trivial destructor for anonymous union member, which
seems too wasteful.

Differential Revision:	http://reviews.llvm.org/D10508


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240742 91177308-0d34-0410-b5e6-96231b3b80d8
parent a41fa8a4
No related branches found
No related tags found
No related merge requests found
......@@ -1294,10 +1294,6 @@ 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;
......@@ -1343,6 +1339,11 @@ FieldHasTrivialDestructorBody(ASTContext &Context,
return true;
CXXRecordDecl *FieldClassDecl = cast<CXXRecordDecl>(RT->getDecl());
// The destructor for an implicit anonymous union member is never invoked.
if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
return false;
return HasTrivialDestructorBody(Context, FieldClassDecl, FieldClassDecl);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment