From: Argyrios Kyrtzidis Date: Thu, 26 Jan 2012 18:28:08 +0000 (+0000) Subject: Change HasMutableFields to HasOnlyCMembers and consider that a tag inside X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4fe19b5bf0db0cbe6afa280ed9f52ed4cb631e53;p=clang Change HasMutableFields to HasOnlyCMembers and consider that a tag inside another tag does not break C-like-ness. rdar://10756831 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149071 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index e035e0b2fc..dcc780781b 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -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. diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 6db3efcd18..afd23f66a3 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -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(D) && !isa(D) && !D->isImplicit()) - data().HasOnlyFields = false; + if (!D->isImplicit() && + !isa(D) && + !isa(D) && + (!isa(D) || cast(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;