diff options
Diffstat (limited to 'gnu/llvm/tools/clang/lib/AST/DeclObjC.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/AST/DeclObjC.cpp | 206 |
1 files changed, 96 insertions, 110 deletions
diff --git a/gnu/llvm/tools/clang/lib/AST/DeclObjC.cpp b/gnu/llvm/tools/clang/lib/AST/DeclObjC.cpp index f95d5def47a..18ba3b13b36 100644 --- a/gnu/llvm/tools/clang/lib/AST/DeclObjC.cpp +++ b/gnu/llvm/tools/clang/lib/AST/DeclObjC.cpp @@ -51,7 +51,7 @@ void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) { memcpy(List, InList, sizeof(void*)*Elts); } -void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts, +void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts, const SourceLocation *Locs, ASTContext &Ctx) { if (Elts == 0) return; @@ -74,7 +74,7 @@ ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const { lookup_result R = lookup(Id); for (lookup_iterator Ivar = R.begin(), IvarEnd = R.end(); Ivar != IvarEnd; ++Ivar) { - if (ObjCIvarDecl *ivar = dyn_cast<ObjCIvarDecl>(*Ivar)) + if (auto *ivar = dyn_cast<ObjCIvarDecl>(*Ivar)) return ivar; } return nullptr; @@ -86,7 +86,7 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance, bool AllowHidden) const { // If this context is a hidden protocol definition, don't find any // methods there. - if (const ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(this)) { + if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) { if (const ObjCProtocolDecl *Def = Proto->getDefinition()) if (Def->isHidden() && !AllowHidden) return nullptr; @@ -102,14 +102,14 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance, lookup_result R = lookup(Sel); for (lookup_iterator Meth = R.begin(), MethEnd = R.end(); Meth != MethEnd; ++Meth) { - ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth); + auto *MD = dyn_cast<ObjCMethodDecl>(*Meth); if (MD && MD->isInstanceMethod() == isInstance) return MD; } return nullptr; } -/// \brief This routine returns 'true' if a user declared setter method was +/// This routine returns 'true' if a user declared setter method was /// found in the class, its protocols, its super classes or categories. /// It also returns 'true' if one of its categories has declared a 'readwrite' /// property. This is because, user must provide a setter method for the @@ -120,12 +120,12 @@ bool ObjCContainerDecl::HasUserDeclaredSetterMethod( lookup_result R = lookup(Sel); for (lookup_iterator Meth = R.begin(), MethEnd = R.end(); Meth != MethEnd; ++Meth) { - ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth); + auto *MD = dyn_cast<ObjCMethodDecl>(*Meth); if (MD && MD->isInstanceMethod() && !MD->isImplicit()) return true; } - if (const ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(this)) { + if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(this)) { // Also look into categories, including class extensions, looking // for a user declared instance method. for (const auto *Cat : ID->visible_categories()) { @@ -145,7 +145,7 @@ bool ObjCContainerDecl::HasUserDeclaredSetterMethod( break; } } - + // Also look into protocols, for a user declared instance method. for (const auto *Proto : ID->all_referenced_protocols()) if (Proto->HasUserDeclaredSetterMethod(Property)) @@ -159,7 +159,7 @@ bool ObjCContainerDecl::HasUserDeclaredSetterMethod( OSC = OSC->getSuperClass(); } } - if (const ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(this)) + if (const auto *PD = dyn_cast<ObjCProtocolDecl>(this)) for (const auto *PI : PD->protocols()) if (PI->HasUserDeclaredSetterMethod(Property)) return true; @@ -172,7 +172,7 @@ ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC, ObjCPropertyQueryKind queryKind) { // If this context is a hidden protocol definition, don't find any // property. - if (const ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(DC)) { + if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(DC)) { if (const ObjCProtocolDecl *Def = Proto->getDefinition()) if (Def->isHidden()) return nullptr; @@ -192,7 +192,7 @@ ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC, ObjCPropertyDecl *classProp = nullptr; for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; ++I) - if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(*I)) { + if (auto *PD = dyn_cast<ObjCPropertyDecl>(*I)) { // If queryKind is unknown, we return the instance property if one // exists; otherwise we return the class property. if ((queryKind == ObjCPropertyQueryKind::OBJC_PR_query_unknown && @@ -230,12 +230,12 @@ ObjCPropertyDecl *ObjCContainerDecl::FindPropertyDeclaration( const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const { // Don't find properties within hidden protocol definitions. - if (const ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(this)) { + if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) { if (const ObjCProtocolDecl *Def = Proto->getDefinition()) if (Def->isHidden()) return nullptr; } - + // Search the extensions of a class first; they override what's in // the class itself. if (const auto *ClassDecl = dyn_cast<ObjCInterfaceDecl>(this)) { @@ -254,7 +254,7 @@ ObjCPropertyDecl *ObjCContainerDecl::FindPropertyDeclaration( default: break; case Decl::ObjCProtocol: { - const ObjCProtocolDecl *PID = cast<ObjCProtocolDecl>(this); + const auto *PID = cast<ObjCProtocolDecl>(this); for (const auto *I : PID->protocols()) if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId, QueryKind)) @@ -262,7 +262,7 @@ ObjCPropertyDecl *ObjCContainerDecl::FindPropertyDeclaration( break; } case Decl::ObjCInterface: { - const ObjCInterfaceDecl *OID = cast<ObjCInterfaceDecl>(this); + const auto *OID = cast<ObjCInterfaceDecl>(this); // Look through categories (but not extensions; they were handled above). for (const auto *Cat : OID->visible_categories()) { if (!Cat->IsClassExtension()) @@ -283,7 +283,7 @@ ObjCPropertyDecl *ObjCContainerDecl::FindPropertyDeclaration( break; } case Decl::ObjCCategory: { - const ObjCCategoryDecl *OCD = cast<ObjCCategoryDecl>(this); + const auto *OCD = cast<ObjCCategoryDecl>(this); // Look through protocols. if (!OCD->IsClassExtension()) for (const auto *I : OCD->protocols()) @@ -310,7 +310,8 @@ ObjCTypeParamList *ObjCInterfaceDecl::getTypeParamList() const { // Otherwise, look at previous declarations to determine whether any // of them has a type parameter list, skipping over those // declarations that do not. - for (auto decl = getMostRecentDecl(); decl; decl = decl->getPreviousDecl()) { + for (const ObjCInterfaceDecl *decl = getMostRecentDecl(); decl; + decl = decl->getPreviousDecl()) { if (ObjCTypeParamList *written = decl->getTypeParamListAsWritten()) return written; } @@ -323,7 +324,7 @@ void ObjCInterfaceDecl::setTypeParamList(ObjCTypeParamList *TPL) { if (!TPL) return; // Set the declaration context of each of the type parameters. - for (auto typeParam : *TypeParamList) + for (auto *typeParam : *TypeParamList) typeParam->setDeclContext(this); } @@ -331,7 +332,7 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::getSuperClass() const { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return nullptr; - + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -350,7 +351,7 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::getSuperClass() const { SourceLocation ObjCInterfaceDecl::getSuperClassLoc() const { if (TypeSourceInfo *superTInfo = getSuperClassTInfo()) return superTInfo->getTypeLoc().getLocStart(); - + return SourceLocation(); } @@ -428,16 +429,16 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList( if (data().ExternallyCompleted) LoadExternalDefinition(); - if (data().AllReferencedProtocols.empty() && + if (data().AllReferencedProtocols.empty() && data().ReferencedProtocols.empty()) { data().AllReferencedProtocols.set(ExtList, ExtNum, C); return; } - + // Check for duplicate protocol in class's protocol list. // This is O(n*m). But it is extremely rare and number of protocols in // class or its extension are very few. - SmallVector<ObjCProtocolDecl*, 8> ProtocolRefs; + SmallVector<ObjCProtocolDecl *, 8> ProtocolRefs; for (unsigned i = 0; i < ExtNum; i++) { bool protocolExists = false; ObjCProtocolDecl *ProtoInExtension = ExtList[i]; @@ -445,7 +446,7 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList( if (C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) { protocolExists = true; break; - } + } } // Do we want to warn on a protocol in extension class which // already exist in the class? Probably not. @@ -604,7 +605,7 @@ void ObjCInterfaceDecl::startDefinition() { allocateDefinitionData(); // Update all of the declarations with a pointer to the definition. - for (auto RD : redecls()) { + for (auto *RD : redecls()) { if (RD != this) RD->Data = Data; } @@ -632,7 +633,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, return I; } } - + ClassDecl = ClassDecl->getSuperClass(); } return nullptr; @@ -672,7 +673,7 @@ ObjCInterfaceDecl::lookupNestedProtocol(IdentifierInfo *Name) { /// the class, its categories, and its super classes (using a linear search). /// When argument category "C" is specified, any implicit method found /// in this category is ignored. -ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, +ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup, bool followSuper, @@ -692,7 +693,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, // 1. Look through primary class. if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance))) return MethodDecl; - + // 2. Didn't find one yet - now look through categories. for (const auto *Cat : ClassDecl->visible_categories()) if ((MethodDecl = Cat->getMethod(Sel, isInstance))) @@ -703,21 +704,20 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, for (const auto *I : ClassDecl->protocols()) if ((MethodDecl = I->lookupMethod(Sel, isInstance))) return MethodDecl; - + // 4. Didn't find one yet - now look through categories' protocols if (!shallowCategoryLookup) for (const auto *Cat : ClassDecl->visible_categories()) { // Didn't find one yet - look through protocols. const ObjCList<ObjCProtocolDecl> &Protocols = Cat->getReferencedProtocols(); - for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), - E = Protocols.end(); I != E; ++I) - if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) + for (auto *Protocol : Protocols) + if ((MethodDecl = Protocol->lookupMethod(Sel, isInstance))) if (C != Cat || !MethodDecl->isImplicit()) return MethodDecl; } - - + + if (!followSuper) return nullptr; @@ -742,7 +742,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod( ObjCMethodDecl *Method = nullptr; if (ObjCImplementationDecl *ImpDecl = getImplementation()) - Method = Instance ? ImpDecl->getInstanceMethod(Sel) + Method = Instance ? ImpDecl->getInstanceMethod(Sel) : ImpDecl->getClassMethod(Sel); // Look through local category implementations associated with the class. @@ -854,7 +854,7 @@ void ObjCMethodDecl::setMethodParams(ASTContext &C, setParamsAndSelLocs(C, Params, SelLocs); } -/// \brief A definition will return its interface declaration. +/// A definition will return its interface declaration. /// An interface declaration will return its definition. /// Otherwise it will return itself. ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() { @@ -865,27 +865,25 @@ ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() { if (Redecl) return Redecl; - Decl *CtxD = cast<Decl>(getDeclContext()); + auto *CtxD = cast<Decl>(getDeclContext()); if (!CtxD->isInvalidDecl()) { - if (ObjCInterfaceDecl *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) { + if (auto *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) { if (ObjCImplementationDecl *ImplD = Ctx.getObjCImplementation(IFD)) if (!ImplD->isInvalidDecl()) Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); - } else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) { + } else if (auto *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) { if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD)) if (!ImplD->isInvalidDecl()) Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); - } else if (ObjCImplementationDecl *ImplD = - dyn_cast<ObjCImplementationDecl>(CtxD)) { + } else if (auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) { if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) if (!IFD->isInvalidDecl()) Redecl = IFD->getMethod(getSelector(), isInstanceMethod()); - } else if (ObjCCategoryImplDecl *CImplD = - dyn_cast<ObjCCategoryImplDecl>(CtxD)) { + } else if (auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) { if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl()) if (!CatD->isInvalidDecl()) Redecl = CatD->getMethod(getSelector(), isInstanceMethod()); @@ -908,15 +906,14 @@ ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() { } ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() { - Decl *CtxD = cast<Decl>(getDeclContext()); + auto *CtxD = cast<Decl>(getDeclContext()); - if (ObjCImplementationDecl *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) { + if (auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) { if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(), isInstanceMethod())) return MD; - } else if (ObjCCategoryImplDecl *CImplD = - dyn_cast<ObjCCategoryImplDecl>(CtxD)) { + } else if (auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) { if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl()) if (ObjCMethodDecl *MD = CatD->getMethod(getSelector(), isInstanceMethod())) @@ -934,14 +931,14 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() { return this; } -SourceLocation ObjCMethodDecl::getLocEnd() const { +SourceLocation ObjCMethodDecl::getEndLoc() const { if (Stmt *Body = getBody()) return Body->getLocEnd(); return DeclEndLoc; } ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const { - ObjCMethodFamily family = static_cast<ObjCMethodFamily>(Family); + auto family = static_cast<ObjCMethodFamily>(Family); if (family != static_cast<unsigned>(InvalidObjCMethodFamily)) return family; @@ -993,12 +990,12 @@ ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const { if (!isInstanceMethod()) family = OMF_None; break; - + case OMF_initialize: if (isInstanceMethod() || !getReturnType()->isVoidType()) family = OMF_None; break; - + case OMF_performSelector: if (!isInstanceMethod() || !getReturnType()->isObjCIdType()) family = OMF_None; @@ -1024,7 +1021,7 @@ ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const { } } break; - + } // Cache the result. @@ -1099,11 +1096,11 @@ void ObjCMethodDecl::createImplicitParams(ASTContext &Context, } ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { - if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext())) + if (auto *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext())) return ID; - if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext())) + if (auto *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext())) return CD->getClassInterface(); - if (ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(getDeclContext())) + if (auto *IMD = dyn_cast<ObjCImplDecl>(getDeclContext())) return IMD->getClassInterface(); if (isa<ObjCProtocolDecl>(getDeclContext())) return nullptr; @@ -1138,11 +1135,10 @@ static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container, if (!Container) return; - // In categories look for overriden methods from protocols. A method from - // category is not "overriden" since it is considered as the "same" method + // In categories look for overridden methods from protocols. A method from + // category is not "overridden" since it is considered as the "same" method // (same USR) as the one from the interface. - if (const ObjCCategoryDecl * - Category = dyn_cast<ObjCCategoryDecl>(Container)) { + if (const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) { // Check whether we have a matching method at this category but only if we // are at the super class level. if (MovedToSuper) @@ -1174,13 +1170,12 @@ static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container, return; } - if (const ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){ + if (const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){ for (const auto *P : Protocol->protocols()) CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper); } - if (const ObjCInterfaceDecl * - Interface = dyn_cast<ObjCInterfaceDecl>(Container)) { + if (const auto *Interface = dyn_cast<ObjCInterfaceDecl>(Container)) { for (const auto *P : Interface->protocols()) CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper); @@ -1204,12 +1199,12 @@ static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, SmallVectorImpl<const ObjCMethodDecl *> &overridden) { assert(Method->isOverriding()); - if (const ObjCProtocolDecl * - ProtD = dyn_cast<ObjCProtocolDecl>(Method->getDeclContext())) { + if (const auto *ProtD = + dyn_cast<ObjCProtocolDecl>(Method->getDeclContext())) { CollectOverriddenMethods(ProtD, Method, overridden); - } else if (const ObjCImplDecl * - IMD = dyn_cast<ObjCImplDecl>(Method->getDeclContext())) { + } else if (const auto *IMD = + dyn_cast<ObjCImplDecl>(Method->getDeclContext())) { const ObjCInterfaceDecl *ID = IMD->getClassInterface(); if (!ID) return; @@ -1221,8 +1216,8 @@ static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, Method = IFaceMeth; CollectOverriddenMethods(ID, Method, overridden); - } else if (const ObjCCategoryDecl * - CatD = dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) { + } else if (const auto *CatD = + dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) { const ObjCInterfaceDecl *ID = CatD->getClassInterface(); if (!ID) return; @@ -1265,7 +1260,7 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const { return nullptr; if (isPropertyAccessor()) { - const ObjCContainerDecl *Container = cast<ObjCContainerDecl>(getParent()); + const auto *Container = cast<ObjCContainerDecl>(getParent()); bool IsGetter = (NumArgs == 0); bool IsInstance = isInstanceMethod(); @@ -1328,11 +1323,9 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const { OverridesTy Overrides; getOverriddenMethods(Overrides); - for (OverridesTy::const_iterator I = Overrides.begin(), E = Overrides.end(); - I != E; ++I) { - if (const ObjCPropertyDecl *Prop = (*I)->findPropertyDecl(false)) + for (const auto *Override : Overrides) + if (const ObjCPropertyDecl *Prop = Override->findPropertyDecl(false)) return Prop; - } return nullptr; } @@ -1422,7 +1415,7 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(const ASTContext &C, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc, bool isInternal){ - ObjCInterfaceDecl *Result = new (C, DC) + auto *Result = new (C, DC) ObjCInterfaceDecl(C, DC, atLoc, Id, typeParamList, ClassLoc, PrevDecl, isInternal); Result->Data.setInt(!C.getLangOpts().Modules); @@ -1432,12 +1425,9 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(const ASTContext &C, ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { - ObjCInterfaceDecl *Result = new (C, ID) ObjCInterfaceDecl(C, nullptr, - SourceLocation(), - nullptr, - nullptr, - SourceLocation(), - nullptr, false); + auto *Result = new (C, ID) + ObjCInterfaceDecl(C, nullptr, SourceLocation(), nullptr, nullptr, + SourceLocation(), nullptr, false); Result->Data.setInt(!C.getLangOpts().Modules); return Result; } @@ -1451,11 +1441,11 @@ ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC, : ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, AtLoc), redeclarable_base(C) { setPreviousDecl(PrevDecl); - + // Copy the 'data' pointer over. if (PrevDecl) Data = PrevDecl->Data; - + setImplicit(IsInternal); setTypeParamList(typeParamList); @@ -1469,9 +1459,9 @@ void ObjCInterfaceDecl::LoadExternalDefinition() const { } void ObjCInterfaceDecl::setExternallyCompleted() { - assert(getASTContext().getExternalSource() && + assert(getASTContext().getExternalSource() && "Class can't be externally completed without an external source"); - assert(hasDefinition() && + assert(hasDefinition() && "Forward declarations can't be externally completed"); data().ExternallyCompleted = true; } @@ -1495,7 +1485,7 @@ bool ObjCInterfaceDecl::hasDesignatedInitializers() const { StringRef ObjCInterfaceDecl::getObjCRuntimeNameAsString() const { - if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>()) + if (const auto *ObjCRTName = getAttr<ObjCRuntimeNameAttr>()) return ObjCRTName->getMetadataName(); return getName(); @@ -1506,7 +1496,7 @@ ObjCImplementationDecl::getObjCRuntimeNameAsString() const { if (ObjCInterfaceDecl *ID = const_cast<ObjCImplementationDecl*>(this)->getClassInterface()) return ID->getObjCRuntimeNameAsString(); - + return getName(); } @@ -1514,11 +1504,11 @@ ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const { if (const ObjCInterfaceDecl *Def = getDefinition()) { if (data().ExternallyCompleted) LoadExternalDefinition(); - + return getASTContext().getObjCImplementation( const_cast<ObjCInterfaceDecl*>(Def)); } - + // FIXME: Should make sure no callers ever do this. return nullptr; } @@ -1586,7 +1576,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() { // cached and complete! if (!data().IvarListMissingImplementation) return data().IvarList; - + if (ObjCImplementationDecl *ImplDecl = getImplementation()) { data().IvarListMissingImplementation = false; if (!ImplDecl->ivar_empty()) { @@ -1603,7 +1593,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() { curIvar->setNextIvar(IV); curIvar = IV; } - + if (!layout.empty()) { // Order synthesized ivars by their size. std::stable_sort(layout.begin(), layout.end()); @@ -1669,7 +1659,7 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool RHSIsQualifiedID) { if (!hasDefinition()) return false; - + ObjCInterfaceDecl *IDecl = this; // 1st, look up the class. for (auto *PI : IDecl->protocols()){ @@ -1731,9 +1721,9 @@ ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC, "Invalid ivar decl context!"); // Once a new ivar is created in any of class/class-extension/implementation // decl contexts, the previously built IvarList must be rebuilt. - ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(DC); + auto *ID = dyn_cast<ObjCInterfaceDecl>(DC); if (!ID) { - if (ObjCImplementationDecl *IM = dyn_cast<ObjCImplementationDecl>(DC)) + if (auto *IM = dyn_cast<ObjCImplementationDecl>(DC)) ID = IM->getClassInterface(); else ID = cast<ObjCCategoryDecl>(DC)->getClassInterface(); @@ -1752,7 +1742,7 @@ ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { } const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const { - const ObjCContainerDecl *DC = cast<ObjCContainerDecl>(getDeclContext()); + const auto *DC = cast<ObjCContainerDecl>(getDeclContext()); switch (DC->getKind()) { default: @@ -1762,7 +1752,7 @@ const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const { // Ivars can only appear in class extension categories. case ObjCCategory: { - const ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(DC); + const auto *CD = cast<ObjCCategoryDecl>(DC); assert(CD->IsClassExtension() && "invalid container for ivar!"); return CD->getClassInterface(); } @@ -1822,7 +1812,7 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl) { - ObjCProtocolDecl *Result = + auto *Result = new (C, DC) ObjCProtocolDecl(C, DC, Id, nameLoc, atStartLoc, PrevDecl); Result->Data.setInt(!C.getLangOpts().Modules); return Result; @@ -1879,9 +1869,9 @@ void ObjCProtocolDecl::allocateDefinitionData() { void ObjCProtocolDecl::startDefinition() { allocateDefinitionData(); - + // Update all of the declarations with a pointer to the definition. - for (auto RD : redecls()) + for (auto *RD : redecls()) RD->Data = this->Data; } @@ -1923,7 +1913,7 @@ void ObjCProtocolDecl::collectInheritedProtocolProperties( StringRef ObjCProtocolDecl::getObjCRuntimeNameAsString() const { - if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>()) + if (const auto *ObjCRTName = getAttr<ObjCRuntimeNameAttr>()) return ObjCRTName->getMetadataName(); return getName(); @@ -1936,7 +1926,7 @@ ObjCProtocolDecl::getObjCRuntimeNameAsString() const { void ObjCCategoryDecl::anchor() {} ObjCCategoryDecl::ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc, - SourceLocation ClassNameLoc, + SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, @@ -1957,7 +1947,7 @@ ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc, SourceLocation IvarRBraceLoc) { - ObjCCategoryDecl *CatDecl = + auto *CatDecl = new (C, DC) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, CategoryNameLoc, Id, IDecl, typeParamList, IvarLBraceLoc, IvarRBraceLoc); @@ -1995,11 +1985,10 @@ void ObjCCategoryDecl::setTypeParamList(ObjCTypeParamList *TPL) { if (!TPL) return; // Set the declaration context of each of the type parameters. - for (auto typeParam : *TypeParamList) + for (auto *typeParam : *TypeParamList) typeParam->setDeclContext(this); } - //===----------------------------------------------------------------------===// // ObjCCategoryImplDecl //===----------------------------------------------------------------------===// @@ -2019,7 +2008,7 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC, atStartLoc, CategoryNameLoc); } -ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C, +ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) ObjCCategoryImplDecl(nullptr, nullptr, nullptr, SourceLocation(), SourceLocation(), @@ -2044,13 +2033,11 @@ void ObjCImplDecl::addPropertyImplementation(ObjCPropertyImplDecl *property) { void ObjCImplDecl::setClassInterface(ObjCInterfaceDecl *IFace) { ASTContext &Ctx = getASTContext(); - if (ObjCImplementationDecl *ImplD - = dyn_cast_or_null<ObjCImplementationDecl>(this)) { + if (auto *ImplD = dyn_cast_or_null<ObjCImplementationDecl>(this)) { if (IFace) Ctx.setObjCImplementation(IFace, ImplD); - } else if (ObjCCategoryImplDecl *ImplD = - dyn_cast_or_null<ObjCCategoryImplDecl>(this)) { + } else if (auto *ImplD = dyn_cast_or_null<ObjCCategoryImplDecl>(this)) { if (ObjCCategoryDecl *CD = IFace->FindCategoryDeclaration(getIdentifier())) Ctx.setObjCImplementation(CD, ImplD); } @@ -2139,8 +2126,7 @@ void ObjCImplementationDecl::setIvarInitializers(ASTContext &C, unsigned numInitializers) { if (numInitializers > 0) { NumIvarInitializers = numInitializers; - CXXCtorInitializer **ivarInitializers = - new (C) CXXCtorInitializer*[NumIvarInitializers]; + auto **ivarInitializers = new (C) CXXCtorInitializer*[NumIvarInitializers]; memcpy(ivarInitializers, initializers, numInitializers * sizeof(CXXCtorInitializer*)); IvarInitializers = ivarInitializers; |
