summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2015-06-26 00:18:35 +0000
committerDavide Italiano <davide@freebsd.org>2015-06-26 00:18:35 +0000
commitc51570d21d24f69066729bc23d71b4f692b7839e (patch)
tree60428cd31b70288bb397abff352cac037d04022d
parenta41fa8a4747a5d551673febf5a368f789d0cd743 (diff)
downloadclang-c51570d21d24f69066729bc23d71b4f692b7839e.tar.gz
[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
-rw-r--r--lib/CodeGen/CGClass.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp
index 6538351edf..62df9820a6 100644
--- a/lib/CodeGen/CGClass.cpp
+++ b/lib/CodeGen/CGClass.cpp
@@ -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);
}