bool hasCallee() const { return begin() != end(); }
- const char *getName(ASTContext &Ctx) { return F->getName(Ctx); }
+ std::string getName(ASTContext &Ctx) { return F->getPrintableName(Ctx); }
};
class CallGraph {
/// \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 a printable name for debugging purpose.
+ std::string getPrintableName(ASTContext &Ctx);
/// \brief Get an Entity associated with the given Decl.
/// \returns Null if an Entity cannot refer to this Decl.
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I->second->hasCallee()) {
ASTContext &Ctx = *CallerCtx[I->second];
- os << "function: " << I->first->getName(Ctx) << " calls:\n";
+ os << "function: " << I->first->getPrintableName(Ctx).c_str()
+ << " calls:\n";
for (CallGraphNode::iterator CI = I->second->begin(),
CE = I->second->end(); CI != CE; ++CI) {
- os << " " << CI->second->getName(Ctx);
+ os << " " << CI->second->getName(Ctx).c_str();
}
os << '\n';
}
return 0; // Failed to find a decl using this Entity.
}
-const char *Entity::getName(ASTContext &Ctx) {
+std::string Entity::getPrintableName(ASTContext &Ctx) {
if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(getDecl(Ctx))) {
- return ND->getNameAsCString();
+ return ND->getNameAsString();
}
- return 0;
+ return std::string();
}
/// \brief Get an Entity associated with the given Decl.