summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Index/Entity.h3
-rw-r--r--clang/lib/Index/Entity.cpp7
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/include/clang/Index/Entity.h b/clang/include/clang/Index/Entity.h
index 8caaeb870fc..e65412cbf5e 100644
--- a/clang/include/clang/Index/Entity.h
+++ b/clang/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/clang/lib/Index/Entity.cpp b/clang/lib/Index/Entity.cpp
index 2620f88a958..520d189826a 100644
--- a/clang/lib/Index/Entity.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud