]> granicus.if.org Git - clang/commitdiff
Change HasMutableFields to HasOnlyCMembers and consider that a tag inside
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 26 Jan 2012 18:28:08 +0000 (18:28 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 26 Jan 2012 18:28:08 +0000 (18:28 +0000)
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

include/clang/AST/DeclCXX.h
lib/AST/DeclCXX.cpp

index e035e0b2fc00d6c8dedf35911e5ec3c64ea3e4b2..dcc780781b37478a55bd52f08540c92ece28a6a9 100644 (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.
index 6db3efcd1847cb3019f3888945eb70c16b354445..afd23f66a35decd5003665db8457cd2ab499b59e 100644 (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;