diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-15 04:39:21 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-15 04:39:21 +0000 |
commit | 53363b26d2bd5ae7890957d7acabfd407bd362b7 (patch) | |
tree | 4ca07efb7c6ae08e8681df4e49fcfc44dd565a67 | |
parent | 41fb0df17bafd699a063982292a90b6293788654 (diff) |
Add getName() method to Entity.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75740 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Index/Entity.h | 3 | ||||
-rw-r--r-- | lib/Index/Entity.cpp | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/include/clang/Index/Entity.h b/include/clang/Index/Entity.h index 8caaeb870f..e65412cbf5 100644 --- a/include/clang/Index/Entity.h +++ b/include/clang/Index/Entity.h @@ -43,6 +43,9 @@ public: /// \brief Find the Decl that can be referred to by this entity. Decl *getDecl(ASTContext &AST); + /// \brief Get the Decl's name. + const char *getName(ASTContext &Ctx); + /// \brief Get an Entity associated with the given Decl. /// \returns Null if an Entity cannot refer to this Decl. static Entity *get(Decl *D, Program &Prog); diff --git a/lib/Index/Entity.cpp b/lib/Index/Entity.cpp index 2620f88a95..520d189826 100644 --- a/lib/Index/Entity.cpp +++ b/lib/Index/Entity.cpp @@ -123,6 +123,13 @@ Decl *Entity::getDecl(ASTContext &AST) { return 0; // Failed to find a decl using this Entity. } +const char *Entity::getName(ASTContext &Ctx) { + if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(getDecl(Ctx))) { + return ND->getNameAsCString(); + } + return 0; +} + /// \brief Get an Entity associated with the given Decl. /// \returns Null if an Entity cannot refer to this Decl. Entity *Entity::get(Decl *D, Program &Prog) { |