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 101 of file WTO.h.

Member Typedef Documentation

◆ Iterator

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

Definition at line 112 of file WTO.h.

◆ NodeRefList

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

Definition at line 109 of file WTO.h.

◆ NodeT

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

Definition at line 106 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 137 of file WTO.h.

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

◆ begin()

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

Begin iterator over the head of cycles.

Definition at line 143 of file WTO.h.

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

◆ compare()

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

Compare the given cycle depths.

Definition at line 175 of file WTO.h.

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

◆ end()

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

End iterator over the head of cycles.

Definition at line 149 of file WTO.h.

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

◆ operator<()

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

Definition at line 211 of file WTO.h.

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

◆ operator<=()

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

Definition at line 216 of file WTO.h.

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

◆ 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 221 of file WTO.h.

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

◆ operator>()

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

Definition at line 231 of file WTO.h.

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

◆ operator>=()

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

Definition at line 226 of file WTO.h.

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

◆ operator^()

Return the common prefix of the given cycle depths.

Definition at line 155 of file WTO.h.

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

◆ toString()

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

Dump the cycleDepth, for debugging purpose.

Definition at line 237 of file WTO.h.

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

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 257 of file WTO.h.

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

Member Data Documentation

◆ _heads

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

Definition at line 115 of file WTO.h.


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