-
Notifications
You must be signed in to change notification settings - Fork 140
SVF CPP API
| Members | Meanings |
|---|---|
| SVF::SVFUtil::outs | output stream similar to std::outs |
| SVF::SVFUtil::isa | instance of a class |
| SVF::SVFUtil::cast | casting from a parent class to a child class |
| SVF::SVFUtil::dyn_cast | dynamic casting from a parent class to a child class, return null if not successful |
| SVF::SVFUtil::getSourceLoc | give an LLVM value and return the source code line number & file name of a C/CPP file |
| SVF::SVFUtil::isCallSite | return true if an LLVM instruction is a call instruction |
| SVF::SVFUtil::isIRFile | return true if the file is a LLVM IR file |
| Members | Meanings |
|---|---|
| ICFGNode::toString | return the content of this ICFGNode in the form of a string consisting of the nodeID, llvm instructions ... |
| SVF::ICFGNode::getPAGEdges | return the PAGEdges residing in this ICFGNode |
| SVF::CallBlockNode::getCallSite | return the LLVM callsite |
| SVF::RetBlockNode::getCallSite | return the LLVM callsite |
| Members | Meanings |
|---|---|
| SVF::ICFGEdge::isIntraCFGEdge | return true if it is an intra-procedural edge |
| SVF::ICFGEdge::isCallCFGEdge | return true if it is a call edge |
| SVF::ICFGEdge::isRetCFGEdge | return true if it is a return edge |
| SVF::CallCFGEdge::getCallSite | return its corresponding llvm call instruction |
| SVF::RetCFGEdge::getCallSite | return its corresponding llvm call instruction |
-
Output the content of a node on ICFG
For example,
ICFGNode *inode = ...; // subclass object CallBlockNode : %call = call i32 (...) @source(), SVFUtil::outs() << *inode << "\n" SVFUtil::outs() << inode->toString() << "\n"The output is
IntraBlockNode 21 : %call = call i32 (...) @source()using one of the following two:
-
The
isa<>operator works similar to Java's “instanceof” operator. It returns true or false depending on whether a reference or pointer points to an instance of the specified class.For example,
ICFGNode* inodesubclass object isCallBlockNodeso that we can use the following to check whether inode is of typeCallBlockNode:if (SVFUtil::isa<CallBlockNode>(inode)) { ... }
-
Casting a pointer or reference to an instance of a specified class. This casting fails and abort the program if the object or reference is not the specified class at runtime.
For example,
cast<CallBlockNode>(inode)->getParent()
-
The
dyn_cast<>operator is a "checking cast" operation. It checks to see if the operand is of the specified type, and if so, returns a pointer to it (this operator does not work with references). If the operand is not of the correct type, a null pointer is returned. Thus, this works very much like the dynamic_cast<> operator in C++, and should be used in the same circumstances.For example,
if (RetCFGEdge* retEdge = SVFUtil::dyn_cast<RetCFGEdge>(edge)) { // ... }This form of the if statement effectively combines isa<> and cast<>, which is more compact.
-
return line number & file name of the original C/CPP source code
For example,
Assuming an Instruction
valis%call = call i32 (...) @sink()in line 6, and you can useSVFUtil::getSourceLoc(val)to navigate the instruction v's location in the source code
- return true if a file is a LLVM IR file
-
return this ICFGNode corresponding PAGEdgeList,
typedef std::list<const PAGEdge*> PAGEdgeList;For example,
ICFGNode v
%0 = load i32, i32* %a, align 4for collecting all it PAGEdges,PAGEdgeList paglist = v.getPAGEdges()
-
return the content of this ICFGNode in the form of a string consisting of the nodeID, llvm instructions and its containing function
Output Sample:
NodeID: 15\nIntraBlockNode ID: 15 store i32 1, i32* %a, align 4 \{fun: main\}}
-
return the LLVM call instruction
For example,
Assuming that
CallBlockNode*vis%call = call i32 (...) @sink(), you can usev->getCallSite()to fetch its LLVM call instruction.
- return the LLVM call instruction, similar as that of
CallBlockNode.
- return its corresponding llvm call instruction