diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-12-11 20:41:00 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-12-11 20:41:00 +0000 |
commit | e267ff35b2f4e9d2b0d8bf24109d41cc7398b61b (patch) | |
tree | 568838468f95906278ae3e3b1753e3ad21e58041 /lib/AST/DeclBase.cpp | |
parent | 7415326dcbba6f333f5f7708ac1bf4982f3adb5a (diff) |
Address some comments on the name lookup/DeclContext patch from Chris
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 3e0f158cbe..6ddb967a63 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -516,7 +516,7 @@ DeclContext::lookup(ASTContext &Context, DeclarationName Name) { // We have a small array. Look into it. unsigned Size = LookupPtr.getInt(); NamedDecl **Array = static_cast<NamedDecl**>(LookupPtr.getPointer()); - for (unsigned Idx = 0; Idx < Size; ++Idx) + for (unsigned Idx = 0; Idx != Size; ++Idx) if (Array[Idx]->getDeclName() == Name) { Result.first = &Array[Idx]; Result.second = Result.first + 1; @@ -566,12 +566,11 @@ void DeclContext::insertImpl(NamedDecl *D) { // from lookup(). There will be zero, one, or two declarations of // the same name. unsigned Match; - for (Match = 0; Match < Size; ++Match) { + for (Match = 0; Match != Size; ++Match) if (Array[Match]->getDeclName() == D->getDeclName()) - break; - } + break; - if (Match < Size) { + if (Match != Size) { // We found another declaration with the same name. If it's also // in the same identifier namespace, update the declaration in // place. @@ -590,7 +589,7 @@ void DeclContext::insertImpl(NamedDecl *D) { // declaration for C++ name lookup to operate properly. Therefore, // if our match is an ordinary name and the new name is in the // tag namespace, we'll insert the new declaration after it. - if (Match < Size && (NS == Decl::IDNS_Tag) && + if (Match != Size && (NS == Decl::IDNS_Tag) && (Array[Match]->getIdentifierNamespace() & Decl::IDNS_Ordinary)) ++Match; } @@ -611,7 +610,7 @@ void DeclContext::insertImpl(NamedDecl *D) { StoredDeclsMap *Map = new StoredDeclsMap(16); LookupPtr.setPointer(Map); LookupPtr.setInt(LookupIsMap); - for (unsigned Idx = 0; Idx < LookupIsMap - 1; ++Idx) + for (unsigned Idx = 0; Idx != LookupIsMap - 1; ++Idx) insertImpl(Array[Idx]); delete [] Array; @@ -626,10 +625,9 @@ void DeclContext::insertImpl(NamedDecl *D) { if (Pos == Map->end()) { // Put this declaration into the appropriate slot. TwoNamedDecls Val; - Val.Decls[0] = 0; - Val.Decls[1] = 0; Val.Decls[IndexOfD] = D; - Pos = Map->insert(std::make_pair(D->getDeclName(),Val)).first; + Val.Decls[!IndexOfD] = 0; + Map->insert(std::make_pair(D->getDeclName(),Val)).first; } else { Pos->second.Decls[IndexOfD] = D; } |