[cfe-commits] r76546 - in /cfe/trunk: include/clang/Analysis/CallGraph.h include/clang/Index/Entity.h lib/Analysis/CallGraph.cpp lib/Index/Entity.cpp lib/Index/EntityImpl.h

Argiris Kirtzidis akyrtzi at gmail.com
Tue Jul 21 00:52:21 PDT 2009


Author: akirtzidis
Date: Tue Jul 21 02:52:21 2009
New Revision: 76546

URL: http://llvm.org/viewvc/llvm-project?rev=76546&view=rev
Log:
Remove the ASTContext parameter from Entity::getPrintableName().

Modified:
    cfe/trunk/include/clang/Analysis/CallGraph.h
    cfe/trunk/include/clang/Index/Entity.h
    cfe/trunk/lib/Analysis/CallGraph.cpp
    cfe/trunk/lib/Index/Entity.cpp
    cfe/trunk/lib/Index/EntityImpl.h

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=76546&r1=76545&r2=76546&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Tue Jul 21 02:52:21 2009
@@ -45,7 +45,7 @@
 
   bool hasCallee() const { return begin() != end(); }
 
-  std::string getName(ASTContext &Ctx) { return F.getPrintableName(Ctx); }
+  std::string getName() { return F.getPrintableName(); }
 };
 
 class CallGraph {

Modified: cfe/trunk/include/clang/Index/Entity.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/Entity.h?rev=76546&r1=76545&r2=76546&view=diff

==============================================================================
--- cfe/trunk/include/clang/Index/Entity.h (original)
+++ cfe/trunk/include/clang/Index/Entity.h Tue Jul 21 02:52:21 2009
@@ -58,7 +58,7 @@
   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.

Modified: cfe/trunk/lib/Analysis/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallGraph.cpp?rev=76546&r1=76545&r2=76546&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CallGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/CallGraph.cpp Tue Jul 21 02:52:21 2009
@@ -97,12 +97,11 @@
 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';
     }

Modified: cfe/trunk/lib/Index/Entity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/Entity.cpp?rev=76546&r1=76545&r2=76546&view=diff

==============================================================================
--- cfe/trunk/lib/Index/Entity.cpp (original)
+++ cfe/trunk/lib/Index/Entity.cpp Tue Jul 21 02:52:21 2009
@@ -134,6 +134,10 @@
   return EntityGetter(Prog).Visit(D);
 }
 
+std::string EntityImpl::getPrintableName() {
+  return std::string(Id->getKeyData(), Id->getKeyData() + Id->getKeyLength());
+}
+
 //===----------------------------------------------------------------------===//
 // Entity Implementation
 //===----------------------------------------------------------------------===//
@@ -152,11 +156,18 @@
   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.

Modified: cfe/trunk/lib/Index/EntityImpl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/EntityImpl.h?rev=76546&r1=76545&r2=76546&view=diff

==============================================================================
--- cfe/trunk/lib/Index/EntityImpl.h (original)
+++ cfe/trunk/lib/Index/EntityImpl.h Tue Jul 21 02:52:21 2009
@@ -44,6 +44,8 @@
   /// \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);





More information about the cfe-commits mailing list