[cfe-commits] r65028 - /cfe/trunk/lib/AST/DeclBase.cpp

Chris Lattner sabre at nondot.org
Wed Feb 18 23:00:44 PST 2009


Author: lattner
Date: Thu Feb 19 01:00:44 2009
New Revision: 65028

URL: http://llvm.org/viewvc/llvm-project?rev=65028&view=rev
Log:
use early exit to reduce indentation.


Modified:
    cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=65028&r1=65027&r2=65028&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Feb 19 01:00:44 2009
@@ -562,33 +562,34 @@
   // 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





More information about the cfe-commits mailing list