diff options
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 01fd10429fc1d..1ed7fc71b025a 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -65,6 +65,13 @@ void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts, // 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. @@ -350,7 +357,7 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::getSuperClass() const { SourceLocation ObjCInterfaceDecl::getSuperClassLoc() const { if (TypeSourceInfo *superTInfo = getSuperClassTInfo()) - return superTInfo->getTypeLoc().getLocStart(); + return superTInfo->getTypeLoc().getBeginLoc(); return SourceLocation(); } @@ -769,6 +776,37 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod( // 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) { + + // 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, @@ -791,6 +829,14 @@ bool ObjCMethodDecl::isThisDeclarationADesignatedInitializer() const { hasAttr<ObjCDesignatedInitializerAttr>(); } +bool ObjCMethodDecl::definedInNSObject(const ASTContext &Ctx) const { + if (const auto *PD = dyn_cast<const ObjCProtocolDecl>(getDeclContext())) + return PD->getIdentifier() == Ctx.getNSObjectName(); + if (const auto *ID = dyn_cast<const ObjCInterfaceDecl>(getDeclContext())) + return ID->getIdentifier() == Ctx.getNSObjectName(); + return false; +} + bool ObjCMethodDecl::isDesignatedInitializerForTheInterface( const ObjCMethodDecl **InitMethod) const { if (getMethodFamily() != OMF_init) @@ -810,8 +856,8 @@ Stmt *ObjCMethodDecl::getBody() const { 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 +892,9 @@ void ObjCMethodDecl::setMethodParams(ASTContext &C, 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 +906,7 @@ void ObjCMethodDecl::setMethodParams(ASTContext &C, ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() { ASTContext &Ctx = getASTContext(); ObjCMethodDecl *Redecl = nullptr; - if (HasRedeclaration) + if (hasRedeclaration()) Redecl = const_cast<ObjCMethodDecl*>(Ctx.getObjCMethodRedeclaration(this)); if (Redecl) return Redecl; @@ -931,14 +977,14 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() { return this; } -SourceLocation ObjCMethodDecl::getLocEnd() const { +SourceLocation ObjCMethodDecl::getEndLoc() const { if (Stmt *Body = getBody()) - return Body->getLocEnd(); + return Body->getEndLoc(); return DeclEndLoc; } 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 +1000,7 @@ ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const { 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 +1071,7 @@ ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const { } // Cache the result. - Family = static_cast<unsigned>(family); + ObjCMethodDeclBits.Family = family; return family; } |