diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-19 07:00:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-19 07:00:44 +0000 |
commit | bd6c80037626a37ce3936a36d9ae287f475845b7 (patch) | |
tree | 2a329a3a8886ebe3feff900501e999a8dad4c75e /lib/AST/DeclBase.cpp | |
parent | d000c9ec6e1562e5e1eed2236a67fa9848bf8201 (diff) |
use early exit to reduce indentation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index db29a8e3c6..6b2a1ffc5e 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -562,33 +562,34 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) { // Insert this declaration into the map. StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(LookupPtr.getPointer()); StoredDeclsMap::iterator Pos = Map->find(D->getDeclName()); - if (Pos != Map->end()) { - if (MayBeRedeclaration) { - // Determine if this declaration is actually a redeclaration. - std::vector<NamedDecl *>::iterator Redecl - = std::find_if(Pos->second.begin(), Pos->second.end(), - std::bind1st(std::mem_fun(&NamedDecl::declarationReplaces), - D)); - if (Redecl != Pos->second.end()) { - *Redecl = D; - return; - } - } - - // Put this declaration into the appropriate slot. - if (D->getKind() == Decl::UsingDirective || - D->getIdentifierNamespace() == Decl::IDNS_Tag - || Pos->second.empty()) - Pos->second.push_back(D); - else if (Pos->second.back()->getIdentifierNamespace() == Decl::IDNS_Tag) { - NamedDecl *TagD = Pos->second.back(); - Pos->second.back() = D; - Pos->second.push_back(TagD); - } else - Pos->second.push_back(D); - } else { + if (Pos == Map->end()) { (*Map)[D->getDeclName()].push_back(D); + return; } + + if (MayBeRedeclaration) { + // Determine if this declaration is actually a redeclaration. + std::vector<NamedDecl *>::iterator Redecl + = std::find_if(Pos->second.begin(), Pos->second.end(), + std::bind1st(std::mem_fun(&NamedDecl::declarationReplaces), + D)); + if (Redecl != Pos->second.end()) { + *Redecl = D; + return; + } + } + + // Put this declaration into the appropriate slot. + if (D->getKind() == Decl::UsingDirective || + D->getIdentifierNamespace() == Decl::IDNS_Tag + || Pos->second.empty()) + Pos->second.push_back(D); + else if (Pos->second.back()->getIdentifierNamespace() == Decl::IDNS_Tag) { + NamedDecl *TagD = Pos->second.back(); + Pos->second.back() = D; + Pos->second.push_back(TagD); + } else + Pos->second.push_back(D); } /// Returns iterator range [First, Last) of UsingDirectiveDecls stored within |