]> granicus.if.org Git - clang/commitdiff
Remove the ASTContext parameter from Entity::getPrintableName().
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 21 Jul 2009 07:52:21 +0000 (07:52 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 21 Jul 2009 07:52:21 +0000 (07:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76546 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/CallGraph.h
include/clang/Index/Entity.h
lib/Analysis/CallGraph.cpp
lib/Index/Entity.cpp
lib/Index/EntityImpl.h

index 73072c410e1a349b89de4bff5741624456e931c3..9a05dad5790bc827a5294fa42373de46298c6c44 100644 (file)
@@ -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 {
index 8eb72e613599a7ffbb906ebd5fda23769c1b8ef1..490a648926cfa07e8c8724097b1d365712ddaa62 100644 (file)
@@ -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.
index 2530fc0ad74410fc8ace858893c6f407763d74ce..5605439ea94c3a8cd77934ba7f0e8c1b6fc692fa 100644 (file)
@@ -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';
     }
index cc45e25cc767a2cc4a4c40a6fa7034e7ceb939b6..c7924f65fc31dc680ea7fb163be26e46d4c72aeb 100644 (file)
@@ -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.
index 334dcfb4ecd9229a18decf274c400b1bb4ba238f..3f09f80fc1f62afcd9141fcdcc51e2dd003fa01b 100644 (file)
@@ -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);