37using namespace SVFUtil;
125 rawstr <<
it->second->getId() <<
", ";
142 rawstr <<
"BinaryOPVFGNode ID: " <<
getId() <<
" ";
146 rawstr <<
it->second->getId() <<
", ";
167 rawstr <<
it->second->getId() <<
", ";
218 rawstr <<
it->second->getId() <<
", ";
229 rawstr <<
"IntraPHIVFGNode ID: " <<
getId() <<
" ";
233 rawstr <<
it->second->getId() <<
", ";
260 rawstr <<
"ArgumentVFGNode ID: " <<
getId() <<
" ";
276 rawstr <<
"ActualParmVFGNode ID: " <<
getId() <<
" ";
293 rawstr <<
"FormalParmVFGNode ID: " <<
getId() <<
" ";
310 rawstr <<
"ActualRetVFGNode ID: " <<
getId() <<
" ";
328 rawstr <<
"FormalRetVFGNode ID: " <<
getId() <<
" ";
457 for (SVFStmt::SVFStmtSetTy::iterator
iter = addrs.begin(),
eiter =
465 for (SVFStmt::SVFStmtSetTy::iterator
iter =
copys.begin(),
eiter =
475 for (SVFStmt::SVFStmtSetTy::iterator
iter =
ngeps.begin(),
eiter =
483 for (SVFStmt::SVFStmtSetTy::iterator
iter =
loads.begin(),
eiter =
498 for (SVFStmt::SVFStmtSetTy::iterator
iter =
forks.begin(),
eiter =
546 if (
func->isVarArg())
571 const RetPE* retPE = SVFUtil::cast<RetPE>(*
cit);
573 retPEs.insert(retPE);
583 for (SVFStmt::SVFStmtSetTy::iterator
iter =
phis.begin(),
eiter =
619 for (SVFStmt::SVFStmtSetTy::iterator
iter =
brs.begin(),
eiter =
628 for (SVFStmt::SVFStmtSetTy::iterator
iter =
cmps.begin(),
eiter =
648 assert(
edge->isDirectVFGEdge() &&
"this should be a direct value flow edge!");
673 assert(
edge->isCallDirectVFGEdge() &&
"this should be a direct value flow edge!");
693 assert(
edge->isRetDirectVFGEdge() &&
"this should be a direct value flow edge!");
718 if(SVFUtil::isa<AddrVFGNode>(
stmtNode))
721 if (
stmtNode->getSrcNode()->isConstDataOrAggDataButNotNullPtr() ==
false)
727 for (
const auto &
varType:
gepStmt->getOffsetVarAndGepTypePairVec())
735 if(SVFUtil::isa<StoreVFGNode>(
stmtNode) && (
stmtNode->getDstNode()->isConstDataOrAggDataButNotNullPtr() ==
false))
745 if (
it->second->isConstDataOrAggDataButNotNullPtr() ==
false)
753 if (
it->second->isConstDataOrAggDataButNotNullPtr() ==
false)
761 if (
it->second->isConstDataOrAggDataButNotNullPtr() ==
false)
769 if (
it->second->isConstDataOrAggDataButNotNullPtr() ==
false)
781 if (
actualParm->getParam()->isConstDataOrAggDataButNotNullPtr() ==
false)
788 for(
u32_t i = 0;
i < callPE->getOpVarNum();
i++)
808 const CallICFGNode* callBlockNode = (*it)->getCallSite();
821 for (SVFStmt::SVFStmtSetTy::iterator
iter =
forks.begin(),
eiter =
838 for (SVFStmt::SVFStmtSetTy::iterator
iter =
joins.begin(),
eiter =
931 PointerAnalysis::CallEdgeMap::const_iterator
iter = pta->
getIndCallMap().begin();
936 assert(
newcs->isIndirectCall() &&
"this is not an indirect call?");
1005 return addr->getDstNode();
1006 else if(
const CopyVFGNode*
copy = SVFUtil::dyn_cast<CopyVFGNode>(node))
1007 return copy->getDstNode();
1008 else if(
const GepVFGNode*
gep = SVFUtil::dyn_cast<GepVFGNode>(node))
1009 return gep->getDstNode();
1010 else if(
const LoadVFGNode* load = SVFUtil::dyn_cast<LoadVFGNode>(node))
1011 return load->getDstNode();
1012 else if(
const PHIVFGNode*
phi = SVFUtil::dyn_cast<PHIVFGNode>(node))
1013 return phi->getRes();
1014 else if(
const CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
1015 return cmp->getRes();
1017 return bop->getRes();
1019 return uop->getRes();
1020 else if(
const ActualParmVFGNode* ap = SVFUtil::dyn_cast<ActualParmVFGNode>(node))
1021 return ap->getParam();
1023 return fp->getParam();
1025 return ar->getRev();
1027 return fr->getRet();
1031 assert(
false &&
"unexpected node kind!");
1042 return fp->getFun();
1046 if(
phi->isFormalParmPHI())
1047 return phi->getFun();
1102 return getSimpleNodeLabel(node, graph);
1104 return getCompleteNodeLabel(node, graph);
1126 rawstr << ap->toString();
1136 else if(SVFUtil::isa<NullPtrVFGNode>(node))
1148 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
1157 assert(
false &&
"what else kinds of nodes do we have??");
1180 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
1184 else if(
PHIVFGNode*
phi = SVFUtil::dyn_cast<PHIVFGNode>(node))
1194 rawstr << ap->toString();
1208 else if (
MRSVFGNode* mr = SVFUtil::dyn_cast<MRSVFGNode>(node))
1210 rawstr << mr->toString();
1217 assert(
false &&
"what else kinds of nodes do we have??");
1230 if (SVFUtil::isa<AddrStmt>(
edge))
1234 else if (SVFUtil::isa<CopyStmt>(
edge))
1238 else if (SVFUtil::isa<RetPE>(
edge))
1240 rawstr <<
"color=black,style=dotted";
1242 else if (SVFUtil::isa<GepStmt>(
edge))
1244 rawstr <<
"color=purple";
1246 else if (SVFUtil::isa<StoreStmt>(
edge))
1250 else if (SVFUtil::isa<LoadStmt>(
edge))
1256 assert(0 &&
"No such kind edge!!");
1260 else if (SVFUtil::isa<CmpVFGNode>(node))
1264 else if (SVFUtil::isa<BinaryOPVFGNode>(node))
1268 else if (SVFUtil::isa<UnaryOPVFGNode>(node))
1272 else if(SVFUtil::isa<PHIVFGNode>(node))
1276 else if(SVFUtil::isa<NullPtrVFGNode>(node))
1280 else if(SVFUtil::isa<FormalParmVFGNode>(node))
1282 rawstr <<
"color=yellow,penwidth=2";
1284 else if(SVFUtil::isa<ActualParmVFGNode>(node))
1286 rawstr <<
"color=yellow,penwidth=2";
1288 else if (SVFUtil::isa<ActualRetVFGNode>(node))
1290 rawstr <<
"color=yellow,penwidth=2";
1292 else if (SVFUtil::isa<FormalRetVFGNode>(node))
1294 rawstr <<
"color=yellow,penwidth=2";
1296 else if (SVFUtil::isa<MRSVFGNode>(node))
1298 rawstr <<
"color=orange,penwidth=2";
1300 else if (SVFUtil::isa<BranchVFGNode>(node))
1302 rawstr <<
"color=gold,penwidth=2";
1305 assert(
false &&
"no such kind of node!!");
1312 template<
class EdgeIter>
1317 if (SVFUtil::isa<DirectSVFGEdge>(
edge))
1319 if (SVFUtil::isa<CallDirSVFGEdge>(
edge))
1320 return "style=solid,color=red";
1321 else if (SVFUtil::isa<RetDirSVFGEdge>(
edge))
1322 return "style=solid,color=blue";
1324 return "style=solid";
1326 else if (SVFUtil::isa<IndirectSVFGEdge>(
edge))
1328 if (SVFUtil::isa<CallIndSVFGEdge>(
edge))
1329 return "style=dashed,color=red";
1330 else if (SVFUtil::isa<RetIndSVFGEdge>(
edge))
1331 return "style=dashed,color=blue";
1333 return "style=dashed";
1337 assert(
false &&
"what else edge we have?");
1342 template<
class EdgeIter>
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
const std::string toString() const override
const ValVar * getParam() const
Return parameter.
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const CallICFGNode * getCallSite() const
Return callsite.
const CallICFGNode * getCallSite() const
Return callsite.
const std::string toString() const override
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const ValVar * getRev() const
Receive parameter at callsite.
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const std::string toString() const override
const std::string toString() const override
const SVFVar * getValue() const override
Return the corresponding LLVM value, if possible, nullptr otherwise.
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const ValVar * getRes() const
const SVFVar * getValue() const override
Return the corresponding LLVM value, if possible, nullptr otherwise.
const std::string toString() const override
OPVers::const_iterator opVerBegin() const
OPVers::const_iterator opVerEnd() const
virtual const std::string toString() const override
virtual const std::string toString() const override
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const BranchStmt * brstmt
CallSiteID getCallSiteId() const
Return callsite ID.
virtual const std::string toString() const
const RetICFGNode * getRetICFGNode() const
Return callsite.
const std::string getSourceLoc() const override
OPVers::const_iterator opVerBegin() const
const std::string toString() const override
const ValVar * getRes() const
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
OPVers::const_iterator opVerEnd() const
const SVFVar * getValue() const override
Return the corresponding LLVM value, if possible, nullptr otherwise.
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const std::string toString() const override
virtual const std::string toString() const
NodeID getSrcID() const
get methods of the components
iterator begin()
Iterators.
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
const GEdgeSetTy & getOutEdges() const
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const std::string toString() const override
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
NodeID getNullPtr() const
NodeID getVarargNode(const FunObjVar *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
bool isFormalParmPHI() const
const std::string toString() const override
virtual const std::string toString() const
const std::string toString() const override
const std::string toString() const override
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const SVFVar * getSVFVar() const
Return corresponding SVFVar.
const std::string toString() const override
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
static const Option< bool > EnableThreadCallGraph
OPVers::const_iterator opVerBegin() const
PHIVFGNode(NodeID id, const ValVar *r, VFGNodeK k=TPhi)
Constructor.
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const std::string toString() const override
OPVers::const_iterator opVerEnd() const
const ValVar * getRes() const
const SVFVar * getValue() const override
Return the corresponding LLVM value, if possible, nullptr otherwise.
Set< const FunObjVar * > FunctionSet
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
virtual const std::string toString() const
CallSiteID getCallSiteId() const
Return callsite ID.
const ValVar * getLHSVar() const
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
bool funHasRet(const FunObjVar *func) const
bool hasFunArgsList(const FunObjVar *func) const
Function has arguments list.
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
const ValVarList & getFunArgsList(const FunObjVar *func) const
Get function arguments list.
std::vector< const ValVar * > ValVarList
CSToRetMap & getCallSiteRets()
Get callsite return.
FunToRetMap & getFunRets()
Get function return list.
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
bool callsiteHasRet(const RetICFGNode *cs) const
const ValVar * getFunRet(const FunObjVar *func) const
Get function return list.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
const ValVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
const ValVar * getValVar(NodeID id) const
CallPE * getCallPEForFormalParm(const SVFVar *param) const
Get the CallPE for a formal parameter (phi-like, nullptr if not found)
FunToArgsListMap & getFunArgsMap()
Get function arguments list.
const SVFVar * getValue() const
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
virtual const std::string toString() const
NodeID getId() const
Get ID.
virtual const std::string & getName() const
const std::string valueOnlyToString() const
virtual bool isConstDataOrAggDataButNotNullPtr() const
Check if this variable represents constant data/metadata but not null pointer.
const SVFVar * getValue() const override
Return the corresponding LLVM value, if possible, nullptr otherwise.
const SVFStmt * getSVFStmt() const
const std::string toString() const override
NodeID getDstNodeID() const
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const std::string toString() const override
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
const ValVar * getRes() const
OPVers::const_iterator opVerBegin() const
virtual const std::string toString() const override
OPVers::const_iterator opVerEnd() const
static GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
Compute the unique edgeFlag value from edge kind and CallSiteID.
virtual const std::string toString() const
virtual const std::string toString() const
FormalRetVFGNode * getFormalRetVFGNode(const SVFVar *fret) const
VFGEdge::VFGEdgeSetTy VFGEdgeSetTy
void updateCallGraph(PointerAnalysis *pta)
Update VFG based on pointer analysis results.
NodeID getDef(const ValVar *valVar) const
VFGEdge * addInterEdgeFromAPToFP(ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
void addStoreVFGNode(const StoreStmt *store)
VFGEdge * addInterEdgeFromFRToAR(FormalRetVFGNode *src, ActualRetVFGNode *dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
void addBranchVFGNode(const BranchStmt *edge)
Add a BranchVFGNode.
ActualParmVFGNode * getActualParmVFGNode(const SVFVar *aparm, const CallICFGNode *cs) const
const SVFVar * getLHSTopLevPtr(const VFGNode *node) const
VFGNodeIDToNodeMapTy::iterator iterator
VFGEdge * addRetEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
virtual void connectAParamAndFParam(const ValVar *csArg, const ValVar *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
void addVFGNodes()
Create VFG nodes.
void addLoadVFGNode(const LoadStmt *load)
Add a Load VFG node.
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *func) const
Get callsite given a callsiteID.
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
void checkIntraEdgeParents(const VFGNode *srcNode, const VFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
void addCopyVFGNode(const CopyStmt *copy)
Add a Copy VFG node.
void addGepVFGNode(const GepStmt *gep)
Add a Gep VFG node.
bool isPhiCopyEdge(const SVFStmt *copy) const
bool hasDef(const ValVar *valVar) const
void addFormalParmVFGNode(const ValVar *fparm, const FunObjVar *fun, const CallPE *callPE)
Add a formal parameter VFG node.
virtual void connectFRetAndARet(const ValVar *funReturn, const ValVar *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect formal-ret and actual ret.
void addUnaryOPVFGNode(const UnaryOPStmt *edge)
Add a UnaryOperator VFG node.
void addCmpVFGNode(const CmpStmt *edge)
Add a Compare VFG node.
FormalParmVFGNode * getFormalParmVFGNode(const SVFVar *fparm) const
bool addVFGEdge(VFGEdge *edge)
Add VFG edge.
VFGNode * getVFGNode(NodeID id) const
Get a VFG node.
void addActualParmVFGNode(const ValVar *aparm, const CallICFGNode *cs)
const FunObjVar * isFunEntryVFGNode(const VFGNode *node) const
Whether a node is function entry VFGNode.
VFG(CallGraph *callgraph, VFGK k=FULLSVFG)
Constructor.
VFGEdge * addCallEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
void addNullPtrVFGNode(const ValVar *svfVar)
virtual SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get SVFStmt set.
void addFormalRetVFGNode(const ValVar *uniqueFunRet, const FunObjVar *fun, RetPESet &retPEs)
FormalRetVFGNode::RetPESet RetPESet
VFGEdge * hasIntraVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Whether we has a SVFG edge.
void addBinaryOPVFGNode(const BinaryOPStmt *edge)
Add a BinaryOperator VFG node.
void addAddrVFGNode(const AddrStmt *addr)
Add an Address VFG node.
void addActualRetVFGNode(const ValVar *ret, const CallICFGNode *cs)
Add a callsite Receive VFG node.
VFGEdge * hasInterVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind, CallSiteID csId)
virtual bool isInterestedSVFVar(const SVFVar *node) const
void connectDirectVFGEdges()
Create edges between VFG nodes within a function.
VFGEdge * getIntraVFGEdge(const VFGNode *src, const VFGNode *dst, VFGEdge::VFGEdgeK kind)
Get a SVFG edge according to src and dst.
ActualRetVFGNode * getActualRetVFGNode(const SVFVar *aret) const
void view()
Dump graph into dot file.
VFGEdge * hasThreadVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
bool hasBlackHoleConstObjAddrAsDef(const ValVar *valVar) const
Whether a SVFVar has a blackhole or const object as its definition.
virtual void connectCallerAndCallee(const CallICFGNode *cs, const FunObjVar *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
void destroy()
Clean up memory.
void addIntraPHIVFGNode(const MultiOpndStmt *edge)
Add an llvm PHI VFG node.
virtual const std::string toString() const
Get string representation.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
bool matchArgs(const CallICFGNode *cs, const FunObjVar *callee)
std::ostream & outs()
Overwrite llvm::outs()
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
llvm::IRBuilder IRBuilder
static std::string getCompleteNodeLabel(NodeType *node, VFG *)
Return label of a VFG node with MemSSA information.
static std::string getNodeAttributes(NodeType *node, VFG *)
static std::string getEdgeSourceLabel(NodeType *, EdgeIter EI)
DOTGraphTraits(bool isSimple=false)
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, VFG *)
std::string getNodeLabel(NodeType *node, VFG *graph)
static std::string getSimpleNodeLabel(NodeType *node, VFG *)
Return label of a VFG node without MemSSA information.
static std::string getGraphName(VFG *)
Return name of the graph.