From 12b1d137c249c511c2e966447ddfea26ba4fa5ef Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Wed, 15 Jul 2009 04:39:21 +0000 Subject: Add getName() method to Entity. llvm-svn: 75740 --- clang/lib/Index/Entity.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/Index/Entity.cpp') 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(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) { -- cgit v1.2.3