summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/AST/DeclObjC.h3
-rw-r--r--clang/lib/AST/DeclObjC.cpp10
-rw-r--r--clang/lib/AST/DeclPrinter.cpp5
-rw-r--r--clang/lib/Rewrite/Frontend/RewriteObjC.cpp6
-rw-r--r--clang/tools/libclang/IndexDecl.cpp7
5 files changed, 13 insertions, 18 deletions
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index 9527a4c62fa..cdd7d2602de 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -2109,6 +2109,9 @@ public:
SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
+ typedef llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>> ivar_range;
+
+ ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); }
ivar_iterator ivar_begin() const {
return ivar_iterator(decls_begin());
}
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 6b05b7ec222..84e329bf186 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -1239,19 +1239,17 @@ ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() {
data().IvarListMissingImplementation = false;
if (!ImplDecl->ivar_empty()) {
SmallVector<SynthesizeIvarChunk, 16> layout;
- for (ObjCImplementationDecl::ivar_iterator I = ImplDecl->ivar_begin(),
- E = ImplDecl->ivar_end(); I != E; ++I) {
- ObjCIvarDecl *IV = *I;
+ for (auto *IV : ImplDecl->ivars()) {
if (IV->getSynthesize() && !IV->isInvalidDecl()) {
layout.push_back(SynthesizeIvarChunk(
IV->getASTContext().getTypeSize(IV->getType()), IV));
continue;
}
if (!data().IvarList)
- data().IvarList = *I;
+ data().IvarList = IV;
else
- curIvar->setNextIvar(*I);
- curIvar = *I;
+ curIvar->setNextIvar(IV);
+ curIvar = IV;
}
if (!layout.empty()) {
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index f19edbad1be..bbe777b93c9 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -961,10 +961,9 @@ void DeclPrinter::VisitObjCImplementationDecl(ObjCImplementationDecl *OID) {
if (OID->ivar_size() > 0) {
Out << "{\n";
Indentation += Policy.Indentation;
- for (ObjCImplementationDecl::ivar_iterator I = OID->ivar_begin(),
- E = OID->ivar_end(); I != E; ++I) {
+ for (const auto *I : OID->ivars()) {
Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
- getAsString(Policy) << ' ' << **I << ";\n";
+ getAsString(Policy) << ' ' << *I << ";\n";
}
Indentation -= Policy.Indentation;
Out << "}\n";
diff --git a/clang/lib/Rewrite/Frontend/RewriteObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteObjC.cpp
index 735d1021fe3..e2bbc92baaf 100644
--- a/clang/lib/Rewrite/Frontend/RewriteObjC.cpp
+++ b/clang/lib/Rewrite/Frontend/RewriteObjC.cpp
@@ -5384,10 +5384,8 @@ void RewriteObjCFragileABI::RewriteObjCClassMetaData(ObjCImplementationDecl *IDe
ObjCInterfaceDecl::ivar_iterator IVI, IVE;
SmallVector<ObjCIvarDecl *, 8> IVars;
if (!IDecl->ivar_empty()) {
- for (ObjCInterfaceDecl::ivar_iterator
- IV = IDecl->ivar_begin(), IVEnd = IDecl->ivar_end();
- IV != IVEnd; ++IV)
- IVars.push_back(*IV);
+ for (auto *IV : IDecl->ivars())
+ IVars.push_back(IV);
IVI = IDecl->ivar_begin();
IVE = IDecl->ivar_end();
} else {
diff --git a/clang/tools/libclang/IndexDecl.cpp b/clang/tools/libclang/IndexDecl.cpp
index 4372ab34666..64052ed3094 100644
--- a/clang/tools/libclang/IndexDecl.cpp
+++ b/clang/tools/libclang/IndexDecl.cpp
@@ -165,11 +165,8 @@ public:
// Index the ivars first to make sure the synthesized ivars are indexed
// before indexing the methods that can reference them.
- for (ObjCImplementationDecl::ivar_iterator
- IvarI = D->ivar_begin(),
- IvarE = D->ivar_end(); IvarI != IvarE; ++IvarI) {
- IndexCtx.indexDecl(*IvarI);
- }
+ for (const auto *IvarI : D->ivars())
+ IndexCtx.indexDecl(IvarI);
for (const auto *I : D->decls()) {
if (!isa<ObjCIvarDecl>(I))
IndexCtx.indexDecl(I);
OpenPOWER on IntegriCloud