From fc41e95acee43f77edb421ffe6e0f96088ff7fe2 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 13 Mar 2014 18:47:37 +0000 Subject: [PATCH] [C++11] Replacing ObjCContainerDecl iterators prop_begin() and prop_end() with iterator_range props(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203830 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclObjC.h | 4 ++ lib/ARCMigrate/ObjCMT.cpp | 8 +--- lib/ARCMigrate/TransProperties.cpp | 10 ++--- lib/AST/DeclObjC.cpp | 25 ++++-------- lib/CodeGen/CGDebugInfo.cpp | 4 +- lib/CodeGen/CGObjCGNU.cpp | 5 +-- lib/CodeGen/CGObjCMac.cpp | 16 +++----- lib/Rewrite/Frontend/RewriteModernObjC.cpp | 33 +++++----------- lib/Rewrite/Frontend/RewriteObjC.cpp | 15 +++----- lib/Sema/SemaCodeComplete.cpp | 18 +++------ lib/Sema/SemaDeclObjC.cpp | 10 ++--- lib/Sema/SemaObjCProperty.cpp | 38 ++++++------------- .../Checkers/DirectIvarAssignment.cpp | 5 +-- 13 files changed, 61 insertions(+), 130 deletions(-) diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 41d86ffff5..bf3c52c460 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -521,6 +521,10 @@ public: // Iterator access to properties. typedef specific_decl_iterator prop_iterator; + typedef llvm::iterator_range> + prop_range; + + prop_range props() const { return prop_range(prop_begin(), prop_end()); } prop_iterator prop_begin() const { return prop_iterator(decls_begin()); } diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index a88085fe6b..4453590d45 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -488,9 +488,7 @@ void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx, if (!(ASTMigrateActions & FrontendOptions::ObjCMT_ReturnsInnerPointerProperty)) return; - for (ObjCContainerDecl::prop_iterator P = D->prop_begin(), - E = D->prop_end(); P != E; ++P) { - ObjCPropertyDecl *Prop = *P; + for (auto *Prop : D->props()) { if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) && !Prop->isDeprecated()) migratePropertyNsReturnsInnerPointer(Ctx, Prop); @@ -507,9 +505,7 @@ ClassImplementsAllMethodsAndProperties(ASTContext &Ctx, // in class interface. bool HasAtleastOneRequiredProperty = false; if (const ObjCProtocolDecl *PDecl = Protocol->getDefinition()) - for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(), - E = PDecl->prop_end(); P != E; ++P) { - ObjCPropertyDecl *Property = *P; + for (const auto *Property : PDecl->props()) { if (Property->getPropertyImplementation() == ObjCPropertyDecl::Optional) continue; HasAtleastOneRequiredProperty = true; diff --git a/lib/ARCMigrate/TransProperties.cpp b/lib/ARCMigrate/TransProperties.cpp index b6ddc43dd6..008493a87c 100644 --- a/lib/ARCMigrate/TransProperties.cpp +++ b/lib/ARCMigrate/TransProperties.cpp @@ -75,17 +75,15 @@ public: static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps, AtPropDeclsTy *PrevAtProps = 0) { - for (ObjCInterfaceDecl::prop_iterator - propI = D->prop_begin(), - propE = D->prop_end(); propI != propE; ++propI) { - if (propI->getAtLoc().isInvalid()) + for (auto *Prop : D->props()) { + if (Prop->getAtLoc().isInvalid()) continue; - unsigned RawLoc = propI->getAtLoc().getRawEncoding(); + unsigned RawLoc = Prop->getAtLoc().getRawEncoding(); if (PrevAtProps) if (PrevAtProps->find(RawLoc) != PrevAtProps->end()) continue; PropsTy &props = AtProps[RawLoc]; - props.push_back(*propI); + props.push_back(Prop); } } diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 094110fecf..274e3faf86 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -125,8 +125,7 @@ ObjCContainerDecl::HasUserDeclaredSetterMethod(const ObjCPropertyDecl *Property) // Also search through the categories looking for a 'readwrite' declaration // of this property. If one found, presumably a setter will be provided // (properties declared in categories will not get auto-synthesized). - for (ObjCContainerDecl::prop_iterator P = Cat->prop_begin(), - E = Cat->prop_end(); P != E; ++P) + for (const auto *P : Cat->props()) if (P->getIdentifier() == Property->getIdentifier()) { if (P->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_readwrite) return true; @@ -286,9 +285,7 @@ ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass( void ObjCInterfaceDecl::collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const { - for (ObjCContainerDecl::prop_iterator P = prop_begin(), - E = prop_end(); P != E; ++P) { - ObjCPropertyDecl *Prop = *P; + for (auto *Prop : props()) { PM[Prop->getIdentifier()] = Prop; PO.push_back(Prop); } @@ -1114,13 +1111,11 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const { bool IsGetter = (NumArgs == 0); - for (ObjCContainerDecl::prop_iterator I = Container->prop_begin(), - E = Container->prop_end(); - I != E; ++I) { - Selector NextSel = IsGetter ? (*I)->getGetterName() - : (*I)->getSetterName(); + for (const auto *I : Container->props()) { + Selector NextSel = IsGetter ? I->getGetterName() + : I->getSetterName(); if (NextSel == Sel) - return *I; + return I; } llvm_unreachable("Marked as a property accessor but no property found!"); @@ -1606,9 +1601,7 @@ void ObjCProtocolDecl::collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const { if (const ObjCProtocolDecl *PDecl = getDefinition()) { - for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(), - E = PDecl->prop_end(); P != E; ++P) { - ObjCPropertyDecl *Prop = *P; + for (auto *Prop : PDecl->props()) { // Insert into PM if not there already. PM.insert(std::make_pair(Prop->getIdentifier(), Prop)); PO.push_back(Prop); @@ -1626,9 +1619,7 @@ void ObjCProtocolDecl::collectInheritedProtocolProperties( ProtocolPropertyMap &PM) const { if (const ObjCProtocolDecl *PDecl = getDefinition()) { bool MatchFound = false; - for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(), - E = PDecl->prop_end(); P != E; ++P) { - ObjCPropertyDecl *Prop = *P; + for (auto *Prop : PDecl->props()) { if (Prop == Property) continue; if (Prop->getIdentifier() == Property->getIdentifier()) { diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index ebca5f8f10..b2e247aa0a 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1668,9 +1668,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, } // Create entries for all of the properties. - for (ObjCContainerDecl::prop_iterator I = ID->prop_begin(), - E = ID->prop_end(); I != E; ++I) { - const ObjCPropertyDecl *PD = *I; + for (const auto *PD : ID->props()) { SourceLocation Loc = PD->getLocation(); llvm::DIFile PUnit = getOrCreateFile(Loc); unsigned PLine = getLineNumber(Loc); diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 66c55c4d7e..a95b046750 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -1822,11 +1822,8 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { // Add all of the property methods need adding to the method list and to the // property metadata list. - for (ObjCContainerDecl::prop_iterator - iter = PD->prop_begin(), endIter = PD->prop_end(); - iter != endIter ; iter++) { + for (auto *property : PD->props()) { std::vector Fields; - ObjCPropertyDecl *property = *iter; Fields.push_back(MakePropertyEncodingString(property, 0)); PushPropertyAttributes(Fields, property); diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 6e2a044993..2296f0a30e 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -999,7 +999,7 @@ protected: llvm::SmallPtrSet &PropertySet, SmallVectorImpl &Properties, const Decl *Container, - const ObjCProtocolDecl *PROTO, + const ObjCProtocolDecl *Proto, const ObjCCommonTypesHelper &ObjCTypes); /// GetProtocolRef - Return a reference to the internal protocol @@ -2773,14 +2773,12 @@ void CGObjCCommonMac:: PushProtocolProperties(llvm::SmallPtrSet &PropertySet, SmallVectorImpl &Properties, const Decl *Container, - const ObjCProtocolDecl *PROTO, + const ObjCProtocolDecl *Proto, const ObjCCommonTypesHelper &ObjCTypes) { - for (ObjCProtocolDecl::protocol_iterator P = PROTO->protocol_begin(), - E = PROTO->protocol_end(); P != E; ++P) + for (ObjCProtocolDecl::protocol_iterator P = Proto->protocol_begin(), + E = Proto->protocol_end(); P != E; ++P) PushProtocolProperties(PropertySet, Properties, Container, (*P), ObjCTypes); - for (ObjCContainerDecl::prop_iterator I = PROTO->prop_begin(), - E = PROTO->prop_end(); I != E; ++I) { - const ObjCPropertyDecl *PD = *I; + for (const auto *PD : Proto->props()) { if (!PropertySet.insert(PD->getIdentifier())) continue; llvm::Constant *Prop[] = { @@ -2809,9 +2807,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name, const ObjCCommonTypesHelper &ObjCTypes) { SmallVector Properties; llvm::SmallPtrSet PropertySet; - for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(), - E = OCD->prop_end(); I != E; ++I) { - const ObjCPropertyDecl *PD = *I; + for (const auto *PD : OCD->props()) { PropertySet.insert(PD->getIdentifier()); llvm::Constant *Prop[] = { GetPropertyName(PD->getIdentifier()), diff --git a/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/lib/Rewrite/Frontend/RewriteModernObjC.cpp index cc6c0c7dee..0c27af06f8 100644 --- a/lib/Rewrite/Frontend/RewriteModernObjC.cpp +++ b/lib/Rewrite/Frontend/RewriteModernObjC.cpp @@ -1160,9 +1160,8 @@ void RewriteModernObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { ReplaceText(LocStart, 0, "// "); } - for (ObjCCategoryDecl::prop_iterator I = CatDecl->prop_begin(), - E = CatDecl->prop_end(); I != E; ++I) - RewriteProperty(*I); + for (auto *I : CatDecl->props()) + RewriteProperty(I); for (ObjCCategoryDecl::instmeth_iterator I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end(); @@ -1194,9 +1193,8 @@ void RewriteModernObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { I != E; ++I) RewriteMethodDeclaration(*I); - for (ObjCInterfaceDecl::prop_iterator I = PDecl->prop_begin(), - E = PDecl->prop_end(); I != E; ++I) - RewriteProperty(*I); + for (auto *I : PDecl->props()) + RewriteProperty(I); // Lastly, comment out the @end. SourceLocation LocEnd = PDecl->getAtEndRange().getBegin(); @@ -1453,9 +1451,8 @@ void RewriteModernObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) { // Mark this typedef as having been written into its c++ equivalent. ObjCWrittenInterfaces.insert(ClassDecl->getCanonicalDecl()); - for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(), - E = ClassDecl->prop_end(); I != E; ++I) - RewriteProperty(*I); + for (auto *I : ClassDecl->props()) + RewriteProperty(I); for (ObjCInterfaceDecl::instmeth_iterator I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end(); I != E; ++I) @@ -7089,11 +7086,7 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, PDecl->getNameAsString(), false); // Protocol's property metadata. - std::vector ProtocolProperties; - for (ObjCContainerDecl::prop_iterator I = PDecl->prop_begin(), - E = PDecl->prop_end(); I != E; ++I) - ProtocolProperties.push_back(*I); - + SmallVector ProtocolProperties(PDecl->props()); Write_prop_list_t_initializer(*this, Context, Result, ProtocolProperties, /* Container */0, "_OBJC_PROTOCOL_PROPERTIES_", @@ -7310,11 +7303,7 @@ void RewriteModernObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl, IDecl->getNameAsString()); // Protocol's property metadata. - std::vector ClassProperties; - for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(), - E = CDecl->prop_end(); I != E; ++I) - ClassProperties.push_back(*I); - + SmallVector ClassProperties(CDecl->props()); Write_prop_list_t_initializer(*this, Context, Result, ClassProperties, /* Container */IDecl, "_OBJC_$_PROP_LIST_", @@ -7569,11 +7558,7 @@ void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl, FullCategoryName); // Protocol's property metadata. - std::vector ClassProperties; - for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(), - E = CDecl->prop_end(); I != E; ++I) - ClassProperties.push_back(*I); - + SmallVector ClassProperties(CDecl->props()); Write_prop_list_t_initializer(*this, Context, Result, ClassProperties, /* Container */IDecl, "_OBJC_$_PROP_LIST_", diff --git a/lib/Rewrite/Frontend/RewriteObjC.cpp b/lib/Rewrite/Frontend/RewriteObjC.cpp index 64f55ad439..32c3477fa6 100644 --- a/lib/Rewrite/Frontend/RewriteObjC.cpp +++ b/lib/Rewrite/Frontend/RewriteObjC.cpp @@ -980,9 +980,8 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { // FIXME: handle category headers that are declared across multiple lines. ReplaceText(LocStart, 0, "// "); - for (ObjCCategoryDecl::prop_iterator I = CatDecl->prop_begin(), - E = CatDecl->prop_end(); I != E; ++I) - RewriteProperty(*I); + for (auto *I : CatDecl->props()) + RewriteProperty(I); for (ObjCCategoryDecl::instmeth_iterator I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end(); @@ -1014,9 +1013,8 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { I != E; ++I) RewriteMethodDeclaration(*I); - for (ObjCInterfaceDecl::prop_iterator I = PDecl->prop_begin(), - E = PDecl->prop_end(); I != E; ++I) - RewriteProperty(*I); + for (auto *I : PDecl->props()) + RewriteProperty(I); // Lastly, comment out the @end. SourceLocation LocEnd = PDecl->getAtEndRange().getBegin(); @@ -1245,9 +1243,8 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) { } RewriteObjCInternalStruct(ClassDecl, ResultStr); - for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(), - E = ClassDecl->prop_end(); I != E; ++I) - RewriteProperty(*I); + for (auto *I : ClassDecl->props()) + RewriteProperty(I); for (ObjCInterfaceDecl::instmeth_iterator I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end(); I != E; ++I) diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 832553aea7..f1da3b4ad1 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -3458,14 +3458,10 @@ static void AddObjCProperties(ObjCContainerDecl *Container, Container = getContainerDef(Container); // Add properties in this container. - for (ObjCContainerDecl::prop_iterator P = Container->prop_begin(), - PEnd = Container->prop_end(); - P != PEnd; - ++P) { + for (const auto *P : Container->props()) if (AddedProperties.insert(P->getIdentifier())) - Results.MaybeAddResult(Result(*P, Results.getBasePriority(*P), 0), + Results.MaybeAddResult(Result(P, Results.getBasePriority(P), 0), CurContext); - } // Add nullary methods if (AllowNullaryMethods) { @@ -6981,14 +6977,10 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, } } - for (unsigned I = 0, N = Containers.size(); I != N; ++I) { - for (ObjCContainerDecl::prop_iterator P = Containers[I]->prop_begin(), - PEnd = Containers[I]->prop_end(); - P != PEnd; ++P) { - AddObjCKeyValueCompletions(*P, IsInstanceMethod, ReturnType, Context, + for (unsigned I = 0, N = Containers.size(); I != N; ++I) + for (auto *P : Containers[I]->props()) + AddObjCKeyValueCompletions(P, IsInstanceMethod, ReturnType, Context, KnownSelectors, Results); - } - } } Results.ExitScope(); diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index bd50cd289c..eb094b5625 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2680,10 +2680,8 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, // ProcessPropertyDecl is responsible for diagnosing conflicts with any // user-defined setter/getter. It also synthesizes setter/getter methods // and adds them to the DeclContext and global method pools. - for (ObjCContainerDecl::prop_iterator I = CDecl->prop_begin(), - E = CDecl->prop_end(); - I != E; ++I) - ProcessPropertyDecl(*I, CDecl); + for (auto *I : CDecl->props()) + ProcessPropertyDecl(I, CDecl); CDecl->setAtEndRange(AtEnd); } if (ObjCImplementationDecl *IC=dyn_cast(ClassDecl)) { @@ -2698,9 +2696,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, Ext = IDecl->visible_extensions_begin(), ExtEnd = IDecl->visible_extensions_end(); Ext != ExtEnd; ++Ext) { - for (ObjCContainerDecl::prop_iterator I = Ext->prop_begin(), - E = Ext->prop_end(); I != E; ++I) { - ObjCPropertyDecl *Property = *I; + for (const auto *Property : Ext->props()) { // Skip over properties declared @dynamic if (const ObjCPropertyImplDecl *PIDecl = IC->FindPropertyImplDecl(Property->getIdentifier())) diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 0ad935ea64..f4f0215108 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1446,11 +1446,8 @@ static void CollectImmediateProperties(ObjCContainerDecl *CDecl, bool IncludeProtocols = true) { if (ObjCInterfaceDecl *IDecl = dyn_cast(CDecl)) { - for (ObjCContainerDecl::prop_iterator P = IDecl->prop_begin(), - E = IDecl->prop_end(); P != E; ++P) { - ObjCPropertyDecl *Prop = *P; + for (auto *Prop : IDecl->props()) PropMap[Prop->getIdentifier()] = Prop; - } if (IncludeProtocols) { // Scan through class's protocols. for (ObjCInterfaceDecl::all_protocol_iterator @@ -1461,11 +1458,8 @@ static void CollectImmediateProperties(ObjCContainerDecl *CDecl, } if (ObjCCategoryDecl *CATDecl = dyn_cast(CDecl)) { if (!CATDecl->IsClassExtension()) - for (ObjCContainerDecl::prop_iterator P = CATDecl->prop_begin(), - E = CATDecl->prop_end(); P != E; ++P) { - ObjCPropertyDecl *Prop = *P; + for (auto *Prop : CATDecl->props()) PropMap[Prop->getIdentifier()] = Prop; - } if (IncludeProtocols) { // Scan through class's protocols. for (ObjCCategoryDecl::protocol_iterator PI = CATDecl->protocol_begin(), @@ -1474,9 +1468,7 @@ static void CollectImmediateProperties(ObjCContainerDecl *CDecl, } } else if (ObjCProtocolDecl *PDecl = dyn_cast(CDecl)) { - for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(), - E = PDecl->prop_end(); P != E; ++P) { - ObjCPropertyDecl *Prop = *P; + for (auto *Prop : PDecl->props()) { ObjCPropertyDecl *PropertyFromSuper = SuperPropMap[Prop->getIdentifier()]; // Exclude property for protocols which conform to class's super-class, // as super-class has to implement the property. @@ -1523,12 +1515,10 @@ Sema::IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, // look up a property declaration whose one of its accessors is implemented // by this method. - for (ObjCContainerDecl::prop_iterator P = IFace->prop_begin(), - E = IFace->prop_end(); P != E; ++P) { - ObjCPropertyDecl *property = *P; - if ((property->getGetterName() == IMD->getSelector() || - property->getSetterName() == IMD->getSelector()) && - (property->getPropertyIvarDecl() == IV)) + for (const auto *Property : IFace->props()) { + if ((Property->getGetterName() == IMD->getSelector() || + Property->getSetterName() == IMD->getSelector()) && + (Property->getPropertyIvarDecl() == IV)) return true; } return false; @@ -1733,13 +1723,10 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, } // Add the properties of 'PDecl' to the list of properties that // need to be implemented. - for (ObjCProtocolDecl::prop_iterator - PRI = PDecl->prop_begin(), PRE = PDecl->prop_end(); - PRI != PRE; ++PRI) { - ObjCPropertyDecl *PropDecl = *PRI; - if ((*LazyMap)[PRI->getIdentifier()]) + for (auto *PropDecl : PDecl->props()) { + if ((*LazyMap)[PropDecl->getIdentifier()]) continue; - PropMap[PRI->getIdentifier()] = PropDecl; + PropMap[PropDecl->getIdentifier()] = PropDecl; } } } @@ -1799,10 +1786,7 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl, // Rules apply in non-GC mode only if (getLangOpts().getGC() != LangOptions::NonGC) return; - for (ObjCContainerDecl::prop_iterator I = IDecl->prop_begin(), - E = IDecl->prop_end(); - I != E; ++I) { - ObjCPropertyDecl *Property = *I; + for (const auto *Property : IDecl->props()) { ObjCMethodDecl *GetterMethod = 0; ObjCMethodDecl *SetterMethod = 0; bool LookedUpGetterSetter = false; diff --git a/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp b/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp index f200dac1c6..7b5a5ed51c 100644 --- a/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp +++ b/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp @@ -124,10 +124,7 @@ void DirectIvarAssignment::checkASTDecl(const ObjCImplementationDecl *D, IvarToPropertyMapTy IvarToPropMap; // Find all properties for this class. - for (ObjCInterfaceDecl::prop_iterator I = InterD->prop_begin(), - E = InterD->prop_end(); I != E; ++I) { - ObjCPropertyDecl *PD = *I; - + for (const auto *PD : InterD->props()) { // Find the corresponding IVar. const ObjCIvarDecl *ID = findPropertyBackingIvar(PD, InterD, Mgr.getASTContext()); -- 2.40.0