diff options
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 37db9aec637..9d0cf106ef7 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -4152,10 +4152,8 @@ TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet( // Build the list of identifiers that would be used for an absolute // (from the global context) NestedNameSpecifier referring to the current // context. - for (DeclContextList::reverse_iterator C = CurContextChain.rbegin(), - CEnd = CurContextChain.rend(); - C != CEnd; ++C) { - if (NamespaceDecl *ND = dyn_cast_or_null<NamespaceDecl>(*C)) + for (DeclContext *C : llvm::reverse(CurContextChain)) { + if (auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) CurContextIdentifiers.push_back(ND->getIdentifier()); } @@ -4183,13 +4181,11 @@ unsigned TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier( DeclContextList &DeclChain, NestedNameSpecifier *&NNS) { unsigned NumSpecifiers = 0; - for (DeclContextList::reverse_iterator C = DeclChain.rbegin(), - CEnd = DeclChain.rend(); - C != CEnd; ++C) { - if (NamespaceDecl *ND = dyn_cast_or_null<NamespaceDecl>(*C)) { + for (DeclContext *C : llvm::reverse(DeclChain)) { + if (auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) { NNS = NestedNameSpecifier::Create(Context, NNS, ND); ++NumSpecifiers; - } else if (RecordDecl *RD = dyn_cast_or_null<RecordDecl>(*C)) { + } else if (auto *RD = dyn_cast_or_null<RecordDecl>(C)) { NNS = NestedNameSpecifier::Create(Context, NNS, RD->isTemplateDecl(), RD->getTypeForDecl()); ++NumSpecifiers; @@ -4206,10 +4202,9 @@ void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier( DeclContextList FullNamespaceDeclChain(NamespaceDeclChain); // Eliminate common elements from the two DeclContext chains. - for (DeclContextList::reverse_iterator C = CurContextChain.rbegin(), - CEnd = CurContextChain.rend(); - C != CEnd && !NamespaceDeclChain.empty() && - NamespaceDeclChain.back() == *C; ++C) { + for (DeclContext *C : llvm::reverse(CurContextChain)) { + if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() != C) + break; NamespaceDeclChain.pop_back(); } |