30#ifndef AnalysisUtil_H_
31#define AnalysisUtil_H_
73std::string
sucMsg(
const std::string&
msg);
76std::string
wrnMsg(
const std::string&
msg);
83std::string
errMsg(
const std::string&
msg);
90std::string
pasMsg(
const std::string&
msg);
110 return (
lpts.count() <
rpts.count());
118 return (*bit < *
rbit);
128 return (
lpts.count() <
rpts.count());
136 return (*bit < *
rbit);
177 if(SVFUtil::isa<SVFCallInst>(
val))
205 std::vector<std::string>
output;
225template <
typename Data>
238template <
typename Key,
typename KeySet>
251template <
typename Key,
typename KeySet>
327 return fun && fun->
getName() ==
"main";
340 return fun && (fun->
getName() ==
"exit" ||
341 fun->
getName() ==
"__assert_rtn" ||
342 fun->
getName() ==
"__assert_fail" );
349 return arg->isArgOfUncalledFunction();
446constexpr typename std::remove_reference<T>::type &&
462template <
typename T,
typename =
void>
struct is_iterable : std::false_type {};
465 std::end(std::declval<T&>()))>>
472template <
typename T>
struct is_map : std::false_type {};
473template <
typename...
Ts>
struct is_map<std::
map<Ts...>> : std::true_type {};
474template <
typename...
Ts>
481template <
typename T>
struct is_set : std::false_type {};
482template <
typename...
Ts>
struct is_set<std::
set<Ts...>> : std::true_type {};
483template <
typename...
Ts>
490template <
typename...
Ts>
492template <
typename...
Ts>
494template <
typename...
Ts>
496template <
typename...
Ts>
set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) add_llvm_executable(wpa wpa.cpp) target_link_libraries(wpa PUBLIC $
bool is_alloc(const SVFFunction *F)
bool is_arg_alloc(const SVFFunction *F)
bool is_ext(const SVFFunction *F)
static ExtAPI * getExtAPI()
s32_t get_alloc_arg_pos(const SVFFunction *F)
bool is_memset(const SVFFunction *F)
bool is_memcpy(const SVFFunction *F)
bool is_realloc(const SVFFunction *F)
const std::string & getName() const
const ValVar * getForkedFun(const CallICFGNode *inst) const
bool isTDFork(const CallICFGNode *inst) const
Return true if this call create a new thread.
bool isTDJoin(const CallICFGNode *inst) const
Return true if this call wait for a worker thread.
bool isTDRelease(const CallICFGNode *inst) const
Return true if this call release a lock.
bool isTDExit(const CallICFGNode *inst) const
Return true if this call exits/terminate a thread.
const ValVar * getActualParmAtForkSite(const CallICFGNode *inst) const
static ThreadAPI * getThreadAPI()
Return a static reference.
bool isTDBarWait(const CallICFGNode *inst) const
Return true if this call waits for a barrier.
bool isTDAcquire(const CallICFGNode *inst) const
Return true if this call acquire a lock.
bool isReallocExtCall(const CallICFGNode *cs)
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
void increaseStackSize()
Increase the stack size limit.
const ObjVar * getObjVarOfValVar(const ValVar *valVar)
std::string bugMsg1(const std::string &msg)
std::string hclustMethodToString(hclust_fast_methods method)
Returns a string representation of a hclust method.
void stopAnalysisLimitTimer(bool limitTimerSet)
bool isLockAquireCall(const CallICFGNode *cs)
bool isHeapAllocExtFunViaRet(const SVFFunction *fun)
Return true if the call is a heap allocator/reallocator.
bool isArgOfUncalledFunction(const SVFValue *svfval)
Return true if this argument belongs to an uncalled function.
bool isExtCall(const SVFFunction *fun)
bool isProgEntryFunction(const SVFFunction *fun)
Program entry function e.g. main.
bool isBarrierWaitCall(const CallICFGNode *cs)
Return true if this is a barrier wait call.
void mergePtsOccMaps(Map< Data, unsigned > &to, const Map< Data, unsigned > from)
Given a map mapping points-to sets to a count, adds from into to.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
OrderedSet< PointsTo, equalPointsTo > PointsToList
void dumpAliasSet(unsigned node, NodeBS To)
Dump alias set.
bool isMemsetExtFun(const SVFFunction *fun)
bool getMemoryUsageKB(u32_t *vmrss_kb, u32_t *vmsize_kb)
Get memory usage from system file. Return TRUE if succeed.
bool isMemcpyExtFun(const SVFFunction *fun)
void reportMemoryUsageKB(const std::string &infor, OutStream &O=SVFUtil::outs())
Print memory usage in KB.
bool startAnalysisLimitTimer(unsigned timeLimit)
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::string bugMsg3(const std::string &msg)
constexpr bool is_sequence_container_v
bool isHeapAllocExtCallViaArg(const CallICFGNode *cs)
bool isHeapAllocExtCall(const ICFGNode *cs)
u32_t getHeapAllocHoldingArgPosition(const SVFFunction *fun)
Get the position of argument that holds an allocated heap object.
bool isNonInstricCallSite(const ICFGNode *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
bool isThreadJoinCall(const CallICFGNode *cs)
NodeBS ptsToNodeBS(const PointsTo &pts)
bool isCallSite(const SVFValue *val)
Whether an instruction is a call or invoke instruction.
bool cmpNodeBS(const NodeBS &lpts, const NodeBS &rpts)
bool isReallocExtFun(const SVFFunction *fun)
Return true if the call is a heap reallocator.
constexpr bool is_iterable_v
std::ostream & errs()
Overwrite llvm::errs()
bool cmpPts(const PointsTo &lpts, const PointsTo &rpts)
bool isThreadForkCall(const CallICFGNode *inst)
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
void dumpSparseSet(const NodeBS &To)
bool isHeapAllocExtFunViaArg(const SVFFunction *fun)
const ValVar * getActualParmAtForkSite(const CallICFGNode *cs)
Return sole argument of the thread routine.
bool isLockReleaseCall(const CallICFGNode *cs)
bool isIntrinsicInst(const SVFInstruction *inst)
Return true if it is an llvm intrinsic instruction.
void dumpPointsToSet(unsigned node, NodeBS To)
Dump points-to set.
bool isThreadExitCall(const CallICFGNode *cs)
std::string bugMsg2(const std::string &msg)
bool isProgExitCall(const CallICFGNode *cs)
std::string wrnMsg(const std::string &msg)
Returns warning message by converting a string into yellow string output.
const ValVar * getForkedFun(const CallICFGNode *inst)
Return thread fork function.
typename make_void< Ts... >::type void_t
bool isRetInstNode(const ICFGNode *node)
std::ostream & outs()
Overwrite llvm::outs()
bool matchArgs(const CallICFGNode *cs, const SVFFunction *callee)
void timeLimitReached(int signum)
Function to call when alarm for time limit hits.
const SVFFunction * getProgFunction(const std::string &funName)
Get program entry function from function name.
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
bool isHeapAllocExtCallViaRet(const CallICFGNode *cs)
interfaces to be used externally
void dumpSet(NodeBS To, OutStream &O=SVFUtil::outs())
Dump sparse bitvector set.
bool isProgExitFunction(const SVFFunction *fun)
Return true if this is a program exit function call.
const SVFFunction * getProgEntryFunction()
Get program entry function.
void removeKey(const Key &key, KeySet &keySet)
Removes an element from a Set/CondSet (or anything implementing ::erase).
void insertKey(const Key &key, KeySet &keySet)
Inserts an element into a Set/CondSet (with ::insert).
std::vector< std::string > split(const std::string &s, char separator)
Split into two substrings around the first occurrence of a separator string.
void dumpPointsToList(const PointsToList &ptl)
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder
bool operator()(const NodeBS &lhs, const NodeBS &rhs) const
bool operator()(const PointsTo &lhs, const PointsTo &rhs) const
Type trait that checks if a type is iterable (can be applied on a range-based for loop)
Type trait to check if a type is a map or unordered_map.
Type trait to check if a type is vector or list.
Type trait to check if a type is a set or unordered_set.
void_t is not available until C++17. We define it here for C++11/14.