From 47c32287d9c97bcd87cbf209e4a91f99025b2fb7 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 8 Mar 2012 20:29:02 +0000 Subject: [PATCH] [AST] Clean up NamedDecl::getUnderlyingDecl() change a bit. llvm-svn: 152332 --- clang/include/clang/AST/Decl.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 7c042c181612..27a9d75f9212 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -106,6 +106,9 @@ class NamedDecl : public Decl { /// constructor, Objective-C selector, etc.) DeclarationName Name; +private: + NamedDecl *getUnderlyingDeclImpl(); + protected: NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N) : Decl(DK, DC, L), Name(N) { } @@ -324,12 +327,13 @@ public: /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for /// the underlying named decl. NamedDecl *getUnderlyingDecl() { - if (!(this->getKind() == UsingShadow) && - !(this->getKind() == ObjCCompatibleAlias)) + // Fast-path the common case. + if (this->getKind() != UsingShadow && + this->getKind() != ObjCCompatibleAlias) return this; + return getUnderlyingDeclImpl(); } - NamedDecl *getUnderlyingDeclImpl(); const NamedDecl *getUnderlyingDecl() const { return const_cast(this)->getUnderlyingDecl(); }