[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().

llvm-svn: 204061
This commit is contained in:
Aaron Ballman 2014-03-17 17:14:12 +00:00
parent 3f44cd7926
commit 804a7fb7ba
3 changed files with 13 additions and 27 deletions

View File

@ -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;

View File

@ -1523,13 +1523,13 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal) {
/// 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()));
}
//===----------------------------------------------------------------------===//

View File

@ -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 LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R,
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 LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R,
// 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 LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R,
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(DeclContext *Ctx, LookupResult &Result,
// 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);
}