Skip to content

SVF APIs

guanqin-123 edited this page Mar 13, 2024 · 6 revisions
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
Members Meanings
ICFGNode::toString return the content of this ICFGNode in the form of a string consisting of the nodeID, llvm instructions ...
SVF::ICFGNode::getSVFStmts return a list of program statements residing in this ICFGNode
SVF::CallICFGNode::getCallSite return the LLVM callsite
SVF::RetICFGNode::getCallSite return the LLVM callsite
SVF::CallICFGNode::getRetICFGNode Given a CallICFGNode, return its corresponding RetICFGNode
SVF::RetICFGNode::getActualRet Get the return variable (SVFVar) of this RetICFGNode
SVF::CallICFGNode::getActualParms Get all the actual parameters of this CallICFGNode
SVF::RetICFGNode:: getCallICFGNode Given a RetICFGNode, return its corresponding CallICFGNode
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::ICFGEdge::getSrcNode return the edge's source node
SVF::ICFGEdge::getDstNode return the edge's destination node
SVF::CallCFGEdge::getCallSite return its corresponding llvm call instruction
SVF::CallCFGEdge:: getCallPEs get parameter edges from this CallCFGEdge (return a vector)
SVF::RetCFGEdge::getCallSite return its corresponding llvm call instruction
SVF::RetCFGEdge::getRetPE get parameter edge to this CallCFGEdge (return a RetPE)
SVF::IntraCFGEdge:: getCondition Given an IntraCFGEdge, return its conditionVar
SVF::IntraCFGEdge:: getSuccessorCondValue Given an IntraCFGEdge (must be a Branch edge, return its conditional number)
Members Meanings
SVF::SVFVar:: getValue return SVFVar's value
SVF::SVFVar:: hasValue check whether SVFVar has a value
SVF::SVFVar::isPointer check whether it is a pointer
SVF::SVFVar::isConstantData check whether it is a constant data, i.e., "0", "1.001", "str"
SVF::SVFVar::getValueName return name of the LLVM value, i.e., "%a", "@main"
Members Meanings
SVF::AssignStmt:: getRHSVar return Right Hand Side (RHS) SVFVar
SVF::AssignStmt:: getRHSVarID return Right Hand Side (RHS) SVFVar's ID
SVF::AssignStmt:: getLHSVar return Left Hand Side (LHS) SVFVar
SVF::AssignStmt:: getLHSVarID return Left Hand Side (LHS) SVFVar's ID
SVF::MultiOpndStmt:: getRes return operand result SVFVar
SVF::MultiOpndStmt:: getResID return operand result SVFVar's ID number
SVF::MultiOpndStmt:: getOpndVars return a vector of operands (vector<SVFVar*>)
SVF::MultiOpndStmt:: getOpVar(u32_t pos) return an operands at position $pos
SVF::MultiOpndStmt:: getOpVarID(u32_t pos) return an operands's ID at position $pos

SVF::SVFUtil::outs()

  • Output the content of a node on ICFG

    For example,

     ICFGNode *inode = ...;  // subclass object CallICFGNode : %call = call i32 (...) @source(),
     SVFUtil::outs() << inode->toString() << "\n"
    

    The output is IntraICFGNode 21 : %call = call i32 (...) @source()


ICFGNode::toString()

  • 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\nIntraICFGNode ID: 15 store i32 1, i32* %a, align 4 \{fun: main\}}


SVFUtil::cast<>()

  • 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,

    SVFUtil::cast<CallICFGNode>(inode)->getParent()
    

SVFUtil::dyn_cast<>()

  • 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 (CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(inode)) {
    // ...
    }
    

    This form of dyn_cast<> is an effective combination of isa<> and cast<> as below:

    if (SVFUtil::isa<CallICFGNode>(inode)) { 
         CallICFGNode* callNode =  SVFUtil::cast<CallICFGNode>(inode);
    }