40using namespace SVFUtil;
41using namespace LLVMUtil;
61 if (start == std::string::npos)
64 end = start +
prefix.size();
105 if (!
glob || !
glob->isConstant() || !
glob->hasDefinitiveInitializer())
108 if (!data || !data->isCString())
111 auto format = data->getAsCString();
112 auto in = [](
const std::string& set,
char c)
114 return set.find(
c) != std::string::npos;
125 if (
format.consume_front(
"%"))
151 format.consume_front(
"^");
152 format.consume_front(
"]");
153 const size_t end =
format.find(
']');
183 std::vector<MemcpyField>& fields,
249 std::vector<MemcpyField> fields;
262 if (
const auto*
global = llvm::dyn_cast_or_null<GlobalVariable>(
baseValue))
263 return global->getValueType();
309 fields.push_back(
ls);
325 std::vector<AccessPath> fields;
404 fields[
index].getConstantStructFldIdx());
406 fields[
index].getConstantStructFldIdx());
458 if (!
arg->getType()->isPointerTy())
489 if (cs->getArgOperand(
arg_pos)->getType()->isPointerTy())
502 writeWrnMsg(
"Arg receiving new object must be pointer type");
509 if(
callee->getName().find(
"iconv") != std::string::npos)
511 else if(
callee->getName().find(
"bcopy") != std::string::npos)
513 if(cs->arg_size() == 3)
517 if(SVFUtil::isa<PointerType>(cs->getType()))
536 if(SVFUtil::isa<PointerType>(cs->getType()))
539 else if(
callee->getName().compare(
"dlsym") == 0)
554 const Value* src = cs->getArgOperand(1);
560 if (!SVFUtil::isa<GlobalVariable>(src))
563 auto *
glob = SVFUtil::cast<GlobalVariable>(src);
564 if (!
glob->hasInitializer() || !SVFUtil::isa<ConstantDataArray>(
glob->getInitializer()))
567 auto *
constarray = SVFUtil::cast<ConstantDataArray>(
glob->getInitializer());
577 else if(
callee->getName().find(
"_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_") != std::string::npos)
580 assert(cs->arg_size() == 4 &&
"_Rb_tree_insert_and_rebalance should have 4 arguments.\n");
595 if((
u32_t)
i >= fields.size())
598 fields[
i].getConstantStructFldIdx());
615 assert((
forkedFun->arg_size() <= 2) &&
"Size of formal parameter of start routine should be one");
char const int const cJSON_bool format
APOffset getConstantStructFldIdx() const
Get methods.
Class representing a function argument variable in the SVFIR.
static ExtAPI * getExtAPI()
const std::vector< std::string > & getExtFuncAnnotations(const FunObjVar *fun)
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.
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()
NodeID allocateValueId(void)
Allocate a value ID as determined by the strategy.
static NodeIDAllocator * get(void)
Return (singleton) allocator.
const Type * inferObjType(const Value *var)
get or infer the type of the object pointed by the value
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
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 void handleNondetArgStoreAtExtCall(const CallBase *cs, const CallICFGNode *callICFGNode)
NodeID getDirectAccessFieldZeroValVar(const Value *ptr, const Type *accessTy)
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)
NodeID addValNode(NodeID i, const SVFType *type, const ICFGNode *icfgNode)
add node into SVFIR
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)
static SVFType * getSVFInt8Type()
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::GlobalVariable GlobalVariable
llvm::StructType StructType
LLVM types.
llvm::StructLayout StructLayout
llvm::Value Value
LLVM Basic classes.
llvm::IRBuilder IRBuilder
llvm::GetElementPtrInst GetElementPtrInst
llvm::ConstantDataArray ConstantDataArray
llvm::ConstantInt ConstantInt
llvm::LLVMContext LLVMContext