Quuxplusone created this revision.
Herald added a subscriber: cfe-commits.

Rename `HasMutableFields` to `HasMutableSubobject` for accuracy.

  
  This bitflag is set whenever the record type has a mutable subobject,
  regardless of whether that subobject is a direct member, or a member
  of some base class, or a member of a member, etc. etc.
  It does not need to be a field of the record type itself.

Rename `HasVolatileMember` to `HasVolatileSubobject` for accuracy.

  
  This bitflag is set whenever the record type has a volatile subobject,
  regardless of whether that subobject is a direct member, or a member
  of some base class, or a member of a member, etc. etc.
  It does not need to be a member of the record type itself.

Generally in C++ if we have

  struct A { mutable int m; };
  struct B { A a; };

we say that `a` is a "member" or "field" of `B`; `m` is a "subobject" of `B`; 
but `m` is neither a "member" nor a "field" of `B`.

The current naming of these accessors confused me for a little while during the 
development of a different patch, so I thought I'd submit a diff renaming them 
after what they actually do, and see if anyone thought it was a good idea. (I 
don't have commit privs.)


Repository:
  rC Clang

https://reviews.llvm.org/D51135

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp

Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -675,7 +675,7 @@
       T = T->getPointeeType();
     const CXXRecordDecl *ParentRecord = T->getAsCXXRecordDecl();
     assert(ParentRecord);
-    if (ParentRecord->hasMutableFields())
+    if (ParentRecord->hasMutableSubobject())
       return;
     // Preserve CXXThis.
     const MemRegion *ThisRegion = ThisVal.getAsRegion();
Index: lib/Serialization/ASTWriterDecl.cpp
===================================================================
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -468,7 +468,7 @@
   Record.push_back(D->hasFlexibleArrayMember());
   Record.push_back(D->isAnonymousStructOrUnion());
   Record.push_back(D->hasObjectMember());
-  Record.push_back(D->hasVolatileMember());
+  Record.push_back(D->hasVolatileSubobject());
   Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize());
   Record.push_back(D->isNonTrivialToPrimitiveCopy());
   Record.push_back(D->isNonTrivialToPrimitiveDestroy());
@@ -1920,7 +1920,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // AnonymousStructUnion
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasObjectMember
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileMember
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // hasVolatileSubobject
 
   // isNonTrivialToPrimitiveDefaultInitialize
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
Index: lib/Serialization/ASTWriter.cpp
===================================================================
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -6025,7 +6025,7 @@
   Record->push_back(Data.HasPrivateFields);
   Record->push_back(Data.HasProtectedFields);
   Record->push_back(Data.HasPublicFields);
-  Record->push_back(Data.HasMutableFields);
+  Record->push_back(Data.HasMutableSubobject);
   Record->push_back(Data.HasVariantMembers);
   Record->push_back(Data.HasOnlyCMembers);
   Record->push_back(Data.HasInClassInitializer);
Index: lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -787,7 +787,7 @@
   RD->setHasFlexibleArrayMember(Record.readInt());
   RD->setAnonymousStructOrUnion(Record.readInt());
   RD->setHasObjectMember(Record.readInt());
-  RD->setHasVolatileMember(Record.readInt());
+  RD->setHasVolatileSubobject(Record.readInt());
   RD->setNonTrivialToPrimitiveDefaultInitialize(Record.readInt());
   RD->setNonTrivialToPrimitiveCopy(Record.readInt());
   RD->setNonTrivialToPrimitiveDestroy(Record.readInt());
@@ -1651,7 +1651,7 @@
   Data.HasPrivateFields = Record.readInt();
   Data.HasProtectedFields = Record.readInt();
   Data.HasPublicFields = Record.readInt();
-  Data.HasMutableFields = Record.readInt();
+  Data.HasMutableSubobject = Record.readInt();
   Data.HasVariantMembers = Record.readInt();
   Data.HasOnlyCMembers = Record.readInt();
   Data.HasInClassInitializer = Record.readInt();
@@ -1792,7 +1792,7 @@
   MATCH_FIELD(HasPrivateFields)
   MATCH_FIELD(HasProtectedFields)
   MATCH_FIELD(HasPublicFields)
-  MATCH_FIELD(HasMutableFields)
+  MATCH_FIELD(HasMutableSubobject)
   MATCH_FIELD(HasVariantMembers)
   MATCH_FIELD(HasOnlyCMembers)
   MATCH_FIELD(HasInClassInitializer)
Index: lib/Sema/SemaOpenMP.cpp
===================================================================
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -1107,7 +1107,7 @@
       RD = CTD->getTemplatedDecl();
   if (IsConstant &&
       !(SemaRef.getLangOpts().CPlusPlus && RD && RD->hasDefinition() &&
-        RD->hasMutableFields())) {
+        RD->hasMutableSubobject())) {
     // Variables with const-qualified type having no mutable member may be
     // listed in a firstprivate clause, even if they are static data members.
     DSAVarData DVarTemp =
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -15724,8 +15724,8 @@
       }
       if (Record && FDTTy->getDecl()->hasObjectMember())
         Record->setHasObjectMember(true);
-      if (Record && FDTTy->getDecl()->hasVolatileMember())
-        Record->setHasVolatileMember(true);
+      if (Record && FDTTy->getDecl()->hasVolatileSubobject())
+        Record->setHasVolatileSubobject(true);
     } else if (FDTy->isObjCObjectType()) {
       /// A field cannot be an Objective-c object
       Diag(FD->getLocation(), diag::err_statically_allocated_object)
@@ -15791,7 +15791,7 @@
     }
 
     if (Record && FD->getType().isVolatileQualified())
-      Record->setHasVolatileMember(true);
+      Record->setHasVolatileSubobject(true);
     // Keep track of the number of named members.
     if (FD->getIdentifier())
       ++NumNamedMembers;
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2863,7 +2863,7 @@
   if (Context.getLangOpts().CPlusPlus) {
     if (const CXXRecordDecl *Record
           = Context.getBaseElementType(Ty)->getAsCXXRecordDecl())
-      return ExcludeCtor && !Record->hasMutableFields() &&
+      return ExcludeCtor && !Record->hasMutableSubobject() &&
              Record->hasTrivialDestructor();
   }
 
@@ -3015,8 +3015,8 @@
         !D->hasDefinition() && D->hasInit() && !D->hasAttr<DLLImportAttr>()) {
       const auto *Record =
           Context.getBaseElementType(D->getType())->getAsCXXRecordDecl();
-      bool HasMutableFields = Record && Record->hasMutableFields();
-      if (!HasMutableFields) {
+      bool HasMutableSubobject = Record && Record->hasMutableSubobject();
+      if (!HasMutableSubobject) {
         const VarDecl *InitDecl;
         const Expr *InitExpr = D->getAnyInitializer(InitDecl);
         if (InitExpr) {
Index: lib/CodeGen/CodeGenFunction.h
===================================================================
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2281,12 +2281,12 @@
   void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,
                       bool capturedByInit);
 
-  /// hasVolatileMember - returns true if aggregate type has a volatile
-  /// member.
-  bool hasVolatileMember(QualType T) {
+  /// hasVolatileSubobject - returns true if aggregate type has a volatile
+  /// subobject.
+  bool hasVolatileSubobject(QualType T) {
     if (const RecordType *RT = T->getAs<RecordType>()) {
       const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
-      return RD->hasVolatileMember();
+      return RD->hasVolatileSubobject();
     }
     return false;
   }
@@ -2317,7 +2317,7 @@
 
   /// Emit an aggregate assignment.
   void EmitAggregateAssign(LValue Dest, LValue Src, QualType EltTy) {
-    bool IsVolatile = hasVolatileMember(EltTy);
+    bool IsVolatile = hasVolatileSubobject(EltTy);
     EmitAggregateCopy(Dest, Src, EltTy, AggValueSlot::MayOverlap, IsVolatile);
   }
 
Index: lib/CodeGen/CGExprAgg.cpp
===================================================================
--- lib/CodeGen/CGExprAgg.cpp
+++ lib/CodeGen/CGExprAgg.cpp
@@ -1161,7 +1161,7 @@
                             AggValueSlot::MayOverlap);
   // A non-volatile aggregate destination might have volatile member.
   if (!LHSSlot.isVolatile() &&
-      CGF.hasVolatileMember(E->getLHS()->getType()))
+      CGF.hasVolatileSubobject(E->getLHS()->getType()))
     LHSSlot.setVolatile(true);
 
   CGF.EmitAggExpr(E->getRHS(), LHSSlot);
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1373,7 +1373,7 @@
   // mutable subobjects or non-trivial copy/destroy behavior.
   if (const auto *RT = dyn_cast<RecordType>(type))
     if (const auto *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
-      if (RD->hasMutableFields() || !RD->isTrivial())
+      if (RD->hasMutableSubobject() || !RD->isTrivial())
         return false;
 
   return true;
Index: lib/CodeGen/CGBlocks.cpp
===================================================================
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -396,7 +396,7 @@
 
   // Otherwise, we just have to make sure there aren't any mutable
   // fields that might have changed since initialization.
-  return !record->hasMutableFields();
+  return !record->hasMutableSubobject();
 }
 
 /// It is illegal to modify a const object after initialization.
Index: lib/CodeGen/CGAtomic.cpp
===================================================================
--- lib/CodeGen/CGAtomic.cpp
+++ lib/CodeGen/CGAtomic.cpp
@@ -1448,7 +1448,7 @@
 bool CodeGenFunction::LValueIsSuitableForInlineAtomic(LValue LV) {
   if (!CGM.getCodeGenOpts().MSVolatile) return false;
   AtomicInfo AI(*this, LV);
-  bool IsVolatile = LV.isVolatile() || hasVolatileMember(LV.getType());
+  bool IsVolatile = LV.isVolatile() || hasVolatileSubobject(LV.getType());
   // An atomic is inline if we don't need to use a libcall.
   bool AtomicIsInline = !AI.shouldUseLibcall();
   // MSVC doesn't seem to do this for types wider than a pointer.
Index: lib/AST/ExprConstant.cpp
===================================================================
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -2728,7 +2728,7 @@
   if (!RD)
     return false;
 
-  if (!RD->hasMutableFields())
+  if (!RD->hasMutableSubobject())
     return false;
 
   for (auto *Field : RD->fields()) {
Index: lib/AST/DeclCXX.cpp
===================================================================
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -77,7 +77,7 @@
       Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
       HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
       HasPrivateFields(false), HasProtectedFields(false),
-      HasPublicFields(false), HasMutableFields(false), HasVariantMembers(false),
+      HasPublicFields(false), HasMutableSubobject(false), HasVariantMembers(false),
       HasOnlyCMembers(true), HasInClassInitializer(false),
       HasUninitializedReferenceMember(false), HasUninitializedFields(false),
       HasInheritedConstructor(false), HasInheritedAssignment(false),
@@ -422,16 +422,16 @@
     if (BaseClassDecl->hasObjectMember())
       setHasObjectMember(true);
 
-    if (BaseClassDecl->hasVolatileMember())
-      setHasVolatileMember(true);
+    if (BaseClassDecl->hasVolatileSubobject())
+      setHasVolatileSubobject(true);
 
     if (BaseClassDecl->getArgPassingRestrictions() ==
         RecordDecl::APK_CanNeverPassInRegs)
       setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
 
     // Keep track of the presence of mutable fields.
-    if (BaseClassDecl->hasMutableFields()) {
-      data().HasMutableFields = true;
+    if (BaseClassDecl->hasMutableSubobject()) {
+      data().HasMutableSubobject = true;
       data().NeedOverloadResolutionForCopyConstructor = true;
     }
 
@@ -927,7 +927,7 @@
 
     // Keep track of the presence of mutable fields.
     if (Field->isMutable()) {
-      data().HasMutableFields = true;
+      data().HasMutableSubobject = true;
       data().NeedOverloadResolutionForCopyConstructor = true;
     }
 
@@ -1131,8 +1131,8 @@
           data().HasIrrelevantDestructor = false;
         if (FieldRec->hasObjectMember())
           setHasObjectMember(true);
-        if (FieldRec->hasVolatileMember())
-          setHasVolatileMember(true);
+        if (FieldRec->hasVolatileSubobject())
+          setHasVolatileSubobject(true);
         if (FieldRec->getArgPassingRestrictions() ==
             RecordDecl::APK_CanNeverPassInRegs)
           setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
@@ -1170,8 +1170,8 @@
         }
 
         // Keep track of the presence of mutable fields.
-        if (FieldRec->hasMutableFields()) {
-          data().HasMutableFields = true;
+        if (FieldRec->hasMutableSubobject()) {
+          data().HasMutableSubobject = true;
           data().NeedOverloadResolutionForCopyConstructor = true;
         }
 
Index: lib/AST/Decl.cpp
===================================================================
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -4073,7 +4073,7 @@
   setHasFlexibleArrayMember(false);
   setAnonymousStructOrUnion(false);
   setHasObjectMember(false);
-  setHasVolatileMember(false);
+  setHasVolatileSubobject(false);
   setHasLoadedFieldsFromExternalStorage(false);
   setNonTrivialToPrimitiveDefaultInitialize(false);
   setNonTrivialToPrimitiveCopy(false);
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1340,7 +1340,7 @@
     ToData.HasPrivateFields = FromData.HasPrivateFields;
     ToData.HasProtectedFields = FromData.HasProtectedFields;
     ToData.HasPublicFields = FromData.HasPublicFields;
-    ToData.HasMutableFields = FromData.HasMutableFields;
+    ToData.HasMutableSubobject = FromData.HasMutableSubobject;
     ToData.HasVariantMembers = FromData.HasVariantMembers;
     ToData.HasOnlyCMembers = FromData.HasOnlyCMembers;
     ToData.HasInClassInitializer = FromData.HasInClassInitializer;
Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -1409,7 +1409,7 @@
 
     FLAG(hasUserDeclaredConstructor, has_user_declared_ctor);
     FLAG(hasConstexprNonCopyMoveConstructor, has_constexpr_non_copy_move_ctor);
-    FLAG(hasMutableFields, has_mutable_fields);
+    FLAG(hasMutableSubobject, has_mutable_subobject);
     FLAG(hasVariantMembers, has_variant_members);
     FLAG(allowConstDefaultInit, can_const_default_init);
 
Index: include/clang/AST/DeclCXX.h
===================================================================
--- include/clang/AST/DeclCXX.h
+++ include/clang/AST/DeclCXX.h
@@ -399,7 +399,7 @@
     unsigned HasPublicFields : 1;
 
     /// True if this class (or any subobject) has mutable fields.
-    unsigned HasMutableFields : 1;
+    unsigned HasMutableSubobject : 1;
 
     /// True if this class (or any nested anonymous struct or union)
     /// has variant members.
@@ -1127,7 +1127,7 @@
   /// Determine whether we need to eagerly declare a defaulted copy
   /// assignment operator for this class.
   bool needsOverloadResolutionForCopyAssignment() const {
-    return data().HasMutableFields;
+    return data().HasMutableSubobject;
   }
 
   /// Determine whether an implicit copy assignment operator for this
@@ -1363,7 +1363,7 @@
 
   /// Determine whether this class, or any of its class subobjects,
   /// contains a mutable field.
-  bool hasMutableFields() const { return data().HasMutableFields; }
+  bool hasMutableSubobject() const { return data().HasMutableSubobject; }
 
   /// Determine whether this class has any variant members.
   bool hasVariantMembers() const { return data().HasVariantMembers; }
Index: include/clang/AST/DeclBase.h
===================================================================
--- include/clang/AST/DeclBase.h
+++ include/clang/AST/DeclBase.h
@@ -1426,9 +1426,9 @@
     /// containing an Objective-C object pointer type.
     uint64_t HasObjectMember : 1;
 
-    /// This is true if struct has at least one member of
-    /// 'volatile' type.
-    uint64_t HasVolatileMember : 1;
+    /// This is true if struct has at least one (possibly nested) member
+    /// of 'volatile' type.
+    uint64_t HasVolatileSubobject : 1;
 
     /// Whether the field declarations of this record have been loaded
     /// from external storage. To avoid unnecessary deserialization of
Index: include/clang/AST/Decl.h
===================================================================
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -3656,10 +3656,10 @@
   bool hasObjectMember() const { return RecordDeclBits.HasObjectMember; }
   void setHasObjectMember(bool val) { RecordDeclBits.HasObjectMember = val; }
 
-  bool hasVolatileMember() const { return RecordDeclBits.HasVolatileMember; }
+  bool hasVolatileSubobject() const { return RecordDeclBits.HasVolatileSubobject; }
 
-  void setHasVolatileMember(bool val) {
-    RecordDeclBits.HasVolatileMember = val;
+  void setHasVolatileSubobject(bool val) {
+    RecordDeclBits.HasVolatileSubobject = val;
   }
 
   bool hasLoadedFieldsFromExternalStorage() const {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to