Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
SVF::WTOCycleDepth< GraphT > Class Template Reference

#include <WTO.h>

Public Types

typedef GraphT::NodeType NodeT
 
typedef NodeRefList::const_iterator Iterator
 

Public Member Functions

 WTOCycleDepth ()=default
 Constructor.
 
 WTOCycleDepth (const WTOCycleDepth &)=default
 Copy constructor.
 
 WTOCycleDepth (WTOCycleDepth &&)=default
 Move constructor.
 
WTOCycleDepthoperator= (const WTOCycleDepth &)=default
 Copy assignment operator.
 
WTOCycleDepthoperator= (WTOCycleDepth &&)=default
 Move assignment operator.
 
 ~WTOCycleDepth ()=default
 Destructor.
 
void add (const NodeT *head)
 Add a cycle head in the cycleDepth.
 
Iterator begin () const
 Begin iterator over the head of cycles.
 
Iterator end () const
 End iterator over the head of cycles.
 
WTOCycleDepth operator^ (const WTOCycleDepth &other) const
 Return the common prefix of the given cycle depths.
 
bool operator< (const WTOCycleDepth &other) const
 
bool operator<= (const WTOCycleDepth &other) const
 
bool operator== (const WTOCycleDepth &other) const
 
bool operator>= (const WTOCycleDepth &other) const
 
bool operator> (const WTOCycleDepth &other) const
 
std::string toString () const
 Dump the cycleDepth, for debugging purpose.
 

Private Types

typedef std::vector< const NodeT * > NodeRefList
 

Private Member Functions

int compare (const WTOCycleDepth &other) const
 Compare the given cycle depths.
 

Private Attributes

NodeRefList _heads
 

Friends

std::ostream & operator<< (std::ostream &o, const WTOCycleDepth< GraphT > &wto)
 Overloading operator << for dumping ICFG node ID.
 

Detailed Description

template<typename GraphT>
class SVF::WTOCycleDepth< GraphT >

Cycle depth of a WTO Component

The cycle depth is represented as a list of cycle's heads, from the outermost to the innermost.

e.g., consider the following nested cycle:

-->1 --> 2 --> 3 --> 4 \ / <– 6 <– 5 <– \ / >7>

where C1: (1 2 3 4 5 6 7) is the outer cycle, where 1 is the head, and C2: (5 6 7) is the inner cycle, where 5 is the head.

The cycle depth is as following:

| Node NO. | Cycle Depth |

| 1 (head of C1) | [ ] |

| 2, 3, 4 | [1] |

| 5 (head of C2) | [1] |

| 6, 7 | [1, 5] |

Definition at line 100 of file WTO.h.

Member Typedef Documentation

◆ Iterator

template<typename GraphT >
typedef NodeRefList::const_iterator SVF::WTOCycleDepth< GraphT >::Iterator

Definition at line 111 of file WTO.h.

◆ NodeRefList

template<typename GraphT >
typedef std::vector<const NodeT*> SVF::WTOCycleDepth< GraphT >::NodeRefList
private

Definition at line 108 of file WTO.h.

◆ NodeT

template<typename GraphT >
typedef GraphT::NodeType SVF::WTOCycleDepth< GraphT >::NodeT

Definition at line 105 of file WTO.h.

Constructor & Destructor Documentation

◆ WTOCycleDepth() [1/3]

template<typename GraphT >
SVF::WTOCycleDepth< GraphT >::WTOCycleDepth ( )
default

Constructor.

◆ WTOCycleDepth() [2/3]

template<typename GraphT >
SVF::WTOCycleDepth< GraphT >::WTOCycleDepth ( const WTOCycleDepth< GraphT > &  )
default

Copy constructor.

◆ WTOCycleDepth() [3/3]

template<typename GraphT >
SVF::WTOCycleDepth< GraphT >::WTOCycleDepth ( WTOCycleDepth< GraphT > &&  )
default

Move constructor.

◆ ~WTOCycleDepth()

template<typename GraphT >
SVF::WTOCycleDepth< GraphT >::~WTOCycleDepth ( )
default

Destructor.

Member Function Documentation

◆ add()

template<typename GraphT >
void SVF::WTOCycleDepth< GraphT >::add ( const NodeT head)
inline

Add a cycle head in the cycleDepth.

Definition at line 136 of file WTO.h.

137 {
138 _heads.push_back(head);
139 }
NodeRefList _heads
Definition WTO.h:114

◆ begin()

template<typename GraphT >
Iterator SVF::WTOCycleDepth< GraphT >::begin ( ) const
inline

Begin iterator over the head of cycles.

Definition at line 142 of file WTO.h.

143 {
144 return _heads.cbegin();
145 }

◆ compare()

template<typename GraphT >
int SVF::WTOCycleDepth< GraphT >::compare ( const WTOCycleDepth< GraphT > &  other) const
inlineprivate

Compare the given cycle depths.

Definition at line 174 of file WTO.h.

175 {
176 if (this == &other)
177 {
178 return 0; // equals
179 }
180
181 auto this_it = begin();
182 auto other_it = other.begin();
183 while (this_it != end())
184 {
185 if (other_it == other.end())
186 {
187 return 1; // `this` is nested within `other`
188 }
189 else if (*this_it == *other_it)
190 {
191 ++this_it;
192 ++other_it;
193 }
194 else
195 {
196 return 2; // not comparable
197 }
198 }
199 if (other_it == other.end())
200 {
201 return 0; // equals
202 }
203 else
204 {
205 return -1; // `other` is nested within `this`
206 }
207 }
Iterator begin() const
Begin iterator over the head of cycles.
Definition WTO.h:142
Iterator end() const
End iterator over the head of cycles.
Definition WTO.h:148
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ end()

template<typename GraphT >
Iterator SVF::WTOCycleDepth< GraphT >::end ( ) const
inline

End iterator over the head of cycles.

Definition at line 148 of file WTO.h.

149 {
150 return _heads.cend();
151 }

◆ operator<()

template<typename GraphT >
bool SVF::WTOCycleDepth< GraphT >::operator< ( const WTOCycleDepth< GraphT > &  other) const
inline

Definition at line 210 of file WTO.h.

211 {
212 return compare(other) == -1;
213 }
int compare(const WTOCycleDepth &other) const
Compare the given cycle depths.
Definition WTO.h:174

◆ operator<=()

template<typename GraphT >
bool SVF::WTOCycleDepth< GraphT >::operator<= ( const WTOCycleDepth< GraphT > &  other) const
inline

Definition at line 215 of file WTO.h.

216 {
217 return compare(other) <= 0;
218 }

◆ operator=() [1/2]

Copy assignment operator.

◆ operator=() [2/2]

Move assignment operator.

◆ operator==()

template<typename GraphT >
bool SVF::WTOCycleDepth< GraphT >::operator== ( const WTOCycleDepth< GraphT > &  other) const
inline

Definition at line 220 of file WTO.h.

221 {
222 return compare(other) == 0;
223 }

◆ operator>()

template<typename GraphT >
bool SVF::WTOCycleDepth< GraphT >::operator> ( const WTOCycleDepth< GraphT > &  other) const
inline

Definition at line 230 of file WTO.h.

231 {
232 return compare(other) == 1;
233 }

◆ operator>=()

template<typename GraphT >
bool SVF::WTOCycleDepth< GraphT >::operator>= ( const WTOCycleDepth< GraphT > &  other) const
inline

Definition at line 225 of file WTO.h.

226 {
227 return operator<=(other, *this);
228 }
bool operator<=(const WTOCycleDepth &other) const
Definition WTO.h:215

◆ operator^()

Return the common prefix of the given cycle depths.

Definition at line 154 of file WTO.h.

155 {
156 WTOCycleDepth res;
157 for (auto this_it = begin(), other_it = other.begin();
158 this_it != end() && other_it != other.end(); ++this_it, ++other_it)
159 {
160 if (*this_it == *other_it)
161 {
162 res.add(*this_it);
163 }
164 else
165 {
166 break;
167 }
168 }
169 return res;
170 }
WTOCycleDepth()=default
Constructor.

◆ toString()

template<typename GraphT >
std::string SVF::WTOCycleDepth< GraphT >::toString ( ) const
inline

Dump the cycleDepth, for debugging purpose.

Definition at line 236 of file WTO.h.

237 {
238 std::string str;
239 std::stringstream rawstr(str);
240 rawstr << "[";
241 for (auto it = begin(), et = end(); it != et;)
242 {
243 rawstr << (*it)->toString();
244 ++it;
245 if (it != et)
246 {
247 rawstr << ", ";
248 }
249 }
250 rawstr << "]";
251 return rawstr.str();
252 }

Friends And Related Symbol Documentation

◆ operator<<

template<typename GraphT >
std::ostream & operator<< ( std::ostream &  o,
const WTOCycleDepth< GraphT > &  wto 
)
friend

Overloading operator << for dumping ICFG node ID.

Definition at line 256 of file WTO.h.

258 {
259 o << wto.toString();
260 return o;
261 }

Member Data Documentation

◆ _heads

template<typename GraphT >
NodeRefList SVF::WTOCycleDepth< GraphT >::_heads
private

Definition at line 114 of file WTO.h.


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