From: Douglas Gregor Date: Thu, 3 May 2012 23:18:44 +0000 (+0000) Subject: Split DeclarationName::getFETokenInfoAsVoid() into hot/cold paths and X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=514d3b6b93c83c0841d2f9dd7af8ecc2877fe921;p=clang Split DeclarationName::getFETokenInfoAsVoid() into hot/cold paths and (trivially) make DeclContext::lookup()'s const version inlinable. Good for 0.3% on . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156126 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 6382bf3694..6aef681d75 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -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(this)->lookup(Name); + } /// \brief A simplistic name lookup mechanism that performs name lookup /// into this declaration context without consulting the external source. diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index 6349d9c001..928a85c63b 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -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(); + return getFETokenInfoAsVoidSlow(); + } + + void *getFETokenInfoAsVoidSlow() const; public: /// DeclarationName - Used to create an empty selector. diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 47a0d25093..a0191f95d0 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -1192,11 +1192,6 @@ DeclContext::lookup(DeclarationName Name) { return I->second.getLookupResult(); } -DeclContext::lookup_const_result -DeclContext::lookup(DeclarationName Name) const { - return const_cast(this)->lookup(Name); -} - void DeclContext::localUncachedLookup(DeclarationName Name, llvm::SmallVectorImpl &Results) { Results.clear(); diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp index 64924ad950..324a2cbf85 100644 --- a/lib/AST/DeclarationName.cpp +++ b/lib/AST/DeclarationName.cpp @@ -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(); + llvm_unreachable("Handled by getFETokenInfoAsVoid()"); case CXXConstructorName: case CXXDestructorName: