mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-04 00:06:50 +00:00
[C++11] Replacing ObjCCategoryDecl iterators propimpl_begin() and propimpl_end() with iterator_range property_impls(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203930
This commit is contained in:
parent
5c77e39f2d
commit
d85eff49a3
@ -1866,6 +1866,12 @@ public:
|
||||
|
||||
// Iterator access to properties.
|
||||
typedef specific_decl_iterator<ObjCPropertyImplDecl> propimpl_iterator;
|
||||
typedef llvm::iterator_range<specific_decl_iterator<ObjCPropertyImplDecl>>
|
||||
propimpl_range;
|
||||
|
||||
propimpl_range property_impls() const {
|
||||
return propimpl_range(propimpl_begin(), propimpl_end());
|
||||
}
|
||||
propimpl_iterator propimpl_begin() const {
|
||||
return propimpl_iterator(decls_begin());
|
||||
}
|
||||
|
@ -113,23 +113,21 @@ public:
|
||||
|
||||
// For a 'dealloc' method use, find all property implementations in
|
||||
// this class implementation.
|
||||
for (ObjCImplDecl::propimpl_iterator
|
||||
I = IMD->propimpl_begin(), EI = IMD->propimpl_end(); I != EI; ++I) {
|
||||
ObjCPropertyImplDecl *PID = *I;
|
||||
if (PID->getPropertyImplementation() ==
|
||||
ObjCPropertyImplDecl::Synthesize) {
|
||||
ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||
ObjCMethodDecl *setterM = PD->getSetterMethodDecl();
|
||||
if (!(setterM && setterM->isDefined())) {
|
||||
ObjCPropertyDecl::PropertyAttributeKind AttrKind =
|
||||
PD->getPropertyAttributes();
|
||||
if (AttrKind &
|
||||
(ObjCPropertyDecl::OBJC_PR_retain |
|
||||
ObjCPropertyDecl::OBJC_PR_copy |
|
||||
ObjCPropertyDecl::OBJC_PR_strong))
|
||||
SynthesizedProperties[PD] = PID;
|
||||
}
|
||||
for (auto *PID : IMD->property_impls()) {
|
||||
if (PID->getPropertyImplementation() ==
|
||||
ObjCPropertyImplDecl::Synthesize) {
|
||||
ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||
ObjCMethodDecl *setterM = PD->getSetterMethodDecl();
|
||||
if (!(setterM && setterM->isDefined())) {
|
||||
ObjCPropertyDecl::PropertyAttributeKind AttrKind =
|
||||
PD->getPropertyAttributes();
|
||||
if (AttrKind &
|
||||
(ObjCPropertyDecl::OBJC_PR_retain |
|
||||
ObjCPropertyDecl::OBJC_PR_copy |
|
||||
ObjCPropertyDecl::OBJC_PR_strong))
|
||||
SynthesizedProperties[PD] = PID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now, remove all zeroing of ivars etc.
|
||||
|
@ -4936,22 +4936,14 @@ ASTContext::getObjCPropertyImplDeclForPropertyDecl(
|
||||
return 0;
|
||||
if (const ObjCCategoryImplDecl *CID =
|
||||
dyn_cast<ObjCCategoryImplDecl>(Container)) {
|
||||
for (ObjCCategoryImplDecl::propimpl_iterator
|
||||
i = CID->propimpl_begin(), e = CID->propimpl_end();
|
||||
i != e; ++i) {
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
if (PID->getPropertyDecl() == PD)
|
||||
return PID;
|
||||
}
|
||||
for (auto *PID : CID->property_impls())
|
||||
if (PID->getPropertyDecl() == PD)
|
||||
return PID;
|
||||
} else {
|
||||
const ObjCImplementationDecl *OID=cast<ObjCImplementationDecl>(Container);
|
||||
for (ObjCCategoryImplDecl::propimpl_iterator
|
||||
i = OID->propimpl_begin(), e = OID->propimpl_end();
|
||||
i != e; ++i) {
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
for (auto *PID : OID->property_impls())
|
||||
if (PID->getPropertyDecl() == PD)
|
||||
return PID;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1674,12 +1674,10 @@ void ObjCImplDecl::setClassInterface(ObjCInterfaceDecl *IFace) {
|
||||
///
|
||||
ObjCPropertyImplDecl *ObjCImplDecl::
|
||||
FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
|
||||
for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
for (auto *PID : property_impls())
|
||||
if (PID->getPropertyIvarDecl() &&
|
||||
PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
|
||||
return PID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1689,11 +1687,9 @@ FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
|
||||
///
|
||||
ObjCPropertyImplDecl *ObjCImplDecl::
|
||||
FindPropertyImplDecl(IdentifierInfo *Id) const {
|
||||
for (propimpl_iterator i = propimpl_begin(), e = propimpl_end(); i != e; ++i){
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
for (auto *PID : property_impls())
|
||||
if (PID->getPropertyDecl()->getIdentifier() == Id)
|
||||
return PID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -404,10 +404,7 @@ static Stmt *createObjCPropertyGetter(ASTContext &Ctx,
|
||||
const ObjCImplementationDecl *ImplDecl =
|
||||
IVar->getContainingInterface()->getImplementation();
|
||||
if (ImplDecl) {
|
||||
typedef ObjCImplementationDecl::propimpl_iterator propimpl_iterator;
|
||||
for (propimpl_iterator I = ImplDecl->propimpl_begin(),
|
||||
E = ImplDecl->propimpl_end();
|
||||
I != E; ++I) {
|
||||
for (const auto *I : ImplDecl->property_impls()) {
|
||||
if (I->getPropertyDecl() != Prop)
|
||||
continue;
|
||||
|
||||
|
@ -2057,12 +2057,9 @@ llvm::Constant *CGObjCGNU::GeneratePropertyList(const ObjCImplementationDecl *OI
|
||||
|
||||
// Add all of the property methods need adding to the method list and to the
|
||||
// property metadata list.
|
||||
for (ObjCImplDecl::propimpl_iterator
|
||||
iter = OID->propimpl_begin(), endIter = OID->propimpl_end();
|
||||
iter != endIter ; iter++) {
|
||||
for (auto *propertyImpl : OID->property_impls()) {
|
||||
std::vector<llvm::Constant*> Fields;
|
||||
ObjCPropertyDecl *property = iter->getPropertyDecl();
|
||||
ObjCPropertyImplDecl *propertyImpl = *iter;
|
||||
ObjCPropertyDecl *property = propertyImpl->getPropertyDecl();
|
||||
bool isSynthesized = (propertyImpl->getPropertyImplementation() ==
|
||||
ObjCPropertyImplDecl::Synthesize);
|
||||
bool isDynamic = (propertyImpl->getPropertyImplementation() ==
|
||||
|
@ -3062,10 +3062,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
|
||||
// Class methods should always be defined.
|
||||
ClassMethods.push_back(GetMethodConstant(I));
|
||||
|
||||
for (ObjCImplementationDecl::propimpl_iterator
|
||||
i = ID->propimpl_begin(), e = ID->propimpl_end(); i != e; ++i) {
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
|
||||
for (const auto *PID : ID->property_impls()) {
|
||||
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize) {
|
||||
ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||
|
||||
@ -5650,10 +5647,7 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
|
||||
// Instance methods should always be defined.
|
||||
Methods.push_back(GetMethodConstant(I));
|
||||
|
||||
for (ObjCImplementationDecl::propimpl_iterator
|
||||
i = ID->propimpl_begin(), e = ID->propimpl_end(); i != e; ++i) {
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
|
||||
for (const auto *PID : ID->property_impls()) {
|
||||
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize){
|
||||
ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||
|
||||
|
@ -2752,10 +2752,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary(
|
||||
/// properties for an implementation.
|
||||
void CodeGenModule::EmitObjCPropertyImplementations(const
|
||||
ObjCImplementationDecl *D) {
|
||||
for (ObjCImplementationDecl::propimpl_iterator
|
||||
i = D->propimpl_begin(), e = D->propimpl_end(); i != e; ++i) {
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
|
||||
for (const auto *PID : D->property_impls()) {
|
||||
// Dynamic is just for type-checking.
|
||||
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize) {
|
||||
ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||
|
@ -1404,12 +1404,8 @@ void RewriteModernObjC::RewriteImplementationDecl(Decl *OID) {
|
||||
const char *endBuf = SM->getCharacterData(LocEnd);
|
||||
ReplaceText(LocStart, endBuf-startBuf, ResultStr);
|
||||
}
|
||||
for (ObjCCategoryImplDecl::propimpl_iterator
|
||||
I = IMD ? IMD->propimpl_begin() : CID->propimpl_begin(),
|
||||
E = IMD ? IMD->propimpl_end() : CID->propimpl_end();
|
||||
I != E; ++I) {
|
||||
RewritePropertyImplDecl(*I, IMD, CID);
|
||||
}
|
||||
for (auto *I : IMD ? IMD->property_impls() : CID->property_impls())
|
||||
RewritePropertyImplDecl(I, IMD, CID);
|
||||
|
||||
InsertText(IMD ? IMD->getLocEnd() : CID->getLocEnd(), "// ");
|
||||
}
|
||||
@ -7220,9 +7216,7 @@ void RewriteModernObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
for (ObjCImplDecl::propimpl_iterator Prop = IDecl->propimpl_begin(),
|
||||
PropEnd = IDecl->propimpl_end();
|
||||
Prop != PropEnd; ++Prop) {
|
||||
for (const auto *Prop : IDecl->property_impls()) {
|
||||
if (Prop->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
|
||||
continue;
|
||||
if (!Prop->getPropertyIvarDecl())
|
||||
@ -7475,9 +7469,7 @@ void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
for (ObjCImplDecl::propimpl_iterator Prop = IDecl->propimpl_begin(),
|
||||
PropEnd = IDecl->propimpl_end();
|
||||
Prop != PropEnd; ++Prop) {
|
||||
for (const auto *Prop : IDecl->property_impls()) {
|
||||
if (Prop->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
|
||||
continue;
|
||||
if (!Prop->getPropertyIvarDecl())
|
||||
|
@ -1197,12 +1197,8 @@ void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
|
||||
const char *endBuf = SM->getCharacterData(LocEnd);
|
||||
ReplaceText(LocStart, endBuf-startBuf, ResultStr);
|
||||
}
|
||||
for (ObjCCategoryImplDecl::propimpl_iterator
|
||||
I = IMD ? IMD->propimpl_begin() : CID->propimpl_begin(),
|
||||
E = IMD ? IMD->propimpl_end() : CID->propimpl_end();
|
||||
I != E; ++I) {
|
||||
RewritePropertyImplDecl(*I, IMD, CID);
|
||||
}
|
||||
for (auto *I : IMD ? IMD->property_impls() : CID->property_impls())
|
||||
RewritePropertyImplDecl(I, IMD, CID);
|
||||
|
||||
InsertText(IMD ? IMD->getLocEnd() : CID->getLocEnd(), "// ");
|
||||
}
|
||||
@ -5429,9 +5425,7 @@ void RewriteObjCFragileABI::RewriteObjCClassMetaData(ObjCImplementationDecl *IDe
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
for (ObjCImplDecl::propimpl_iterator Prop = IDecl->propimpl_begin(),
|
||||
PropEnd = IDecl->propimpl_end();
|
||||
Prop != PropEnd; ++Prop) {
|
||||
for (const auto *Prop : IDecl->property_impls()) {
|
||||
if (Prop->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
|
||||
continue;
|
||||
if (!Prop->getPropertyIvarDecl())
|
||||
@ -5710,9 +5704,7 @@ void RewriteObjCFragileABI::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *ID
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
for (ObjCImplDecl::propimpl_iterator Prop = IDecl->propimpl_begin(),
|
||||
PropEnd = IDecl->propimpl_end();
|
||||
Prop != PropEnd; ++Prop) {
|
||||
for (const auto *Prop : IDecl->property_impls()) {
|
||||
if (Prop->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
|
||||
continue;
|
||||
if (!Prop->getPropertyIvarDecl())
|
||||
|
@ -1703,9 +1703,7 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
|
||||
return;
|
||||
|
||||
llvm::DenseSet<ObjCPropertyDecl *> PropImplMap;
|
||||
for (ObjCImplDecl::propimpl_iterator
|
||||
I = IMPDecl->propimpl_begin(),
|
||||
EI = IMPDecl->propimpl_end(); I != EI; ++I)
|
||||
for (const auto *I : IMPDecl->property_impls())
|
||||
PropImplMap.insert(I->getPropertyDecl());
|
||||
|
||||
SelectorSet InsMap;
|
||||
@ -1836,9 +1834,7 @@ void Sema::DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D
|
||||
if (getLangOpts().getGC() == LangOptions::GCOnly)
|
||||
return;
|
||||
|
||||
for (ObjCImplementationDecl::propimpl_iterator
|
||||
i = D->propimpl_begin(), e = D->propimpl_end(); i != e; ++i) {
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
for (const auto *PID : D->property_impls()) {
|
||||
const ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||
if (PD && !PD->hasAttr<NSReturnsNotRetainedAttr>() &&
|
||||
!D->getInstanceMethod(PD->getGetterName())) {
|
||||
|
@ -208,9 +208,7 @@ static void checkObjCDealloc(const CheckerBase *Checker,
|
||||
|
||||
// Scan for missing and extra releases of ivars used by implementations
|
||||
// of synthesized properties
|
||||
for (ObjCImplementationDecl::propimpl_iterator I = D->propimpl_begin(),
|
||||
E = D->propimpl_end(); I!=E; ++I) {
|
||||
|
||||
for (const auto *I : D->property_impls()) {
|
||||
// We can only check the synthesized properties
|
||||
if (I->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize)
|
||||
continue;
|
||||
@ -258,7 +256,7 @@ static void checkObjCDealloc(const CheckerBase *Checker,
|
||||
}
|
||||
|
||||
PathDiagnosticLocation SDLoc =
|
||||
PathDiagnosticLocation::createBegin(*I, BR.getSourceManager());
|
||||
PathDiagnosticLocation::createBegin(I, BR.getSourceManager());
|
||||
|
||||
BR.EmitBasicReport(MD, Checker, name,
|
||||
categories::CoreFoundationObjectiveC, os.str(), SDLoc);
|
||||
|
@ -83,9 +83,8 @@ static void Scan(IvarUsageMap& M, const ObjCContainerDecl *D) {
|
||||
if (const ObjCImplementationDecl *ID = dyn_cast<ObjCImplementationDecl>(D)) {
|
||||
// Scan for @synthesized property methods that act as setters/getters
|
||||
// to an ivar.
|
||||
for (ObjCImplementationDecl::propimpl_iterator I = ID->propimpl_begin(),
|
||||
E = ID->propimpl_end(); I!=E; ++I)
|
||||
Scan(M, *I);
|
||||
for (const auto *I : ID->property_impls())
|
||||
Scan(M, I);
|
||||
|
||||
// Scan the associated categories as well.
|
||||
for (const auto *Cat : ID->getClassInterface()->visible_categories()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user