[AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729,
https://reviews.llvm.org/D49732 and
https://reviews.llvm.org/D49733.

Move the bits from ObjCMethodDecl and ObjCContainerDecl
into DeclContext.

Differential Revision: https://reviews.llvm.org/D49734

Patch By: bricci

llvm-svn: 338641
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 01fd104..86ec972 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -65,6 +65,13 @@
 // ObjCInterfaceDecl
 //===----------------------------------------------------------------------===//
 
+ObjCContainerDecl::ObjCContainerDecl(Kind DK, DeclContext *DC,
+                                     IdentifierInfo *Id, SourceLocation nameLoc,
+                                     SourceLocation atStartLoc)
+    : NamedDecl(DK, DC, nameLoc, Id), DeclContext(DK) {
+  setAtStartLoc(atStartLoc);
+}
+
 void ObjCContainerDecl::anchor() {}
 
 /// getIvarDecl - This method looks up an ivar in this ContextDecl.
@@ -769,6 +776,44 @@
 // ObjCMethodDecl
 //===----------------------------------------------------------------------===//
 
+ObjCMethodDecl::ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
+                               Selector SelInfo, QualType T,
+                               TypeSourceInfo *ReturnTInfo,
+                               DeclContext *contextDecl, bool isInstance,
+                               bool isVariadic, bool isPropertyAccessor,
+                               bool isImplicitlyDeclared, bool isDefined,
+                               ImplementationControl impControl,
+                               bool HasRelatedResultType)
+    : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
+      DeclContext(ObjCMethod), MethodDeclType(T), ReturnTInfo(ReturnTInfo),
+      DeclEndLoc(endLoc) {
+  // See the comment in ObjCMethodFamilyBitfields about
+  // ObjCMethodFamilyBitWidth for why we check this.
+  static_assert(
+      static_cast<unsigned>(ObjCMethodDeclBits.ObjCMethodFamilyBitWidth) ==
+          static_cast<unsigned>(ObjCMethodFamilyBitWidth),
+      "ObjCMethodDeclBitfields::ObjCMethodFamilyBitWidth and "
+      "ObjCMethodFamilyBitWidth do not match!");
+
+  // Initialized the bits stored in DeclContext.
+  ObjCMethodDeclBits.Family =
+      static_cast<ObjCMethodFamily>(InvalidObjCMethodFamily);
+  setInstanceMethod(isInstance);
+  setVariadic(isVariadic);
+  setPropertyAccessor(isPropertyAccessor);
+  setDefined(isDefined);
+  setIsRedeclaration(false);
+  setHasRedeclaration(false);
+  setDeclImplementation(impControl);
+  setObjCDeclQualifier(OBJC_TQ_None);
+  setRelatedResultType(HasRelatedResultType);
+  setSelLocsKind(SelLoc_StandardNoSpace);
+  setOverriding(false);
+  setHasSkippedBody(false);
+
+  setImplicit(isImplicitlyDeclared);
+}
+
 ObjCMethodDecl *ObjCMethodDecl::Create(
     ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc,
     Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo,
@@ -810,8 +855,8 @@
 void ObjCMethodDecl::setAsRedeclaration(const ObjCMethodDecl *PrevMethod) {
   assert(PrevMethod);
   getASTContext().setObjCMethodRedeclaration(PrevMethod, this);
-  IsRedeclaration = true;
-  PrevMethod->HasRedeclaration = true;
+  setIsRedeclaration(true);
+  PrevMethod->setHasRedeclaration(true);
 }
 
 void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
@@ -846,9 +891,9 @@
   if (isImplicit())
     return setParamsAndSelLocs(C, Params, llvm::None);
 
-  SelLocsKind = hasStandardSelectorLocs(getSelector(), SelLocs, Params,
-                                        DeclEndLoc);
-  if (SelLocsKind != SelLoc_NonStandard)
+  setSelLocsKind(hasStandardSelectorLocs(getSelector(), SelLocs, Params,
+                                        DeclEndLoc));
+  if (getSelLocsKind() != SelLoc_NonStandard)
     return setParamsAndSelLocs(C, Params, llvm::None);
 
   setParamsAndSelLocs(C, Params, SelLocs);
@@ -860,7 +905,7 @@
 ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() {
   ASTContext &Ctx = getASTContext();
   ObjCMethodDecl *Redecl = nullptr;
-  if (HasRedeclaration)
+  if (hasRedeclaration())
     Redecl = const_cast<ObjCMethodDecl*>(Ctx.getObjCMethodRedeclaration(this));
   if (Redecl)
     return Redecl;
@@ -938,7 +983,7 @@
 }
 
 ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const {
-  auto family = static_cast<ObjCMethodFamily>(Family);
+  auto family = static_cast<ObjCMethodFamily>(ObjCMethodDeclBits.Family);
   if (family != static_cast<unsigned>(InvalidObjCMethodFamily))
     return family;
 
@@ -954,7 +999,7 @@
     case ObjCMethodFamilyAttr::OMF_mutableCopy: family = OMF_mutableCopy; break;
     case ObjCMethodFamilyAttr::OMF_new: family = OMF_new; break;
     }
-    Family = static_cast<unsigned>(family);
+    ObjCMethodDeclBits.Family = family;
     return family;
   }
 
@@ -1025,7 +1070,7 @@
   }
 
   // Cache the result.
-  Family = static_cast<unsigned>(family);
+  ObjCMethodDeclBits.Family = family;
   return family;
 }