diff options
author | Anders Carlsson <andersca@mac.com> | 2009-06-26 06:29:23 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-06-26 06:29:23 +0000 |
commit | e136e0e1b74760d7ec3ede38e0e739d5c52a3c0a (patch) | |
tree | 421b564f95af11583fc3a809e7a324ad0ec8c1bf /lib/AST/Decl.cpp | |
parent | 58badb7a655d021fc67bb7ed0af95d6ea0c63eb1 (diff) |
Add NamedDecl::getUnderlyingDecl that can see through UsingDecl and ObjCCompatibleAliasDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 4fbf2f6f48..5382ab52ab 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -297,6 +297,19 @@ bool NamedDecl::hasLinkage() const { return false; } +NamedDecl *NamedDecl::getUnderlyingDecl() { + NamedDecl *ND = this; + while (true) { + if (UsingDecl *UD = dyn_cast<UsingDecl>(ND)) + ND = UD->getTargetDecl(); + else if (ObjCCompatibleAliasDecl *AD + = dyn_cast<ObjCCompatibleAliasDecl>(ND)) + return AD->getClassInterface(); + else + return ND; + } +} + //===----------------------------------------------------------------------===// // VarDecl Implementation //===----------------------------------------------------------------------===// |