36 using namespace SVFUtil;
42 for (CHEdge::CHEdgeSetTy::const_iterator it = src->
getOutEdges().begin(),
45 CHNode *node = (*it)->getDstNode();
47 if (node == dst && edgeType == et)
60 for (
unsigned i = 1; i < arg_size; i++)
63 auto fn_arg = fn->
getArg(i);
64 if (cs_arg->getType() != fn_arg->getType())
76 CallNodeToVTableSetMap::const_iterator it = callNodeToCHAVtblsMap.find(cs);
77 return it != callNodeToCHAVtblsMap.end();
81 CallNodeToVFunSetMap::const_iterator it = callNodeToCHAVFnsMap.find(cs);
82 return it != callNodeToCHAVFnsMap.end();
86 CallNodeToVTableSetMap::const_iterator it = callNodeToCHAVtblsMap.find(cs);
87 assert(it != callNodeToCHAVtblsMap.end() &&
"cs does not have vtabls based on CHA.");
92 CallNodeToVFunSetMap::const_iterator it = callNodeToCHAVFnsMap.find(cs);
93 assert(it != callNodeToCHAVFnsMap.end() &&
"cs does not have vfns based on CHA.");
100 CHNode *srcNode = getNode(className);
101 CHNode *dstNode = getNode(baseClassName);
102 assert(srcNode && dstNode &&
"node not found?");
104 if (!
hasEdge(srcNode, dstNode, edgeType))
114 auto chNode = classNameToNodeMap.find(
name);
115 if (chNode != classNameToNodeMap.end())
return chNode->second;
133 if (
child ==
nullptr)
136 child->getVirtualFunctions(idx, vfns);
137 for (CHNode::FuncVector::const_iterator fit = vfns.begin(),
138 feit = vfns.end(); fit != feit; ++fit)
150 string calleeName = callee->
getName();
162 size_t suffix_pos = calleeName.rfind(suffix);
163 if (suffix_pos != string::npos)
164 calleeName.erase(suffix_pos, suffix.size());
170 if (funName.size() == 0)
172 virtualFunctions.insert(callee);
174 else if (funName[0] ==
'~')
186 if (calleeName[0] ==
'~')
188 virtualFunctions.insert(callee);
197 if (funName.compare(calleeName) == 0)
199 virtualFunctions.insert(callee);
210 for (vector<FuncVector>::const_iterator it = virtualFunctionVectors.begin(),
211 eit = virtualFunctionVectors.end(); it != eit; ++it)
213 if ((*it).size() > idx)
214 virtualFunctions.push_back((*it)[idx]);
223 const CHNode *node = it->second;
225 for (CHEdge::CHEdgeSetTy::const_iterator it = node->
OutEdgeBegin();
229 outs() << (*it)->getDstNode()->getName() <<
" --inheritance--> "
230 << (*it)->getSrcNode()->getName() <<
"\n";
232 outs() << (*it)->getSrcNode()->getName() <<
" --instance--> "
233 << (*it)->getDstNode()->getName() <<
"\n";
272 return "Class Hierarchy Graph";
290 template<
class EdgeIter>
294 CHEdge* edge = *(EI.getCurrent());
295 assert(edge &&
"No edge found!!");
298 return "style=solid";
302 return "style=dashed";
static bool hasEdge(const CHNode *src, const CHNode *dst, CHEdge::CHEDGETYPE et)
static bool checkArgTypes(const CallICFGNode *cs, const SVFFunction *fn)
CHEDGETYPE getEdgeType() const
void dump(const std::string &filename)
bool csHasVtblsBasedonCHA(const CallICFGNode *cs) override
void addEdge(const std::string className, const std::string baseClassName, CHEdge::CHEDGETYPE edgeType)
bool csHasVFnsBasedonCHA(const CallICFGNode *cs) override
const VFunSet & getCSVFsBasedonCHA(const CallICFGNode *cs) override
const VTableSet & getCSVtblsBasedonCHA(const CallICFGNode *cs) override
void getVFnsFromVtbls(const CallICFGNode *cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override
CHNode * getNode(const std::string name) const
void getVirtualFunctions(u32_t idx, FuncVector &virtualFunctions) const
bool isPureAbstract() const
std::vector< const SVFFunction * > FuncVector
std::string getName() const
const std::string & getFunNameOfVirtualCall() const
s32_t getFunIdxInVtable() const
const SVFVar * getArgument(u32_t ArgNo) const
Parameter operations.
IDToNodeMapTy::const_iterator const_iterator
const GEdgeSetTy & getOutEdges() const
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
iterator OutEdgeBegin()
iterators
bool addOutgoingEdge(EdgeType *outEdge)
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
const SVFArgument * getArg(u32_t idx) const
const std::string & getName() const
std::ostream & outs()
Overwrite llvm::outs()
Set< const SVFGlobalValue * > VTableSet
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
Set< const SVFFunction * > VFunSet
DOTGraphTraits(bool isSimple=false)
static std::string getNodeLabel(CHNode *node, CHGraph *)
Return function name;.
static std::string getGraphName(CHGraph *)
Return name of the graph.
static std::string getNodeAttributes(CHNode *node, CHGraph *)
static std::string getEdgeAttributes(CHNode *, EdgeIter EI, CHGraph *)