/// \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);
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) {