From 91942501b6f71a41d3a09bedec19be479832c718 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 20 Feb 2009 00:55:03 +0000 Subject: [PATCH] slight code simplifications. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65094 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclBase.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index d244637af7..8b04053846 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -280,13 +280,10 @@ typedef llvm::DenseMap > DeclContext::~DeclContext() { unsigned Size = LookupPtr.getInt(); - if (Size == LookupIsMap) { - StoredDeclsMap *Map = static_cast(LookupPtr.getPointer()); - delete Map; - } else { - NamedDecl **Array = static_cast(LookupPtr.getPointer()); - delete [] Array; - } + if (Size == LookupIsMap) + delete static_cast(LookupPtr.getPointer()); + else + delete [] static_cast(LookupPtr.getPointer()); } void DeclContext::DestroyDecls(ASTContext &C) { @@ -412,10 +409,11 @@ DeclContext::lookup(DeclarationName Name) { if (isLookupMap()) { StoredDeclsMap *Map = static_cast(LookupPtr.getPointer()); StoredDeclsMap::iterator Pos = Map->find(Name); - if (Pos != Map->end()) - return lookup_result(&Pos->second.front(), - &Pos->second.front() + Pos->second.size()); - return lookup_result(0, 0); + if (Pos == Map->end()) + return lookup_result(0, 0); + + return lookup_result(&Pos->second.front(), + &Pos->second.front() + Pos->second.size()); } // We have a small array. Look into it. @@ -566,7 +564,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) { DeclNameEntries.push_back(D); return; } - + if (MayBeRedeclaration) { // Determine if this declaration is actually a redeclaration. std::vector::iterator Redecl @@ -578,11 +576,10 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) { return; } } - + // Put this declaration into the appropriate slot. if (isa(D) || - D->getIdentifierNamespace() == Decl::IDNS_Tag || - DeclNameEntries.empty()) + D->getIdentifierNamespace() == Decl::IDNS_Tag) DeclNameEntries.push_back(D); else if (DeclNameEntries.back()->getIdentifierNamespace() == Decl::IDNS_Tag) { NamedDecl *TagD = DeclNameEntries.back(); -- 2.40.0