38using namespace SVFUtil;
39using namespace LLVMUtil;
56 std::vector<MemcpyField>& fields,
103 std::vector<MemcpyField> fields;
116 if (
const auto*
global = llvm::dyn_cast_or_null<GlobalVariable>(
baseValue))
117 return global->getValueType();
156 fields.push_back(
ls);
172 std::vector<AccessPath> fields;
252 fields[
index].getConstantStructFldIdx());
254 fields[
index].getConstantStructFldIdx());
277 if (cs->getArgOperand(
arg_pos)->getType()->isPointerTy())
290 writeWrnMsg(
"Arg receiving new object must be pointer type");
297 if(
callee->getName().find(
"iconv") != std::string::npos)
299 else if(
callee->getName().find(
"bcopy") != std::string::npos)
301 if(cs->arg_size() == 3)
305 if(SVFUtil::isa<PointerType>(cs->getType()))
324 if(SVFUtil::isa<PointerType>(cs->getType()))
327 else if(
callee->getName().compare(
"dlsym") == 0)
342 const Value* src = cs->getArgOperand(1);
348 if (!SVFUtil::isa<GlobalVariable>(src))
351 auto *
glob = SVFUtil::cast<GlobalVariable>(src);
352 if (!
glob->hasInitializer() || !SVFUtil::isa<ConstantDataArray>(
glob->getInitializer()))
355 auto *
constarray = SVFUtil::cast<ConstantDataArray>(
glob->getInitializer());
365 else if(
callee->getName().find(
"_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_") != std::string::npos)
368 assert(cs->arg_size() == 4 &&
"_Rb_tree_insert_and_rebalance should have 4 arguments.\n");
383 if((
u32_t)
i >= fields.size())
386 fields[
i].getConstantStructFldIdx());
403 assert((
forkedFun->arg_size() <= 2) &&
"Size of formal parameter of start routine should be one");
APOffset getConstantStructFldIdx() const
Get methods.
Class representing a function argument variable in the SVFIR.
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
const FunObjVar * getDefFunForMultipleModule() const
NodeType * getGNode(NodeID id) const
Get a node.
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
u32_t getFlattenedElemIdx(const SVFType *T, u32_t origId)
Flattened element idx of an array or struct by considering stride.
u32_t getNumOfFlattenElements(const SVFType *T)
const SVFType * getFlatternedElemType(const SVFType *baseType, u32_t flatten_idx)
Return the type of a flattened element given a flattened index.
const SVFType * getOriginalElemType(const SVFType *baseType, u32_t origId) const
NodeID getValueNode(const Value *V)
Module * getMainLLVMModule() const
static LLVMModuleSet * getLLVMModuleSet()
void addToSVFVar2LLVMValueMap(const Value *val, SVFValue *svfBaseNode)
SVFType * getSVFType(const Type *T)
Get or create SVFType and typeinfo.
CallICFGNode * getCallICFGNode(const Instruction *cs)
get a call node
NodeID getObjectNode(const Value *V)
LLVMContext & getContext() const
ObjTypeInference * getTypeInference()
const Type * inferObjType(const Value *var)
get or infer the type of the object pointed by the value
SVFIR * getPAG() const
Return SVFIR.
void addStoreEdge(NodeID src, NodeID dst)
Add Store edge.
void addLoadEdge(NodeID src, NodeID dst)
Add Load edge.
virtual void handleExtCall(const CallBase *cs, const Function *callee)
AddrStmt * addAddrWithHeapSz(NodeID src, NodeID dst, const CallBase *cs)
Add Address edge from ext call with args like "%5 = call i8* @malloc(i64 noundef 5)".
LLVMModuleSet * llvmModuleSet()
void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Thread fork edge for parameter passing.
AccessPath getAccessPathFromBaseNode(NodeID nodeId)
const Value * getBaseValueForExtArg(const Value *V)
Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst,...
virtual const Type * getBaseTypeAndFlattenedFields(const Value *V, std::vector< AccessPath > &fields, const Value *szValue)
Handle external call.
CopyStmt * addCopyEdge(NodeID src, NodeID dst, CopyStmt::CopyKind kind)
NodeID getValueNode(const Value *V)
Get different kinds of node.
virtual void addComplexConsForExt(Value *D, Value *S, const Value *sz)
NodeID getGepValVar(const Value *val, const AccessPath &ap, const SVFType *elementType)
NodeID addConstantIntValNode(NodeID i, const std::pair< s64_t, u64_t > &intValue, const ICFGNode *icfgNode, const SVFType *type)
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
SVFTypeLocSetsPair & getTypeLocSetsMap(NodeID argId)
Given an arg NodeId, get its base SVFType* and all its field location sets.
NodeID addDummyObjNode(const SVFType *type)
const Function * getProgFunction(const std::string &funName)
Get program entry function from module.
const Value * stripConstantCasts(const Value *val)
Strip off the constant casts.
bool isHeapAllocExtCallViaRet(const Instruction *inst)
bool isMemcpyExtFun(const Function *fun)
std::pair< s64_t, u64_t > getIntegerValue(const ConstantInt *intValue)
bool isConstDataOrAggData(const Value *val)
Return true if the value refers to constant data, e.g., i32 0.
bool isHeapAllocExtCallViaArg(const Instruction *inst)
bool isMemsetExtFun(const Function *fun)
bool isObject(const Value *ref)
Return true if this value refers to a object.
u32_t getHeapAllocHoldingArgPosition(const Function *fun)
bool isThreadForkCall(const CallICFGNode *inst)
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
const ValVar * getActualParmAtForkSite(const CallICFGNode *cs)
Return sole argument of the thread routine.
const ValVar * getForkedFun(const CallICFGNode *inst)
Return thread fork function.
llvm::DataLayout DataLayout
llvm::StructType StructType
LLVM types.
llvm::StructLayout StructLayout
llvm::Value Value
LLVM Basic classes.
llvm::IRBuilder IRBuilder
llvm::GetElementPtrInst GetElementPtrInst
llvm::ConstantInt ConstantInt
llvm::LLVMContext LLVMContext