]> granicus.if.org Git - clang/commitdiff
Split DeclarationName::getFETokenInfoAsVoid() into hot/cold paths and
authorDouglas Gregor <dgregor@apple.com>
Thu, 3 May 2012 23:18:44 +0000 (23:18 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 3 May 2012 23:18:44 +0000 (23:18 +0000)
(trivially) make DeclContext::lookup()'s const version inlinable. Good
for 0.3% on <rdar://problem/11004361>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156126 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
include/clang/AST/DeclarationName.h
lib/AST/DeclBase.cpp
lib/AST/DeclarationName.cpp

index 6382bf3694f28ed6749e20627ce5e62107f864cc..6aef681d75efc7f2b75e88ccbaf7e4340e23e2c3 100644 (file)
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_AST_DECLBASE_H
 
 #include "clang/AST/Attr.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/PointerUnion.h"
@@ -1411,7 +1412,9 @@ public:
   /// and enumerator names preceding any tag name. Note that this
   /// routine will not look into parent contexts.
   lookup_result lookup(DeclarationName Name);
-  lookup_const_result lookup(DeclarationName Name) const;
+  lookup_const_result lookup(DeclarationName Name) const {
+    return const_cast<DeclContext*>(this)->lookup(Name);
+  }
 
   /// \brief A simplistic name lookup mechanism that performs name lookup
   /// into this declaration context without consulting the external source.
index 6349d9c001fd5c114edfb14d2de7d12736c6f243..928a85c63bf91b93337c83cfaf371797a857ff60 100644 (file)
@@ -155,7 +155,13 @@ private:
 
   /// getFETokenInfoAsVoid - Retrieves the front end-specified pointer
   /// for this name as a void pointer.
-  void *getFETokenInfoAsVoid() const;
+  void *getFETokenInfoAsVoid() const {
+    if (getNameKind() == Identifier)
+      return getAsIdentifierInfo()->getFETokenInfo<void>();
+    return getFETokenInfoAsVoidSlow();
+  }
+
+  void *getFETokenInfoAsVoidSlow() const;
 
 public:
   /// DeclarationName - Used to create an empty selector.
index 47a0d25093d5f9eeaf0a49bd4f6b030607441ef1..a0191f95d0d5a41c9d2c590ef8737152b72473a8 100644 (file)
@@ -1192,11 +1192,6 @@ DeclContext::lookup(DeclarationName Name) {
   return I->second.getLookupResult();
 }
 
-DeclContext::lookup_const_result
-DeclContext::lookup(DeclarationName Name) const {
-  return const_cast<DeclContext*>(this)->lookup(Name);
-}
-
 void DeclContext::localUncachedLookup(DeclarationName Name, 
                                   llvm::SmallVectorImpl<NamedDecl *> &Results) {
   Results.clear();
index 64924ad95095581c86b1e1750d7fafa7997ba09f..324a2cbf856ef07fd96a710386cd2087c9983779 100644 (file)
@@ -323,10 +323,10 @@ Selector DeclarationName::getObjCSelector() const {
   return Selector();
 }
 
-void *DeclarationName::getFETokenInfoAsVoid() const {
+void *DeclarationName::getFETokenInfoAsVoidSlow() const {
   switch (getNameKind()) {
   case Identifier:
-    return getAsIdentifierInfo()->getFETokenInfo<void>();
+    llvm_unreachable("Handled by getFETokenInfoAsVoid()");
 
   case CXXConstructorName:
   case CXXDestructorName: