5#include <GraphDotOutput.h> 
    8#include "Rose/Diagnostics.h" 
   14#include <boost/unordered_map.hpp> 
   16#include "ClassHierarchyGraph.h" 
   25namespace CallTargetSet
 
   39  std::vector<SgFunctionDeclaration*> solveFunctionPointerCall ( 
SgPointerDerefExp *);
 
   58  Rose_STL_Container<SgFunctionDeclaration*> solveFunctionPointerCallsFunctional(
SgNode* node, 
SgFunctionType* functionType );
 
   62  std::vector<SgFunctionDeclaration*> solveMemberFunctionCall (
 
   69  ROSE_DLL_API 
void getPropertiesForExpression(
SgExpression* exp,
 
   71                                               Rose_STL_Container<SgFunctionDeclaration*>& propList,
 
   72                                               bool includePureVirtualFunc = 
false);
 
   80                                    Rose_STL_Container<SgFunctionDefinition*>& calleeList);
 
   86                                    Rose_STL_Container<SgFunctionDeclaration*>& calleeList,
 
   87                                    bool includePureVirtualFunc = 
false);
 
   94                                   Rose_STL_Container<SgExpression*>& exps);
 
  125  using result_type = bool;
 
 
  133  using result_type = bool;
 
 
  140    using GraphNodes = boost::unordered_map<SgFunctionDeclaration*, SgGraphNode*> ;
 
  145    template<
typename Predicate>
 
  146      void buildCallGraph(Predicate pred);
 
  152    boost::unordered_map<SgFunctionDeclaration*, SgGraphNode*>& getGraphNodesMapping(){ 
return graphNodes; }
 
  163    GraphNodes graphNodes;
 
 
  173  using result_type = Rose_STL_Container<SgNode*>;
 
  174  result_type operator()(
SgNode* node);
 
 
  177template<
typename Predicate>
 
  186        isSelected(Predicate &pred): pred(pred) {}
 
  187        bool operator()(
SgNode *node) {
 
  193            if(isSgTemplateFunctionDeclaration(f)||isSgTemplateMemberFunctionDeclaration(f)) {
 
  194              std::cerr<<
"Error: CallGraphBuilder: call referring to node "<<f->
class_name()<<
" :: function-name:"<<f->get_qualified_name()<<std::endl;
 
  204    std::vector<FunctionData> callGraphData;
 
  207    VariantVector vv(V_SgFunctionDeclaration);
 
  209    for(
SgNode *node : NodeQuery::queryMemoryPool(defFunc, &vv)) {
 
  213        printf (
"In buildCallGraph(): loop over functions from memory pool: fdecl  = %p = %s name = %s \n",fdecl,fdecl->
class_name().c_str(),fdecl->get_name().str());
 
  214        printf (
"In buildCallGraph(): loop over functions from memory pool: unique = %p = %s name = %s \n",unique,unique->
class_name().c_str(),unique->get_name().str());
 
  219            printf (
"Collect function calls in unique function: unique = %p \n",unique);
 
  222            callGraphData.push_back(fdata);
 
  223            std::string functionName = unique->get_qualified_name().getString();
 
  225            graphNode->set_SgNode(unique);
 
  226            graphNodes[unique] = graphNode;
 
  228            mprintf(
"Added function %s %p\n", functionName.c_str(), unique);
 
  233            printf (
"Function not selected for processing: unique = %p \n",unique);
 
  234            printf (
"   --- isSelected(pred)(unique) = %s \n",isSelected(pred)(unique) ? 
"true" : 
"false");
 
  235            printf (
"   --- graphNodes.find(unique)==graphNodes.end() = %s \n",graphNodes.find(unique)==graphNodes.end() ? 
"true" : 
"false");
 
  243        std::string curFuncName = curFuncDecl->get_qualified_name().getString();
 
  245        ROSE_ASSERT(srcNode != NULL);
 
  246        std::vector<SgFunctionDeclaration*> & callees = currentFunction.functionList;
 
  248            if (isSelected(pred)(callee)) {
 
  250                ROSE_ASSERT(dstNode != NULL);
 
  251                if (graph->checkIfDirectedGraphEdgeExists(srcNode, dstNode) == 
false)
 
 
SgIncidenceDirectedGraph * getGraph()
Grab the call graph built.
SgGraphNode * hasGraphNodeFor(SgFunctionDeclaration *fdecl) const
Retrieve the node matching a function declaration using firstNondefiningDeclaration (does not work ac...
void buildCallGraph()
Default builder filtering nothing in the call graph.
SgGraphNode * getGraphNodeFor(SgFunctionDeclaration *fdecl) const
Retrieve the node matching a function declaration (using mangled name to resolve across translation u...
std::vector< SgFunctionDeclaration * > functionList
All the callees of this function.
This class represents the call of a class constructor to initialize a variable. For example "Foo foo;...
SgDeclarationStatement * get_firstNondefiningDeclaration() const
This is an access function for the SgDeclarationStatement::p_firstNondefiningDeclaration data member ...
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
This class represents the concept of a function declaration statement.
virtual std::string class_name() const override
returns a string representing the class name
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
This class represents a type for all functions.
SgGraphNode * addNode(const std::string &name="", SgNode *sg_node=NULL)
Support for adding SgGraphNode to SgGraph.
SgDirectedGraphEdge * addDirectedEdge(SgGraphNode *a, SgGraphNode *b, const std::string &name="")
Support for adding SgGraphEdge to SgGraph.
This class represents the concept of a member function declaration statement.
This class represents the base class for all IR nodes within Sage III.
This class represents a source project, with a list of SgFile objects and global information about th...
ROSE_DLL_API Sawyer::Message::Facility mlog
Diagnostic facility for the ROSE library as a whole.
A function object to filter out builtin functions in a call graph (only non-builtin functions will be...
A function object to be used as a predicate to filter out functions in a call graph: it does not filt...