diff options
Diffstat (limited to 'clang/lib/Index')
-rw-r--r-- | clang/lib/Index/Entity.cpp | 19 | ||||
-rw-r--r-- | clang/lib/Index/EntityImpl.h | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/Index/Entity.cpp b/clang/lib/Index/Entity.cpp index cc45e25cc76..c7924f65fc3 100644 --- a/clang/lib/Index/Entity.cpp +++ b/clang/lib/Index/Entity.cpp @@ -134,6 +134,10 @@ Entity EntityImpl::get(Decl *D, ProgramImpl &Prog) { return EntityGetter(Prog).Visit(D); } +std::string EntityImpl::getPrintableName() { + return std::string(Id->getKeyData(), Id->getKeyData() + Id->getKeyLength()); +} + //===----------------------------------------------------------------------===// // Entity Implementation //===----------------------------------------------------------------------===// @@ -152,11 +156,18 @@ Decl *Entity::getDecl(ASTContext &AST) { return Val.get<EntityImpl *>()->getDecl(AST); } -std::string Entity::getPrintableName(ASTContext &Ctx) { - if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(getDecl(Ctx))) { - return ND->getNameAsString(); +std::string Entity::getPrintableName() { + if (isInvalid()) + return "<< Invalid >>"; + + if (Decl *D = Val.dyn_cast<Decl *>()) { + if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) + return ND->getNameAsString(); + else + return std::string(); } - return std::string(); + + return Val.get<EntityImpl *>()->getPrintableName(); } /// \brief Get an Entity associated with the given Decl. diff --git a/clang/lib/Index/EntityImpl.h b/clang/lib/Index/EntityImpl.h index 334dcfb4ecd..3f09f80fc1f 100644 --- a/clang/lib/Index/EntityImpl.h +++ b/clang/lib/Index/EntityImpl.h @@ -44,6 +44,8 @@ public: /// \brief Get an Entity associated with the given Decl. /// \returns Null if an Entity cannot refer to this Decl. static Entity get(Decl *D, ProgramImpl &Prog); + + std::string getPrintableName(); void Profile(llvm::FoldingSetNodeID &ID) const { Profile(ID, Parent, Id, IdNS); |