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 | 7a4fad1b0b86fd2a6c770f010ef6148ead8fa4c7 (patch) | |
tree | 56e7314c6299ee31231bb620129f3222b8fd63e6 /clang/lib/AST/DeclBase.cpp | |
parent | 67ab296d5c029d3b410ffbc0d7a6e7cfcee17c3e (diff) | |
download | bcm5719-llvm-7a4fad1b0b86fd2a6c770f010ef6148ead8fa4c7.tar.gz bcm5719-llvm-7a4fad1b0b86fd2a6c770f010ef6148ead8fa4c7.zip |
Address some comments on the name lookup/DeclContext patch from Chris
llvm-svn: 60897
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 3e0f158cbe1..6ddb967a639 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/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; } |