Browse Source

[AST] Clean up NamedDecl::getUnderlyingDecl() change a bit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152332 91177308-0d34-0410-b5e6-96231b3b80d8
Daniel Dunbar 13 years ago
parent
commit
e13edcb296
1 changed files with 7 additions and 3 deletions
  1. 7 3
      include/clang/AST/Decl.h

+ 7 - 3
include/clang/AST/Decl.h

@@ -106,6 +106,9 @@ class NamedDecl : public Decl {
   /// constructor, Objective-C selector, etc.)
   /// constructor, Objective-C selector, etc.)
   DeclarationName Name;
   DeclarationName Name;
 
 
+private:
+  NamedDecl *getUnderlyingDeclImpl();
+
 protected:
 protected:
   NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
   NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
     : Decl(DK, DC, L), Name(N) { }
     : Decl(DK, DC, L), Name(N) { }
@@ -324,12 +327,13 @@ public:
   /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
   /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
   /// the underlying named decl.
   /// the underlying named decl.
   NamedDecl *getUnderlyingDecl() {
   NamedDecl *getUnderlyingDecl() {
-    if (!(this->getKind() == UsingShadow) &&
-        !(this->getKind() == ObjCCompatibleAlias))
+    // Fast-path the common case.
+    if (this->getKind() != UsingShadow &&
+        this->getKind() != ObjCCompatibleAlias)
       return this;
       return this;
+
     return getUnderlyingDeclImpl();
     return getUnderlyingDeclImpl();
   }
   }
-  NamedDecl *getUnderlyingDeclImpl();
   const NamedDecl *getUnderlyingDecl() const {
   const NamedDecl *getUnderlyingDecl() const {
     return const_cast<NamedDecl*>(this)->getUnderlyingDecl();
     return const_cast<NamedDecl*>(this)->getUnderlyingDecl();
   }
   }