Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
SVF::SVFFunction Class Reference

#include <SVFValue.h>

Inheritance diagram for SVF::SVFFunction:
SVF::SVFValue

Public Types

typedef std::vector< const SVFBasicBlock * >::const_iterator const_iterator
 
typedef SVFLoopAndDomInfo::BBSet BBSet
 
typedef SVFLoopAndDomInfo::BBList BBList
 
typedef SVFLoopAndDomInfo::LoopBBs LoopBBs
 
- Public Types inherited from SVF::SVFValue
enum  SVFValKind {
  SVFVal , SVFFunc , SVFBB , SVFInst ,
  SVFCall , SVFVCall , SVFGlob , SVFArg ,
  SVFConst , SVFConstData , SVFConstInt , SVFConstFP ,
  SVFNullPtr , SVFBlackHole , SVFMetaAsValue , SVFOther
}
 
typedef s64_t GNodeK
 

Public Member Functions

 SVFFunction (const SVFType *ty, const SVFFunctionType *ft, bool declare, bool intrinsic, bool addrTaken, bool varg, SVFLoopAndDomInfo *ld)
 
 SVFFunction (void)=delete
 
virtual ~SVFFunction ()
 
SVFLoopAndDomInfogetLoopAndDomInfo ()
 
bool isDeclaration () const
 
bool isIntrinsic () const
 
bool hasAddressTaken () const
 
const SVFFunctionTypegetFunctionType () const
 Returns the FunctionType. More...
 
const SVFTypegetReturnType () const
 Returns the FunctionType. More...
 
const SVFFunctiongetDefFunForMultipleModule () const
 
u32_t arg_size () const
 
const SVFArgumentgetArg (u32_t idx) const
 
bool isVarArg () const
 
bool hasBasicBlock () const
 
const SVFBasicBlockgetEntryBlock () const
 
const SVFBasicBlockgetExitBB () const
 
void setExitBlock (SVFBasicBlock *bb)
 
const SVFBasicBlockfront () const
 
const SVFBasicBlockback () const
 
const_iterator begin () const
 
const_iterator end () const
 
const std::vector< const SVFBasicBlock * > & getBasicBlockList () const
 
const std::vector< const SVFBasicBlock * > & getReachableBBs () const
 
bool isUncalledFunction () const
 
bool hasReturn () const
 
void getExitBlocksOfLoop (const SVFBasicBlock *bb, BBList &exitbbs) const
 
bool hasLoopInfo (const SVFBasicBlock *bb) const
 
const LoopBBsgetLoopInfo (const SVFBasicBlock *bb) const
 
const SVFBasicBlockgetLoopHeader (const BBList &lp) const
 
bool loopContainsBB (const BBList &lp, const SVFBasicBlock *bb) const
 
const Map< const SVFBasicBlock *, BBSet > & getDomTreeMap () const
 
const Map< const SVFBasicBlock *, BBSet > & getDomFrontierMap () const
 
bool isLoopHeader (const SVFBasicBlock *bb) const
 
bool dominate (const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
 
bool postDominate (const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
 
- Public Member Functions inherited from SVF::SVFValue
 SVFValue ()=delete
 
virtual ~SVFValue ()=default
 
GNodeK getKind () const
 Get the type of this SVFValue. More...
 
const std::stringgetName () const
 
void setName (const std::string &n)
 
void setName (std::string &&n)
 
virtual const SVFTypegetType () const
 
bool isConstDataOrAggData () const
 
bool ptrInUncalledFunction () const
 
bool isblackHole () const
 
bool isNullPtr () const
 
virtual void setSourceLoc (const std::string &sourceCodeInfo)
 
virtual const std::string getSourceLoc () const
 
std::string toString () const
 Needs to be implemented by a SVF front end. More...
 

Static Public Member Functions

static bool classof (const SVFValue *node)
 

Protected Member Functions

void addBasicBlock (const SVFBasicBlock *bb)
 a 'single' basic block having no successors and containing return instruction in a function More...
 
void addArgument (SVFArgument *arg)
 
void setIsUncalledFunction (bool uncalledFunction)
 
void setIsNotRet (bool notRet)
 
void setDefFunForMultipleModule (const SVFFunction *deffun)
 
- Protected Member Functions inherited from SVF::SVFValue
 SVFValue (const SVFType *ty, SVFValKind k)
 Constructor without name. More...
 
void setConstDataOrAggData ()
 
void setPtrInUncalledFunction ()
 

Private Attributes

bool isDecl
 
bool intrinsic
 return true if this function does not have a body More...
 
bool addrTaken
 return true if this function is an intrinsic function (e.g., llvm.dbg), which does not reside in the application code More...
 
bool isUncalled
 return true if this function is address-taken (for indirect call purposes) More...
 
bool isNotRet
 return true if this function is never called More...
 
bool varArg
 return true if this function never returns More...
 
const SVFFunctionTypefuncType
 return true if this function supports variable arguments More...
 
SVFLoopAndDomInfoloopAndDom
 FunctionType, which is different from the type (PointerType) of this SVFFunction. More...
 
const SVFFunctionrealDefFun
 the loop and dominate information More...
 
std::vector< const SVFBasicBlock * > allBBs
 the definition of a function across multiple modules More...
 
std::vector< const SVFArgument * > allArgs
 all BasicBlocks of this function More...
 
SVFBasicBlockexitBlock
 all formal arguments of this function More...
 

Friends

class LLVMModuleSet
 
class SVFIRWriter
 
class SVFIRReader
 
class SVFIRBuilder
 

Additional Inherited Members

- Protected Attributes inherited from SVF::SVFValue
const SVFTypetype
 Type of this SVFValue. More...
 
std::string name
 Short name of value for printing & debugging. More...
 
std::string sourceLoc
 

Detailed Description

Definition at line 297 of file SVFValue.h.

Member Typedef Documentation

◆ BBList

Definition at line 307 of file SVFValue.h.

◆ BBSet

Definition at line 306 of file SVFValue.h.

◆ const_iterator

Definition at line 305 of file SVFValue.h.

◆ LoopBBs

Definition at line 308 of file SVFValue.h.

Constructor & Destructor Documentation

◆ SVFFunction() [1/2]

SVFFunction::SVFFunction ( const SVFType ty,
const SVFFunctionType ft,
bool  declare,
bool  intrinsic,
bool  addrTaken,
bool  varg,
SVFLoopAndDomInfo ld 
)

Definition at line 152 of file SVFValue.cpp.

156  addrTaken(adt), isUncalled(false), isNotRet(false), varArg(varg),
157  funcType(ft), loopAndDom(ld), realDefFun(nullptr), exitBlock(nullptr)
158 {
159 }
bool intrinsic
return true if this function does not have a body
Definition: SVFValue.h:312
bool varArg
return true if this function never returns
Definition: SVFValue.h:316
bool isUncalled
return true if this function is address-taken (for indirect call purposes)
Definition: SVFValue.h:314
SVFBasicBlock * exitBlock
all formal arguments of this function
Definition: SVFValue.h:322
bool addrTaken
return true if this function is an intrinsic function (e.g., llvm.dbg), which does not reside in the ...
Definition: SVFValue.h:313
const SVFFunction * realDefFun
the loop and dominate information
Definition: SVFValue.h:319
bool isNotRet
return true if this function is never called
Definition: SVFValue.h:315
const SVFFunctionType * funcType
return true if this function supports variable arguments
Definition: SVFValue.h:317
SVFLoopAndDomInfo * loopAndDom
FunctionType, which is different from the type (PointerType) of this SVFFunction.
Definition: SVFValue.h:318
SVFValue()=delete

◆ SVFFunction() [2/2]

SVF::SVFFunction::SVFFunction ( void  )
delete

◆ ~SVFFunction()

SVFFunction::~SVFFunction ( )
virtual

Definition at line 161 of file SVFValue.cpp.

162 {
163  for(const SVFBasicBlock* bb : allBBs)
164  delete bb;
165  for(const SVFArgument* arg : allArgs)
166  delete arg;
167  delete loopAndDom;
168 }
std::vector< const SVFArgument * > allArgs
all BasicBlocks of this function
Definition: SVFValue.h:321
std::vector< const SVFBasicBlock * > allBBs
the definition of a function across multiple modules
Definition: SVFValue.h:320

Member Function Documentation

◆ addArgument()

void SVF::SVFFunction::addArgument ( SVFArgument arg)
inlineprotected

Definition at line 331 of file SVFValue.h.

332  {
333  allArgs.push_back(arg);
334  }

◆ addBasicBlock()

void SVF::SVFFunction::addBasicBlock ( const SVFBasicBlock bb)
inlineprotected

a 'single' basic block having no successors and containing return instruction in a function

attributes to be set only through Module builders e.g., LLVMModule

Definition at line 326 of file SVFValue.h.

327  {
328  allBBs.push_back(bb);
329  }

◆ arg_size()

u32_t SVFFunction::arg_size ( ) const

Definition at line 170 of file SVFValue.cpp.

171 {
172  return allArgs.size();
173 }

◆ back()

const SVFBasicBlock* SVF::SVFFunction::back ( ) const
inline

Carefully! 'back' is just the last basic block of function, but not necessarily a exit basic block more refer to: https://github.com/SVF-tools/SVF/pull/1262

Definition at line 426 of file SVFValue.h.

427  {
428  assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
432  return allBBs.back();
433  }
bool hasBasicBlock() const
Definition: SVFValue.h:404

◆ begin()

const_iterator SVF::SVFFunction::begin ( ) const
inline

Definition at line 435 of file SVFValue.h.

436  {
437  return allBBs.begin();
438  }

◆ classof()

static bool SVF::SVFFunction::classof ( const SVFValue node)
inlinestatic

Definition at line 357 of file SVFValue.h.

358  {
359  return node->getKind() == SVFFunc;
360  }

◆ dominate()

bool SVF::SVFFunction::dominate ( const SVFBasicBlock bbKey,
const SVFBasicBlock bbValue 
) const
inline

Definition at line 505 of file SVFValue.h.

506  {
507  return loopAndDom->dominate(bbKey,bbValue);
508  }
bool dominate(const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
Definition: SVFValue.cpp:54

◆ end()

const_iterator SVF::SVFFunction::end ( ) const
inline

Definition at line 440 of file SVFValue.h.

441  {
442  return allBBs.end();
443  }

◆ front()

const SVFBasicBlock* SVF::SVFFunction::front ( ) const
inline

Definition at line 421 of file SVFValue.h.

422  {
423  return getEntryBlock();
424  }
const SVFBasicBlock * getEntryBlock() const
Definition: SVFValue.h:409

◆ getArg()

const SVFArgument * SVFFunction::getArg ( u32_t  idx) const

Definition at line 175 of file SVFValue.cpp.

176 {
177  assert (idx < allArgs.size() && "getArg() out of range!");
178  return allArgs[idx];
179 }

◆ getBasicBlockList()

const std::vector<const SVFBasicBlock*>& SVF::SVFFunction::getBasicBlockList ( ) const
inline

Definition at line 445 of file SVFValue.h.

446  {
447  return allBBs;
448  }

◆ getDefFunForMultipleModule()

const SVFFunction* SVF::SVFFunction::getDefFunForMultipleModule ( ) const
inline

Definition at line 393 of file SVFValue.h.

394  {
395  if(realDefFun==nullptr)
396  return this;
397  return realDefFun;
398  }

◆ getDomFrontierMap()

const Map<const SVFBasicBlock*,BBSet>& SVF::SVFFunction::getDomFrontierMap ( ) const
inline

Definition at line 495 of file SVFValue.h.

496  {
497  return loopAndDom->getDomFrontierMap();
498  }
const Map< const SVFBasicBlock *, BBSet > & getDomFrontierMap() const
Definition: SVFValue.h:75

◆ getDomTreeMap()

const Map<const SVFBasicBlock*,BBSet>& SVF::SVFFunction::getDomTreeMap ( ) const
inline

Definition at line 490 of file SVFValue.h.

491  {
492  return loopAndDom->getDomTreeMap();
493  }
Map< const SVFBasicBlock *, BBSet > & getDomTreeMap()
Definition: SVFValue.h:139

◆ getEntryBlock()

const SVFBasicBlock* SVF::SVFFunction::getEntryBlock ( ) const
inline

Definition at line 409 of file SVFValue.h.

410  {
411  assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
412  return allBBs.front();
413  }

◆ getExitBB()

const SVFBasicBlock * SVFFunction::getExitBB ( ) const

Carefully! when you call getExitBB, you need ensure the function has return instruction more refer to: https://github.com/SVF-tools/SVF/pull/1262

Definition at line 186 of file SVFValue.cpp.

187 {
188  assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
189  assert(exitBlock && "must have an exitBlock");
190  return exitBlock;
191 }

◆ getExitBlocksOfLoop()

void SVF::SVFFunction::getExitBlocksOfLoop ( const SVFBasicBlock bb,
BBList exitbbs 
) const
inline

Definition at line 465 of file SVFValue.h.

466  {
467  return loopAndDom->getExitBlocksOfLoop(bb,exitbbs);
468  }
void getExitBlocksOfLoop(const SVFBasicBlock *bb, BBList &exitbbs) const
Definition: SVFValue.cpp:35

◆ getFunctionType()

const SVFFunctionType* SVF::SVFFunction::getFunctionType ( ) const
inline

Returns the FunctionType.

Definition at line 382 of file SVFValue.h.

383  {
384  return funcType;
385  }

◆ getLoopAndDomInfo()

SVFLoopAndDomInfo* SVF::SVFFunction::getLoopAndDomInfo ( )
inline

Definition at line 362 of file SVFValue.h.

363  {
364  return loopAndDom;
365  }

◆ getLoopHeader()

const SVFBasicBlock* SVF::SVFFunction::getLoopHeader ( const BBList lp) const
inline

Definition at line 480 of file SVFValue.h.

481  {
482  return loopAndDom->getLoopHeader(lp);
483  }
const SVFBasicBlock * getLoopHeader(const LoopBBs &lp) const
Definition: SVFValue.h:92

◆ getLoopInfo()

const LoopBBs& SVF::SVFFunction::getLoopInfo ( const SVFBasicBlock bb) const
inline

Definition at line 475 of file SVFValue.h.

476  {
477  return loopAndDom->getLoopInfo(bb);
478  }
const LoopBBs & getLoopInfo(const SVFBasicBlock *bb) const
Definition: SVFValue.cpp:28

◆ getReachableBBs()

const std::vector<const SVFBasicBlock*>& SVF::SVFFunction::getReachableBBs ( ) const
inline

Definition at line 450 of file SVFValue.h.

451  {
452  return loopAndDom->getReachableBBs();
453  }
const BBList & getReachableBBs() const
Definition: SVFValue.h:155

◆ getReturnType()

const SVFType* SVF::SVFFunction::getReturnType ( ) const
inline

Returns the FunctionType.

Definition at line 388 of file SVFValue.h.

389  {
390  return funcType->getReturnType();
391  }
const SVFType * getReturnType() const
Definition: SVFType.h:336

◆ hasAddressTaken()

bool SVF::SVFFunction::hasAddressTaken ( ) const
inline

Definition at line 376 of file SVFValue.h.

377  {
378  return addrTaken;
379  }

◆ hasBasicBlock()

bool SVF::SVFFunction::hasBasicBlock ( ) const
inline

Definition at line 404 of file SVFValue.h.

405  {
406  return !allBBs.empty();
407  }

◆ hasLoopInfo()

bool SVF::SVFFunction::hasLoopInfo ( const SVFBasicBlock bb) const
inline

Definition at line 470 of file SVFValue.h.

471  {
472  return loopAndDom->hasLoopInfo(bb);
473  }
bool hasLoopInfo(const SVFBasicBlock *bb) const
Definition: SVFValue.h:85

◆ hasReturn()

bool SVF::SVFFunction::hasReturn ( ) const
inline

Definition at line 460 of file SVFValue.h.

461  {
462  return !isNotRet;
463  }

◆ isDeclaration()

bool SVF::SVFFunction::isDeclaration ( ) const
inline

Definition at line 366 of file SVFValue.h.

367  {
368  return isDecl;
369  }

◆ isIntrinsic()

bool SVF::SVFFunction::isIntrinsic ( ) const
inline

Definition at line 371 of file SVFValue.h.

372  {
373  return intrinsic;
374  }

◆ isLoopHeader()

bool SVF::SVFFunction::isLoopHeader ( const SVFBasicBlock bb) const
inline

Definition at line 500 of file SVFValue.h.

501  {
502  return loopAndDom->isLoopHeader(bb);
503  }
bool isLoopHeader(const SVFBasicBlock *bb) const
Definition: SVFValue.cpp:141

◆ isUncalledFunction()

bool SVF::SVFFunction::isUncalledFunction ( ) const
inline

Definition at line 455 of file SVFValue.h.

456  {
457  return isUncalled;
458  }

◆ isVarArg()

bool SVFFunction::isVarArg ( ) const

Definition at line 181 of file SVFValue.cpp.

182 {
183  return varArg;
184 }

◆ loopContainsBB()

bool SVF::SVFFunction::loopContainsBB ( const BBList lp,
const SVFBasicBlock bb 
) const
inline

Definition at line 485 of file SVFValue.h.

486  {
487  return loopAndDom->loopContainsBB(lp,bb);
488  }
bool loopContainsBB(const LoopBBs &lp, const SVFBasicBlock *bb) const
Definition: SVFValue.h:98

◆ postDominate()

bool SVF::SVFFunction::postDominate ( const SVFBasicBlock bbKey,
const SVFBasicBlock bbValue 
) const
inline

Definition at line 510 of file SVFValue.h.

511  {
512  return loopAndDom->postDominate(bbKey,bbValue);
513  }
bool postDominate(const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
Definition: SVFValue.cpp:85

◆ setDefFunForMultipleModule()

void SVF::SVFFunction::setDefFunForMultipleModule ( const SVFFunction deffun)
inlineprotected

Definition at line 346 of file SVFValue.h.

347  {
348  realDefFun = deffun;
349  }

◆ setExitBlock()

void SVFFunction::setExitBlock ( SVFBasicBlock bb)

Definition at line 193 of file SVFValue.cpp.

194 {
195  assert(!exitBlock && "have already set exit Basicblock!");
196  exitBlock = bb;
197 }

◆ setIsNotRet()

void SVF::SVFFunction::setIsNotRet ( bool  notRet)
inlineprotected

Definition at line 341 of file SVFValue.h.

342  {
343  isNotRet = notRet;
344  }

◆ setIsUncalledFunction()

void SVF::SVFFunction::setIsUncalledFunction ( bool  uncalledFunction)
inlineprotected

Definition at line 336 of file SVFValue.h.

337  {
338  isUncalled = uncalledFunction;
339  }

Friends And Related Function Documentation

◆ LLVMModuleSet

friend class LLVMModuleSet
friend

Definition at line 299 of file SVFValue.h.

◆ SVFIRBuilder

friend class SVFIRBuilder
friend

Definition at line 302 of file SVFValue.h.

◆ SVFIRReader

friend class SVFIRReader
friend

Definition at line 301 of file SVFValue.h.

◆ SVFIRWriter

friend class SVFIRWriter
friend

Definition at line 300 of file SVFValue.h.

Member Data Documentation

◆ addrTaken

bool SVF::SVFFunction::addrTaken
private

return true if this function is an intrinsic function (e.g., llvm.dbg), which does not reside in the application code

Definition at line 313 of file SVFValue.h.

◆ allArgs

std::vector<const SVFArgument*> SVF::SVFFunction::allArgs
private

all BasicBlocks of this function

Definition at line 321 of file SVFValue.h.

◆ allBBs

std::vector<const SVFBasicBlock*> SVF::SVFFunction::allBBs
private

the definition of a function across multiple modules

Definition at line 320 of file SVFValue.h.

◆ exitBlock

SVFBasicBlock* SVF::SVFFunction::exitBlock
private

all formal arguments of this function

Definition at line 322 of file SVFValue.h.

◆ funcType

const SVFFunctionType* SVF::SVFFunction::funcType
private

return true if this function supports variable arguments

Definition at line 317 of file SVFValue.h.

◆ intrinsic

bool SVF::SVFFunction::intrinsic
private

return true if this function does not have a body

Definition at line 312 of file SVFValue.h.

◆ isDecl

bool SVF::SVFFunction::isDecl
private

Definition at line 311 of file SVFValue.h.

◆ isNotRet

bool SVF::SVFFunction::isNotRet
private

return true if this function is never called

Definition at line 315 of file SVFValue.h.

◆ isUncalled

bool SVF::SVFFunction::isUncalled
private

return true if this function is address-taken (for indirect call purposes)

Definition at line 314 of file SVFValue.h.

◆ loopAndDom

SVFLoopAndDomInfo* SVF::SVFFunction::loopAndDom
private

FunctionType, which is different from the type (PointerType) of this SVFFunction.

Definition at line 318 of file SVFValue.h.

◆ realDefFun

const SVFFunction* SVF::SVFFunction::realDefFun
private

the loop and dominate information

Definition at line 319 of file SVFValue.h.

◆ varArg

bool SVF::SVFFunction::varArg
private

return true if this function never returns

Definition at line 316 of file SVFValue.h.


The documentation for this class was generated from the following files: