From: Argyrios Kyrtzidis Date: Tue, 21 Jul 2009 07:52:21 +0000 (+0000) Subject: Remove the ASTContext parameter from Entity::getPrintableName(). X-Git-Tag: llvmorg-2.6.0~2808 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8274ad5281d02515a66087f93d2d7ec0c7b516e2;p=platform%2Fupstream%2Fllvm.git Remove the ASTContext parameter from Entity::getPrintableName(). llvm-svn: 76546 --- diff --git a/clang/include/clang/Analysis/CallGraph.h b/clang/include/clang/Analysis/CallGraph.h index 73072c410e1a..9a05dad5790b 100644 --- a/clang/include/clang/Analysis/CallGraph.h +++ b/clang/include/clang/Analysis/CallGraph.h @@ -45,7 +45,7 @@ public: bool hasCallee() const { return begin() != end(); } - std::string getName(ASTContext &Ctx) { return F.getPrintableName(Ctx); } + std::string getName() { return F.getPrintableName(); } }; class CallGraph { diff --git a/clang/include/clang/Index/Entity.h b/clang/include/clang/Index/Entity.h index 8eb72e613599..490a648926cf 100644 --- a/clang/include/clang/Index/Entity.h +++ b/clang/include/clang/Index/Entity.h @@ -58,7 +58,7 @@ public: Decl *getDecl(ASTContext &AST); /// \brief Get a printable name for debugging purpose. - std::string getPrintableName(ASTContext &Ctx); + std::string getPrintableName(); /// \brief Get an Entity associated with the given Decl. /// \returns Null if an Entity cannot refer to this Decl. diff --git a/clang/lib/Analysis/CallGraph.cpp b/clang/lib/Analysis/CallGraph.cpp index 2530fc0ad744..5605439ea94c 100644 --- a/clang/lib/Analysis/CallGraph.cpp +++ b/clang/lib/Analysis/CallGraph.cpp @@ -97,12 +97,11 @@ CallGraphNode *CallGraph::getOrInsertFunction(Entity F) { void CallGraph::print(llvm::raw_ostream &os) { for (iterator I = begin(), E = end(); I != E; ++I) { if (I->second->hasCallee()) { - ASTContext &Ctx = *CallerCtx[I->second]; - os << "function: " << I->first.getPrintableName(Ctx).c_str() + os << "function: " << I->first.getPrintableName() << " calls:\n"; for (CallGraphNode::iterator CI = I->second->begin(), CE = I->second->end(); CI != CE; ++CI) { - os << " " << CI->second->getName(Ctx).c_str(); + os << " " << CI->second->getName().c_str(); } os << '\n'; } diff --git a/clang/lib/Index/Entity.cpp b/clang/lib/Index/Entity.cpp index cc45e25cc767..c7924f65fc31 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()->getDecl(AST); } -std::string Entity::getPrintableName(ASTContext &Ctx) { - if (const NamedDecl *ND = dyn_cast_or_null(getDecl(Ctx))) { - return ND->getNameAsString(); +std::string Entity::getPrintableName() { + if (isInvalid()) + return "<< Invalid >>"; + + if (Decl *D = Val.dyn_cast()) { + if (NamedDecl *ND = dyn_cast(D)) + return ND->getNameAsString(); + else + return std::string(); } - return std::string(); + + return Val.get()->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 334dcfb4ecd9..3f09f80fc1f6 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);