r204061 - [C++11] Replacing DeclContext iterators using_directives_begin() and using_directives_end() with iterator_range using_directives(). Updating all of the usages of the iterators with range-based for loops, and removing the no-longer-needed iterator versions. Also used as an opportunity to normalize the name from getUsingDirectives() to using_directives().
Aaron Ballman
aaron at aaronballman.com
Mon Mar 17 10:14:13 PDT 2014
Author: aaronballman
Date: Mon Mar 17 12:14:12 2014
New Revision: 204061
URL: http://llvm.org/viewvc/llvm-project?rev=204061&view=rev
Log:
[C++11] Replacing DeclContext iterators using_directives_begin() and using_directives_end() with iterator_range using_directives(). Updating all of the usages of the iterators with range-based for loops, and removing the no-longer-needed iterator versions. Also used as an opportunity to normalize the name from getUsingDirectives() to using_directives().
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/DeclBase.cpp
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=204061&r1=204060&r2=204061&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Mar 17 12:14:12 2014
@@ -1592,21 +1592,9 @@ public:
all_lookups_iterator noload_lookups_begin() const;
all_lookups_iterator noload_lookups_end() const;
- /// udir_iterator - Iterates through the using-directives stored
- /// within this context.
- typedef UsingDirectiveDecl * const * udir_iterator;
+ typedef llvm::iterator_range<UsingDirectiveDecl * const *> udir_range;
- typedef llvm::iterator_range<udir_iterator> udir_range;
-
- udir_range getUsingDirectives() const;
-
- udir_iterator using_directives_begin() const {
- return getUsingDirectives().begin();
- }
-
- udir_iterator using_directives_end() const {
- return getUsingDirectives().end();
- }
+ udir_range using_directives() const;
// These are all defined in DependentDiagnostic.h.
class ddiag_iterator;
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=204061&r1=204060&r2=204061&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Mar 17 12:14:12 2014
@@ -1523,13 +1523,13 @@ void DeclContext::makeDeclVisibleInConte
/// Returns iterator range [First, Last) of UsingDirectiveDecls stored within
/// this context.
-DeclContext::udir_range
-DeclContext::getUsingDirectives() const {
+DeclContext::udir_range DeclContext::using_directives() const {
// FIXME: Use something more efficient than normal lookup for using
// directives. In C++, using directives are looked up more than anything else.
lookup_const_result Result = lookup(UsingDirectiveDecl::getName());
- return udir_range(reinterpret_cast<udir_iterator>(Result.begin()),
- reinterpret_cast<udir_iterator>(Result.end()));
+ return udir_range(
+ reinterpret_cast<UsingDirectiveDecl *const *>(Result.begin()),
+ reinterpret_cast<UsingDirectiveDecl *const *>(Result.end()));
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=204061&r1=204060&r2=204061&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Mar 17 12:14:12 2014
@@ -151,7 +151,7 @@ namespace {
void addUsingDirectives(DeclContext *DC, DeclContext *EffectiveDC) {
SmallVector<DeclContext*,4> queue;
while (true) {
- for (auto UD : DC->getUsingDirectives()) {
+ for (auto UD : DC->using_directives()) {
DeclContext *NS = UD->getNominatedNamespace();
if (visited.insert(NS)) {
addUsingDirective(UD, EffectiveDC);
@@ -1448,10 +1448,8 @@ static bool LookupQualifiedNameInUsingDi
DeclContext *StartDC) {
assert(StartDC->isFileContext() && "start context is not a file context");
- DeclContext::udir_iterator I = StartDC->using_directives_begin();
- DeclContext::udir_iterator E = StartDC->using_directives_end();
-
- if (I == E) return false;
+ DeclContext::udir_range UsingDirectives = StartDC->using_directives();
+ if (UsingDirectives.begin() == UsingDirectives.end()) return false;
// We have at least added all these contexts to the queue.
llvm::SmallPtrSet<DeclContext*, 8> Visited;
@@ -1463,8 +1461,8 @@ static bool LookupQualifiedNameInUsingDi
// We have already looked into the initial namespace; seed the queue
// with its using-children.
- for (; I != E; ++I) {
- NamespaceDecl *ND = (*I)->getNominatedNamespace()->getOriginalNamespace();
+ for (auto *I : UsingDirectives) {
+ NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
if (Visited.insert(ND))
Queue.push_back(ND);
}
@@ -1511,7 +1509,7 @@ static bool LookupQualifiedNameInUsingDi
continue;
}
- for (auto I : ND->getUsingDirectives()) {
+ for (auto I : ND->using_directives()) {
NamespaceDecl *Nom = I->getNominatedNamespace();
if (Visited.insert(Nom))
Queue.push_back(Nom);
@@ -3074,7 +3072,7 @@ static void LookupVisibleDecls(DeclConte
// Traverse using directives for qualified name lookup.
if (QualifiedNameLookup) {
ShadowContextRAII Shadow(Visited);
- for (auto I : Ctx->getUsingDirectives()) {
+ for (auto I : Ctx->using_directives()) {
LookupVisibleDecls(I->getNominatedNamespace(), Result,
QualifiedNameLookup, InBaseClass, Consumer, Visited);
}
More information about the cfe-commits
mailing list