Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
SVF::ContextCond Class Reference

#include <DPItem.h>

Public Types

typedef CallStrCxt::const_iterator const_iterator
 

Public Member Functions

 ContextCond ()
 Constructor. More...
 
 ContextCond (const ContextCond &cond)
 Copy Constructor. More...
 
 ContextCond (ContextCond &&cond) noexcept
 Move Constructor. More...
 
ContextCondoperator= (ContextCond &&cond) noexcept
 Move operator=. More...
 
virtual ~ContextCond ()
 Destructor. More...
 
const CallStrCxtgetContexts () const
 Get context. More...
 
CallStrCxtgetContexts ()
 Get context. More...
 
bool isConcreteCxt () const
 Whether it is an concrete context. More...
 
void setNonConcreteCxt ()
 Whether it is an concrete context. More...
 
bool containCallStr (NodeID cxt) const
 Whether contains callstring cxt. More...
 
u32_t cxtSize () const
 Get context size. More...
 
u32_t getMaxPathLen () const
 
virtual bool pushContext (NodeID ctx)
 Push context. More...
 
virtual bool matchContext (NodeID ctx)
 Match context. More...
 
bool operator< (const ContextCond &rhs) const
 
NodeID operator[] (const u32_t index) const
 Overloading operator[]. More...
 
ContextCondoperator= (const ContextCond &rhs)
 Overloading operator=. More...
 
bool operator== (const ContextCond &rhs) const
 Overloading operator==. More...
 
bool operator!= (const ContextCond &rhs) const
 Overloading operator!=. More...
 
const_iterator begin () const
 Begin iterators. More...
 
const_iterator end () const
 End iterators. More...
 
std::string toString () const
 Dump context condition. More...
 

Static Public Member Functions

static void setMaxCxtLen (u32_t max)
 set max context limit More...
 
static void setMaxPathLen (u32_t max)
 set max path limit More...
 

Static Public Attributes

static u32_t maximumCxt = 0
 
static u32_t maximumPath = 0
 

Protected Attributes

CallStrCxt context
 
bool concreteCxt
 

Static Protected Attributes

static u32_t maximumCxtLen = 0
 
static u32_t maximumPathLen = 0
 

Detailed Description

Context Condition

Definition at line 206 of file DPItem.h.

Member Typedef Documentation

◆ const_iterator

typedef CallStrCxt::const_iterator SVF::ContextCond::const_iterator

Definition at line 209 of file DPItem.h.

Constructor & Destructor Documentation

◆ ContextCond() [1/3]

SVF::ContextCond::ContextCond ( )
inline

Constructor.

Definition at line 211 of file DPItem.h.

211  :concreteCxt(true)
212  {
213  }
bool concreteCxt
Definition: DPItem.h:376

◆ ContextCond() [2/3]

SVF::ContextCond::ContextCond ( const ContextCond cond)
inline

Copy Constructor.

Definition at line 215 of file DPItem.h.

215  : context(cond.getContexts()), concreteCxt(cond.isConcreteCxt())
216  {
217  }
CallStrCxt context
Definition: DPItem.h:373

◆ ContextCond() [3/3]

SVF::ContextCond::ContextCond ( ContextCond &&  cond)
inlinenoexcept

Move Constructor.

Definition at line 219 of file DPItem.h.

219 : context(std::move(cond.context)), concreteCxt(cond.concreteCxt) {}
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
Definition: SVFUtil.h:447

◆ ~ContextCond()

virtual SVF::ContextCond::~ContextCond ( )
inlinevirtual

Destructor.

Definition at line 231 of file DPItem.h.

232  {
233  }

Member Function Documentation

◆ begin()

const_iterator SVF::ContextCond::begin ( void  ) const
inline

Begin iterators.

Definition at line 350 of file DPItem.h.

351  {
352  return context.begin();
353  }

◆ containCallStr()

bool SVF::ContextCond::containCallStr ( NodeID  cxt) const
inline

Whether contains callstring cxt.

Definition at line 255 of file DPItem.h.

256  {
257  return std::find(context.begin(),context.end(),cxt) != context.end();
258  }

◆ cxtSize()

u32_t SVF::ContextCond::cxtSize ( ) const
inline

Get context size.

Definition at line 260 of file DPItem.h.

261  {
262  return context.size();
263  }

◆ end()

const_iterator SVF::ContextCond::end ( void  ) const
inline

End iterators.

Definition at line 355 of file DPItem.h.

356  {
357  return context.end();
358  }

◆ getContexts() [1/2]

CallStrCxt& SVF::ContextCond::getContexts ( )
inline

Get context.

Definition at line 240 of file DPItem.h.

241  {
242  return context;
243  }

◆ getContexts() [2/2]

const CallStrCxt& SVF::ContextCond::getContexts ( ) const
inline

Get context.

Definition at line 235 of file DPItem.h.

236  {
237  return context;
238  }

◆ getMaxPathLen()

u32_t SVF::ContextCond::getMaxPathLen ( ) const
inline

Definition at line 274 of file DPItem.h.

275  {
276  return maximumPathLen;
277  }
static u32_t maximumPathLen
Definition: DPItem.h:375

◆ isConcreteCxt()

bool SVF::ContextCond::isConcreteCxt ( ) const
inline

Whether it is an concrete context.

Definition at line 245 of file DPItem.h.

246  {
247  return concreteCxt;
248  }

◆ matchContext()

virtual bool SVF::ContextCond::matchContext ( NodeID  ctx)
inlinevirtual

Match context.

if context is empty, then it is the unbalanced parentheses match

otherwise, we perform balanced parentheses matching

Definition at line 303 of file DPItem.h.

304  {
306  if(context.empty())
307  return true;
309  else if(context.back() == ctx)
310  {
311  context.pop_back();
312  return true;
313  }
314  return false;
315  }

◆ operator!=()

bool SVF::ContextCond::operator!= ( const ContextCond rhs) const
inline

Overloading operator!=.

Definition at line 345 of file DPItem.h.

346  {
347  return !(*this==rhs);
348  }

◆ operator<()

bool SVF::ContextCond::operator< ( const ContextCond rhs) const
inline

Enable compare operator to avoid duplicated item insertion in map or set to be noted that two vectors can also overload operator()

Definition at line 319 of file DPItem.h.

320  {
321  return context < rhs.context;
322  }

◆ operator=() [1/2]

ContextCond& SVF::ContextCond::operator= ( const ContextCond rhs)
inline

Overloading operator=.

Definition at line 330 of file DPItem.h.

331  {
332  if(*this!=rhs)
333  {
334  context = rhs.getContexts();
335  concreteCxt = rhs.isConcreteCxt();
336  }
337  return *this;
338  }

◆ operator=() [2/2]

ContextCond& SVF::ContextCond::operator= ( ContextCond &&  cond)
inlinenoexcept

Move operator=.

Definition at line 221 of file DPItem.h.

222  {
223  if(this!=&cond)
224  {
225  context = std::move(cond.context);
226  concreteCxt = cond.concreteCxt;
227  }
228  return *this;
229  }

◆ operator==()

bool SVF::ContextCond::operator== ( const ContextCond rhs) const
inline

Overloading operator==.

Definition at line 340 of file DPItem.h.

341  {
342  return (context == rhs.getContexts());
343  }

◆ operator[]()

NodeID SVF::ContextCond::operator[] ( const u32_t  index) const
inline

Overloading operator[].

Definition at line 324 of file DPItem.h.

325  {
326  assert(index < context.size());
327  return context[index];
328  }
int index
Definition: cJSON.h:170

◆ pushContext()

virtual bool SVF::ContextCond::pushContext ( NodeID  ctx)
inlinevirtual

Push context.

handle out of context limit case

Definition at line 279 of file DPItem.h.

280  {
281 
282  if(context.size() < maximumCxtLen)
283  {
284  context.push_back(ctx);
285 
286  if(context.size() > maximumCxt)
287  maximumCxt = context.size();
288  return true;
289  }
290  else
291  {
292  if(!context.empty())
293  {
295  context.erase(context.begin());
296  context.push_back(ctx);
297  }
298  return false;
299  }
300  }
static u32_t maximumCxt
Definition: DPItem.h:378
static u32_t maximumCxtLen
Definition: DPItem.h:374
void setNonConcreteCxt()
Whether it is an concrete context.
Definition: DPItem.h:250

◆ setMaxCxtLen()

static void SVF::ContextCond::setMaxCxtLen ( u32_t  max)
inlinestatic

set max context limit

Definition at line 265 of file DPItem.h.

266  {
267  maximumCxtLen = max;
268  }

◆ setMaxPathLen()

static void SVF::ContextCond::setMaxPathLen ( u32_t  max)
inlinestatic

set max path limit

Definition at line 270 of file DPItem.h.

271  {
272  maximumPathLen = max;
273  }

◆ setNonConcreteCxt()

void SVF::ContextCond::setNonConcreteCxt ( )
inline

Whether it is an concrete context.

Definition at line 250 of file DPItem.h.

251  {
252  concreteCxt = false;
253  }

◆ toString()

std::string SVF::ContextCond::toString ( ) const
inline

Dump context condition.

Definition at line 360 of file DPItem.h.

361  {
362  std::string str;
363  std::stringstream rawstr(str);
364  rawstr << "[:";
365  for(CallStrCxt::const_iterator it = context.begin(), eit = context.end(); it!=eit; ++it)
366  {
367  rawstr << *it << " ";
368  }
369  rawstr << " ]";
370  return rawstr.str();
371  }
const char *const string
Definition: cJSON.h:172

Member Data Documentation

◆ concreteCxt

bool SVF::ContextCond::concreteCxt
protected

Definition at line 376 of file DPItem.h.

◆ context

CallStrCxt SVF::ContextCond::context
protected

Definition at line 373 of file DPItem.h.

◆ maximumCxt

u32_t ContextCond::maximumCxt = 0
static

Definition at line 378 of file DPItem.h.

◆ maximumCxtLen

u32_t ContextCond::maximumCxtLen = 0
staticprotected

Definition at line 374 of file DPItem.h.

◆ maximumPath

u32_t ContextCond::maximumPath = 0
static

Definition at line 379 of file DPItem.h.

◆ maximumPathLen

u32_t ContextCond::maximumPathLen = 0
staticprotected

Definition at line 375 of file DPItem.h.


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