r203933 - [C++11] Replacing DeclContext iterators lookups_begin() and lookups_end() with iterator_range lookups(). Similar for noload_lookups(). Updating all of the usages of the iterators with range-based for loops.
Aaron Ballman
aaron at aaronballman.com
Fri Mar 14 08:28:49 PDT 2014
Author: aaronballman
Date: Fri Mar 14 10:28:49 2014
New Revision: 203933
URL: http://llvm.org/viewvc/llvm-project?rev=203933&view=rev
Log:
[C++11] Replacing DeclContext iterators lookups_begin() and lookups_end() with iterator_range lookups(). Similar for noload_lookups(). Updating all of the usages of the iterators with range-based for loops.
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/DeclLookups.h
cfe/trunk/lib/Sema/SemaLookup.cpp
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=203933&r1=203932&r2=203933&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Mar 14 10:28:49 2014
@@ -1577,6 +1577,11 @@ public:
/// of looking up every possible name.
class all_lookups_iterator;
+ typedef llvm::iterator_range<all_lookups_iterator> lookups_range;
+
+ lookups_range lookups() const;
+ lookups_range noload_lookups() const;
+
/// \brief Iterators over all possible lookups within this context.
all_lookups_iterator lookups_begin() const;
all_lookups_iterator lookups_end() const;
Modified: cfe/trunk/include/clang/AST/DeclLookups.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclLookups.h?rev=203933&r1=203932&r2=203933&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclLookups.h (original)
+++ cfe/trunk/include/clang/AST/DeclLookups.h Fri Mar 14 10:28:49 2014
@@ -68,6 +68,10 @@ public:
}
};
+inline DeclContext::lookups_range DeclContext::lookups() const {
+ return lookups_range(lookups_begin(), lookups_end());
+}
+
inline DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
DeclContext *Primary = const_cast<DeclContext*>(this)->getPrimaryContext();
if (Primary->hasExternalVisibleStorage())
@@ -86,6 +90,10 @@ inline DeclContext::all_lookups_iterator
return all_lookups_iterator();
}
+inline DeclContext::lookups_range DeclContext::noload_lookups() const {
+ return lookups_range(noload_lookups_begin(), noload_lookups_end());
+}
+
inline
DeclContext::all_lookups_iterator DeclContext::noload_lookups_begin() const {
DeclContext *Primary = const_cast<DeclContext*>(this)->getPrimaryContext();
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=203933&r1=203932&r2=203933&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Mar 14 10:28:49 2014
@@ -3063,13 +3063,9 @@ static void LookupVisibleDecls(DeclConte
Result.getSema().ForceDeclarationOfImplicitMembers(Class);
// Enumerate all of the results in this context.
- for (DeclContext::all_lookups_iterator L = Ctx->lookups_begin(),
- LEnd = Ctx->lookups_end();
- L != LEnd; ++L) {
- DeclContext::lookup_result R = *L;
- for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E;
- ++I) {
- if (NamedDecl *ND = dyn_cast<NamedDecl>(*I)) {
+ for (const auto &R : Ctx->lookups()) {
+ for (auto *I : R) {
+ if (NamedDecl *ND = dyn_cast<NamedDecl>(I)) {
if ((ND = Result.getAcceptableDecl(ND))) {
Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
Visited.add(ND);
More information about the cfe-commits
mailing list