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 | dfd6b3d19084bbd16e1660e9500fde2838ccd011 (patch) | |
tree | 034a5a9842a4848d6cd71d91bccb5b375c3af13a /clang/lib | |
parent | bd4dc67bd210150f71de66b513d0e290da4e291d (diff) | |
download | bcm5719-llvm-dfd6b3d19084bbd16e1660e9500fde2838ccd011.tar.gz bcm5719-llvm-dfd6b3d19084bbd16e1660e9500fde2838ccd011.zip |
use early exit to reduce indentation.
llvm-svn: 65028
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index db29a8e3c63..6b2a1ffc5e7 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/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 |