Change HasMutableFields to HasOnlyCMembers and consider that a tag inside

another tag does not break C-like-ness. rdar://10756831

llvm-svn: 149071
This commit is contained in:
Argyrios Kyrtzidis 2012-01-26 18:28:08 +00:00
parent 1a1531d65e
commit b2e31e4443
2 changed files with 8 additions and 5 deletions

View File

@ -349,7 +349,7 @@ class CXXRecordDecl : public RecordDecl {
bool HasMutableFields : 1;
/// \brief True if there no non-field members declared by the user.
bool HasOnlyFields : 1;
bool HasOnlyCMembers : 1;
/// HasTrivialDefaultConstructor - True when, if this class has a default
/// constructor, this default constructor is trivial.

View File

@ -43,7 +43,7 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D)
Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
Abstract(false), IsStandardLayout(true), HasNoNonEmptyBases(true),
HasPrivateFields(false), HasProtectedFields(false), HasPublicFields(false),
HasMutableFields(false), HasOnlyFields(true),
HasMutableFields(false), HasOnlyCMembers(true),
HasTrivialDefaultConstructor(true),
HasConstexprNonCopyMoveConstructor(false),
DefaultedDefaultConstructorIsConstexpr(true),
@ -457,8 +457,11 @@ void CXXRecordDecl::markedVirtualFunctionPure() {
}
void CXXRecordDecl::addedMember(Decl *D) {
if (!isa<FieldDecl>(D) && !isa<IndirectFieldDecl>(D) && !D->isImplicit())
data().HasOnlyFields = false;
if (!D->isImplicit() &&
!isa<FieldDecl>(D) &&
!isa<IndirectFieldDecl>(D) &&
(!isa<TagDecl>(D) || cast<TagDecl>(D)->getTagKind() == TTK_Class))
data().HasOnlyCMembers = false;
// Ignore friends and invalid declarations.
if (D->getFriendObjectKind() || D->isInvalidDecl())
@ -968,7 +971,7 @@ bool CXXRecordDecl::isCLike() const {
return true;
return isPOD() &&
data().HasOnlyFields &&
data().HasOnlyCMembers &&
!data().HasPrivateFields &&
!data().HasProtectedFields &&
!data().NumBases;