partially inline getAttrs() to speed up PR3810 (and lots of
other code presumably) by 4.3%


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67430 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 86d96a5..abf5404 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -180,7 +180,10 @@
 
   bool hasAttrs() const { return HasAttrs; }
   void addAttr(Attr *attr);
-  const Attr *getAttrs() const;
+  const Attr *getAttrs() const {
+    if (!HasAttrs) return 0;  // common case, no attributes.
+    return getAttrsImpl();    // Uncommon case, out of line hash lookup.
+  }
   void swapAttrs(Decl *D);
   void invalidateAttrs();
 
@@ -188,7 +191,6 @@
     for (const Attr *attr = getAttrs(); attr; attr = attr->getNext())
       if (const T *V = dyn_cast<T>(attr))
         return V;
-
     return 0;
   }
     
@@ -326,6 +328,9 @@
     // FIXME: This will eventually be a pure virtual function.
     assert (false && "Not implemented.");
   }
+private:
+  const Attr *getAttrsImpl() const;
+
 };
 
 /// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 1e7ef54..812c362 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -171,10 +171,8 @@
   }
 }
 
-const Attr *Decl::getAttrs() const {
-  if (!HasAttrs)
-    return 0;
-  
+const Attr *Decl::getAttrsImpl() const {
+  assert(HasAttrs && "getAttrs() should verify this!"); 
   return (*DeclAttrs)[this];
 }