Skip to content

Commit 982bbf4

Browse files
committedJun 26, 2015
[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 llvm-svn: 240742
1 parent 2ca4686 commit 982bbf4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎clang/lib/CodeGen/CGClass.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1294,10 +1294,6 @@ HasTrivialDestructorBody(ASTContext &Context,
12941294
if (BaseClassDecl->hasTrivialDestructor())
12951295
return true;
12961296

1297-
// Give up if the destructor is not accessible.
1298-
if (!BaseClassDecl->getDestructor())
1299-
return false;
1300-
13011297
if (!BaseClassDecl->getDestructor()->hasTrivialBody())
13021298
return false;
13031299

@@ -1343,6 +1339,11 @@ FieldHasTrivialDestructorBody(ASTContext &Context,
13431339
return true;
13441340

13451341
CXXRecordDecl *FieldClassDecl = cast<CXXRecordDecl>(RT->getDecl());
1342+
1343+
// The destructor for an implicit anonymous union member is never invoked.
1344+
if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
1345+
return false;
1346+
13461347
return HasTrivialDestructorBody(Context, FieldClassDecl, FieldClassDecl);
13471348
}
13481349

0 commit comments

Comments
 (0)