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

llvm-svn: 152332
This commit is contained in:
Daniel Dunbar 2012-03-08 20:29:02 +00:00
parent eb72532098
commit 47c32287d9
1 changed files with 7 additions and 3 deletions

View File

@ -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<NamedDecl*>(this)->getUnderlyingDecl();
}