r203814 - [C++11] Replacing CXXRecordDecl iterators ctor_begin() and ctor_end() with iterator_range ctors(). Updating all of the usages of the iterators with range-based for loops.
Aaron Ballman
aaron at aaronballman.com
Thu Mar 13 09:51:27 PDT 2014
Author: aaronballman
Date: Thu Mar 13 11:51:27 2014
New Revision: 203814
URL: http://llvm.org/viewvc/llvm-project?rev=203814&view=rev
Log:
[C++11] Replacing CXXRecordDecl iterators ctor_begin() and ctor_end() with iterator_range ctors(). Updating all of the usages of the iterators with range-based for loops.
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=203814&r1=203813&r2=203814&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Mar 13 11:51:27 2014
@@ -730,6 +730,10 @@ public:
/// Iterator access to constructor members.
typedef specific_decl_iterator<CXXConstructorDecl> ctor_iterator;
+ typedef llvm::iterator_range<specific_decl_iterator<CXXConstructorDecl>>
+ ctor_range;
+
+ ctor_range ctors() const { return ctor_range(ctor_begin(), ctor_end()); }
ctor_iterator ctor_begin() const {
return ctor_iterator(decls_begin());
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=203814&r1=203813&r2=203814&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Mar 13 11:51:27 2014
@@ -5284,10 +5284,9 @@ bool Sema::ShouldDeleteSpecialMember(CXX
if (!Diagnose) return true;
// Find any user-declared move constructor.
- for (CXXRecordDecl::ctor_iterator I = RD->ctor_begin(),
- E = RD->ctor_end(); I != E; ++I) {
+ for (auto *I : RD->ctors()) {
if (I->isMoveConstructor()) {
- UserDeclaredMove = *I;
+ UserDeclaredMove = I;
break;
}
}
@@ -5393,11 +5392,10 @@ static bool findTrivialSpecialMember(Sem
CXXConstructorDecl *DefCtor = 0;
if (RD->needsImplicitDefaultConstructor())
S.DeclareImplicitDefaultConstructor(RD);
- for (CXXRecordDecl::ctor_iterator CI = RD->ctor_begin(),
- CE = RD->ctor_end(); CI != CE; ++CI) {
+ for (auto *CI : RD->ctors()) {
if (!CI->isDefaultConstructor())
continue;
- DefCtor = *CI;
+ DefCtor = CI;
if (!DefCtor->isUserProvided())
break;
}
@@ -5486,10 +5484,9 @@ static bool findTrivialSpecialMember(Sem
}
static CXXConstructorDecl *findUserDeclaredCtor(CXXRecordDecl *RD) {
- for (CXXRecordDecl::ctor_iterator CI = RD->ctor_begin(), CE = RD->ctor_end();
- CI != CE; ++CI)
+ for (auto *CI : RD->ctors())
if (!CI->isImplicit())
- return *CI;
+ return CI;
// Look for constructor templates.
typedef CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl> tmpl_iter;
@@ -8296,10 +8293,8 @@ private:
/// Process all constructors for a class.
void visitAll(const CXXRecordDecl *RD, VisitFn Callback) {
- for (CXXRecordDecl::ctor_iterator CtorIt = RD->ctor_begin(),
- CtorE = RD->ctor_end();
- CtorIt != CtorE; ++CtorIt)
- (this->*Callback)(*CtorIt);
+ for (const auto *Ctor : RD->ctors())
+ (this->*Callback)(Ctor);
for (CXXRecordDecl::specific_decl_iterator<FunctionTemplateDecl>
I(RD->decls_begin()), E(RD->decls_end());
I != E; ++I) {
@@ -9290,10 +9285,9 @@ static void diagnoseDeprecatedCopyOperat
RD->hasUserDeclaredCopyConstructor() &&
!S.getLangOpts().MSVCCompat) {
// Find any user-declared copy constructor.
- for (CXXRecordDecl::ctor_iterator I = RD->ctor_begin(),
- E = RD->ctor_end(); I != E; ++I) {
+ for (auto *I : RD->ctors()) {
if (I->isCopyConstructor()) {
- UserDeclaredOperation = *I;
+ UserDeclaredOperation = I;
break;
}
}
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp?rev=203814&r1=203813&r2=203814&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp Thu Mar 13 11:51:27 2014
@@ -216,8 +216,7 @@ public:
WalkAST walker(this, BR, mgr.getAnalysisDeclContext(RD));
// Check the constructors.
- for (CXXRecordDecl::ctor_iterator I = RD->ctor_begin(), E = RD->ctor_end();
- I != E; ++I) {
+ for (const auto *I : RD->ctors()) {
if (!I->isCopyOrMoveConstructor())
if (Stmt *Body = I->getBody()) {
walker.Visit(Body);
More information about the cfe-commits
mailing list