svf-lib 1.0.1234 → 1.0.1236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/MSSA/MemSSA.h +1 -16
- package/SVF-osx/include/MSSA/SVFGBuilder.h +0 -17
- package/SVF-osx/include/SABER/SaberCondAllocator.h +14 -6
- package/SVF-osx/include/SVF-FE/BasicTypes.h +9 -0
- package/SVF-osx/include/SVF-FE/LLVMModule.h +6 -28
- package/SVF-osx/include/Util/BasicTypes.h +100 -7
- package/SVF-osx/include/Util/SVFUtil.h +1 -1
- package/SVF-osx/include/Util/WorkList.h +51 -35
- package/package.json +1 -1
|
Binary file
|
|
@@ -120,8 +120,6 @@ public:
|
|
|
120
120
|
protected:
|
|
121
121
|
BVDataPTAImpl* pta;
|
|
122
122
|
MRGenerator* mrGen;
|
|
123
|
-
DominanceFrontier* df;
|
|
124
|
-
DominatorTree* dt;
|
|
125
123
|
MemSSAStat* stat;
|
|
126
124
|
|
|
127
125
|
/// Create mu chi for candidate regions in a function
|
|
@@ -291,19 +289,6 @@ private:
|
|
|
291
289
|
phi->setOpVer(getTopStackVer(phi->getMR()), pos);
|
|
292
290
|
}
|
|
293
291
|
}
|
|
294
|
-
|
|
295
|
-
//@}
|
|
296
|
-
/// Get/set methods for dominace frontier/tree
|
|
297
|
-
//@{
|
|
298
|
-
DominanceFrontier* getDF(const SVFFunction&)
|
|
299
|
-
{
|
|
300
|
-
return df;
|
|
301
|
-
}
|
|
302
|
-
DominatorTree* getDT(const SVFFunction&)
|
|
303
|
-
{
|
|
304
|
-
return dt;
|
|
305
|
-
}
|
|
306
|
-
void setCurrentDFDT(DominanceFrontier* f, DominatorTree* t);
|
|
307
292
|
//@}
|
|
308
293
|
|
|
309
294
|
public:
|
|
@@ -328,7 +313,7 @@ public:
|
|
|
328
313
|
return mrGen;
|
|
329
314
|
}
|
|
330
315
|
/// We start from here
|
|
331
|
-
virtual void buildMemSSA(const SVFFunction& fun
|
|
316
|
+
virtual void buildMemSSA(const SVFFunction& fun);
|
|
332
317
|
|
|
333
318
|
/// Perform statistics
|
|
334
319
|
void performStat();
|
|
@@ -36,23 +36,6 @@
|
|
|
36
36
|
namespace SVF
|
|
37
37
|
{
|
|
38
38
|
|
|
39
|
-
/*!
|
|
40
|
-
* Dominator frontier used in MSSA
|
|
41
|
-
*/
|
|
42
|
-
class MemSSADF : public DominanceFrontier
|
|
43
|
-
{
|
|
44
|
-
public:
|
|
45
|
-
MemSSADF() : DominanceFrontier()
|
|
46
|
-
{}
|
|
47
|
-
|
|
48
|
-
bool runOnDT(DominatorTree& dt)
|
|
49
|
-
{
|
|
50
|
-
releaseMemory();
|
|
51
|
-
analyze(dt);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
39
|
/*!
|
|
57
40
|
* SVFG Builder
|
|
58
41
|
*/
|
|
@@ -144,16 +144,24 @@ public:
|
|
|
144
144
|
return negConds.test(id);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
inline DominatorTree* getDT(const Function* fun)
|
|
147
|
+
inline bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
149
148
|
{
|
|
150
|
-
|
|
149
|
+
const SVFFunction* keyFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbKey->getParent());
|
|
150
|
+
const SVFFunction* valueFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbValue->getParent());
|
|
151
|
+
assert((keyFunc == valueFunc) && "two basicblocks should be in the same function!");
|
|
152
|
+
|
|
153
|
+
return keyFunc->postDominate(bbKey,bbValue);
|
|
151
154
|
}
|
|
152
|
-
|
|
153
|
-
inline
|
|
155
|
+
|
|
156
|
+
inline bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
154
157
|
{
|
|
155
|
-
|
|
158
|
+
const SVFFunction* keyFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbKey->getParent());
|
|
159
|
+
const SVFFunction* valueFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbValue->getParent());
|
|
160
|
+
assert((keyFunc == valueFunc) && "two basicblocks should be in the same function!");
|
|
161
|
+
|
|
162
|
+
return keyFunc->dominate(bbKey,bbValue);
|
|
156
163
|
}
|
|
164
|
+
|
|
157
165
|
/// Get LoopInfo
|
|
158
166
|
inline LoopInfo* getLoopInfo(const Function* f)
|
|
159
167
|
{
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
#include <llvm/IR/DerivedTypes.h>
|
|
18
18
|
|
|
19
19
|
#include <llvm/Analysis/MemoryLocation.h>
|
|
20
|
+
#include <llvm/Analysis/DominanceFrontier.h>
|
|
21
|
+
#include <llvm/Analysis/PostDominators.h>
|
|
20
22
|
#include <llvm/Analysis/ScalarEvolution.h>
|
|
21
23
|
#include <llvm/Analysis/ScalarEvolutionExpressions.h>
|
|
22
24
|
|
|
@@ -64,6 +66,13 @@ typedef llvm::ConstantData ConstantData;
|
|
|
64
66
|
typedef llvm::ConstantArray ConstantArray;
|
|
65
67
|
typedef llvm::Constant Constant;
|
|
66
68
|
|
|
69
|
+
/// LLVM Dominators
|
|
70
|
+
typedef llvm::DominatorTree DominatorTree;
|
|
71
|
+
typedef llvm::DomTreeNode DomTreeNode;
|
|
72
|
+
typedef llvm::DominanceFrontier DominanceFrontier;
|
|
73
|
+
typedef llvm::PostDominatorTree PostDominatorTree;
|
|
74
|
+
typedef llvm::DominanceFrontierBase<llvm::BasicBlock, false> DominanceFrontierBase;
|
|
75
|
+
|
|
67
76
|
// LLVM Instructions
|
|
68
77
|
typedef llvm::AllocaInst AllocaInst;
|
|
69
78
|
typedef llvm::AtomicCmpXchgInst AtomicCmpXchgInst;
|
|
@@ -42,9 +42,9 @@ class LLVMModuleSet
|
|
|
42
42
|
{
|
|
43
43
|
public:
|
|
44
44
|
|
|
45
|
-
typedef std::vector<const
|
|
46
|
-
typedef Map<const
|
|
47
|
-
typedef Map<const
|
|
45
|
+
typedef std::vector<const Function*> FunctionSetType;
|
|
46
|
+
typedef Map<const Function*, const Function*> FunDeclToDefMapTy;
|
|
47
|
+
typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
|
|
48
48
|
typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
|
|
49
49
|
|
|
50
50
|
private:
|
|
@@ -133,25 +133,14 @@ public:
|
|
|
133
133
|
return nullptr;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
/// Fun decl --> def
|
|
137
136
|
bool hasDefinition(const Function *fun) const
|
|
138
|
-
{
|
|
139
|
-
return hasDefinition(svfModule->getSVFFunction(fun));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
bool hasDefinition(const SVFFunction *fun) const
|
|
143
137
|
{
|
|
144
138
|
assert(fun->isDeclaration() && "not a function declaration?");
|
|
145
139
|
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
146
140
|
return it != FunDeclToDefMap.end();
|
|
147
141
|
}
|
|
148
142
|
|
|
149
|
-
const
|
|
150
|
-
{
|
|
151
|
-
return getDefinition(svfModule->getSVFFunction(fun));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const SVFFunction *getDefinition(const SVFFunction *fun) const
|
|
143
|
+
const Function *getDefinition(const Function *fun) const
|
|
155
144
|
{
|
|
156
145
|
assert(fun->isDeclaration() && "not a function declaration?");
|
|
157
146
|
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
@@ -159,18 +148,12 @@ public:
|
|
|
159
148
|
return it->second;
|
|
160
149
|
}
|
|
161
150
|
|
|
162
|
-
/// Fun def --> decl
|
|
163
151
|
bool hasDeclaration(const Function *fun) const
|
|
164
|
-
{
|
|
165
|
-
return hasDeclaration(svfModule->getSVFFunction(fun));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
bool hasDeclaration(const SVFFunction *fun) const
|
|
169
152
|
{
|
|
170
153
|
if(fun->isDeclaration() && !hasDefinition(fun))
|
|
171
154
|
return false;
|
|
172
155
|
|
|
173
|
-
const
|
|
156
|
+
const Function* funDef = fun;
|
|
174
157
|
if(fun->isDeclaration() && hasDefinition(fun))
|
|
175
158
|
funDef = getDefinition(fun);
|
|
176
159
|
|
|
@@ -180,12 +163,7 @@ public:
|
|
|
180
163
|
|
|
181
164
|
const FunctionSetType& getDeclaration(const Function *fun) const
|
|
182
165
|
{
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const FunctionSetType& getDeclaration(const SVFFunction *fun) const
|
|
187
|
-
{
|
|
188
|
-
const SVFFunction* funDef = fun;
|
|
166
|
+
const Function* funDef = fun;
|
|
189
167
|
if(fun->isDeclaration() && hasDefinition(fun))
|
|
190
168
|
funDef = getDefinition(fun);
|
|
191
169
|
|
|
@@ -103,12 +103,6 @@ typedef llvm::CallInst CallInst;
|
|
|
103
103
|
typedef llvm::StoreInst StoreInst;
|
|
104
104
|
typedef llvm::LoadInst LoadInst;
|
|
105
105
|
|
|
106
|
-
/// LLVM Dominators
|
|
107
|
-
typedef llvm::DominanceFrontier DominanceFrontier;
|
|
108
|
-
typedef llvm::DominatorTree DominatorTree;
|
|
109
|
-
typedef llvm::PostDominatorTree PostDominatorTree;
|
|
110
|
-
typedef llvm::DomTreeNode DomTreeNode;
|
|
111
|
-
typedef llvm::DominanceFrontierBase<BasicBlock, false> DominanceFrontierBase;
|
|
112
106
|
|
|
113
107
|
/// LLVM Iterators
|
|
114
108
|
#if LLVM_VERSION_MAJOR >= 11
|
|
@@ -132,6 +126,9 @@ private:
|
|
|
132
126
|
std::vector<const BasicBlock*> reachableBBs;
|
|
133
127
|
bool isUncalled;
|
|
134
128
|
bool isNotRet;
|
|
129
|
+
Map<const BasicBlock*,Set<const BasicBlock*>> dtBBsMap;
|
|
130
|
+
Map<const BasicBlock*,Set<const BasicBlock*>> dfBBsMap;
|
|
131
|
+
Map<const BasicBlock*,Set<const BasicBlock*>> pdtBBsMap;
|
|
135
132
|
public:
|
|
136
133
|
SVFFunction(const std::string& val): SVFValue(val,SVFValue::SVFFunc),
|
|
137
134
|
isDecl(false), isIntri(false), fun(nullptr), exitBB(nullptr), isUncalled(false), isNotRet(false)
|
|
@@ -209,7 +206,42 @@ public:
|
|
|
209
206
|
this->reachableBBs = reachableBBs;
|
|
210
207
|
}
|
|
211
208
|
|
|
212
|
-
inline const
|
|
209
|
+
inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getDomFrontierMap() const
|
|
210
|
+
{
|
|
211
|
+
return dfBBsMap;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
inline Map<const BasicBlock*,Set<const BasicBlock*>>& getDomFrontierMap()
|
|
215
|
+
{
|
|
216
|
+
return dfBBsMap;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getPostDomTreeMap() const
|
|
220
|
+
{
|
|
221
|
+
return pdtBBsMap;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
inline Map<const BasicBlock*,Set<const BasicBlock*>>& getPostDomTreeMap()
|
|
225
|
+
{
|
|
226
|
+
return pdtBBsMap;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
inline Map<const BasicBlock*,Set<const BasicBlock*>>& getDomTreeMap()
|
|
230
|
+
{
|
|
231
|
+
return dtBBsMap;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getDomTreeMap() const
|
|
235
|
+
{
|
|
236
|
+
return dtBBsMap;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
inline bool isUnreachable(const BasicBlock* bb) const
|
|
240
|
+
{
|
|
241
|
+
return std::find(reachableBBs.begin(), reachableBBs.end(), bb)==reachableBBs.end();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
inline bool isNotRetFunction() const
|
|
213
245
|
{
|
|
214
246
|
return isNotRet;
|
|
215
247
|
}
|
|
@@ -219,6 +251,67 @@ public:
|
|
|
219
251
|
return this->exitBB;
|
|
220
252
|
}
|
|
221
253
|
|
|
254
|
+
bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
255
|
+
{
|
|
256
|
+
if (bbKey == bbValue)
|
|
257
|
+
return true;
|
|
258
|
+
|
|
259
|
+
// An unreachable node is dominated by anything.
|
|
260
|
+
if (isUnreachable(bbValue))
|
|
261
|
+
{
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// And dominates nothing.
|
|
266
|
+
if (isUnreachable(bbKey))
|
|
267
|
+
{
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const Map<const BasicBlock*,Set<const BasicBlock*>>& dtBBsMap = getDomTreeMap();
|
|
272
|
+
Map<const BasicBlock*,Set<const BasicBlock*>>::const_iterator mapIter = dtBBsMap.find(bbKey);
|
|
273
|
+
if (mapIter != dtBBsMap.end())
|
|
274
|
+
{
|
|
275
|
+
const Set<const BasicBlock*> & dtBBs = mapIter->second;
|
|
276
|
+
if (dtBBs.find(bbValue) != dtBBs.end())
|
|
277
|
+
{
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
286
|
+
{
|
|
287
|
+
if (bbKey == bbValue)
|
|
288
|
+
return true;
|
|
289
|
+
|
|
290
|
+
// An unreachable node is dominated by anything.
|
|
291
|
+
if (isUnreachable(bbValue))
|
|
292
|
+
{
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// And dominates nothing.
|
|
297
|
+
if (isUnreachable(bbKey))
|
|
298
|
+
{
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const Map<const BasicBlock*,Set<const BasicBlock*>>& dtBBsMap = getPostDomTreeMap();
|
|
303
|
+
Map<const BasicBlock*,Set<const BasicBlock*>>::const_iterator mapIter = dtBBsMap.find(bbKey);
|
|
304
|
+
if (mapIter != dtBBsMap.end())
|
|
305
|
+
{
|
|
306
|
+
const Set<const BasicBlock*> & dtBBs = mapIter->second;
|
|
307
|
+
if (dtBBs.find(bbValue) != dtBBs.end())
|
|
308
|
+
{
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
222
315
|
// Dump Control Flow Graph of llvm function, with instructions
|
|
223
316
|
void viewCFG();
|
|
224
317
|
|
|
@@ -260,7 +260,7 @@ inline const SVFFunction* getDefFunForMultipleModule(const Function* fun)
|
|
|
260
260
|
LLVMModuleSet* llvmModuleset = LLVMModuleSet::getLLVMModuleSet();
|
|
261
261
|
const SVFFunction* svfFun = llvmModuleset->getSVFFunction(fun);
|
|
262
262
|
if (fun->isDeclaration() && llvmModuleset->hasDefinition(fun))
|
|
263
|
-
svfFun = LLVMModuleSet::getLLVMModuleSet()->getDefinition(fun);
|
|
263
|
+
svfFun = llvmModuleset->getSVFFunction(LLVMModuleSet::getLLVMModuleSet()->getDefinition(fun));
|
|
264
264
|
return svfFun;
|
|
265
265
|
}
|
|
266
266
|
|
|
@@ -58,7 +58,7 @@ class List
|
|
|
58
58
|
class ListNode
|
|
59
59
|
{
|
|
60
60
|
public:
|
|
61
|
-
ListNode(Data d)
|
|
61
|
+
ListNode(const Data& d)
|
|
62
62
|
{
|
|
63
63
|
data = d;
|
|
64
64
|
next = nullptr;
|
|
@@ -87,12 +87,12 @@ public:
|
|
|
87
87
|
return (head == nullptr);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
inline bool find(Data data) const
|
|
90
|
+
inline bool find(const Data& data) const
|
|
91
91
|
{
|
|
92
92
|
return (nodeSet.find(data) == nodeSet.end() ? false : true);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
void push(Data data)
|
|
95
|
+
void push(const Data& data)
|
|
96
96
|
{
|
|
97
97
|
if (nodeSet.find(data) == nodeSet.end())
|
|
98
98
|
{
|
|
@@ -136,7 +136,6 @@ private:
|
|
|
136
136
|
template<class Data>
|
|
137
137
|
class FIFOWorkList
|
|
138
138
|
{
|
|
139
|
-
typedef Set<Data> DataSet;
|
|
140
139
|
typedef std::deque<Data> DataDeque;
|
|
141
140
|
public:
|
|
142
141
|
FIFOWorkList() {}
|
|
@@ -148,35 +147,46 @@ public:
|
|
|
148
147
|
return data_list.empty();
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
inline bool find(Data data) const
|
|
150
|
+
inline bool find(const Data& data) const
|
|
152
151
|
{
|
|
153
|
-
return (
|
|
152
|
+
return std::find(data_list.begin(), data_list.end(), data) != data_list.end();
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
/**
|
|
157
156
|
* Push a data into the work list.
|
|
158
157
|
*/
|
|
159
|
-
inline bool push(Data data)
|
|
158
|
+
inline bool push(const Data& data)
|
|
160
159
|
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
data_list.push_back(data);
|
|
164
|
-
data_set.insert(data);
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
else
|
|
168
|
-
return false;
|
|
160
|
+
data_list.push_back(data);
|
|
161
|
+
return true;
|
|
169
162
|
}
|
|
170
163
|
|
|
171
164
|
/**
|
|
172
165
|
* Pop a data from the END of work list.
|
|
173
166
|
*/
|
|
174
167
|
inline Data pop()
|
|
168
|
+
{
|
|
169
|
+
Data data = front();
|
|
170
|
+
removeFront();
|
|
171
|
+
return data;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Remove a data from the END of work list, no return value
|
|
176
|
+
*/
|
|
177
|
+
inline void removeFront()
|
|
175
178
|
{
|
|
176
179
|
assert(!empty() && "work list is empty");
|
|
177
|
-
Data data = data_list.front();
|
|
178
180
|
data_list.pop_front();
|
|
179
|
-
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Get reference of top data from the END of work list.
|
|
185
|
+
*/
|
|
186
|
+
inline Data& front()
|
|
187
|
+
{
|
|
188
|
+
assert(!empty() && "work list is empty");
|
|
189
|
+
Data& data = data_list.front();
|
|
180
190
|
return data;
|
|
181
191
|
}
|
|
182
192
|
|
|
@@ -186,11 +196,9 @@ public:
|
|
|
186
196
|
inline void clear()
|
|
187
197
|
{
|
|
188
198
|
data_list.clear();
|
|
189
|
-
data_set.clear();
|
|
190
199
|
}
|
|
191
200
|
|
|
192
201
|
private:
|
|
193
|
-
DataSet data_set; ///< store all data in the work list.
|
|
194
202
|
DataDeque data_list; ///< work list using std::vector.
|
|
195
203
|
};
|
|
196
204
|
|
|
@@ -202,7 +210,6 @@ private:
|
|
|
202
210
|
template<class Data>
|
|
203
211
|
class FILOWorkList
|
|
204
212
|
{
|
|
205
|
-
typedef Set<Data> DataSet;
|
|
206
213
|
typedef std::vector<Data> DataVector;
|
|
207
214
|
public:
|
|
208
215
|
FILOWorkList() {}
|
|
@@ -214,35 +221,46 @@ public:
|
|
|
214
221
|
return data_list.empty();
|
|
215
222
|
}
|
|
216
223
|
|
|
217
|
-
inline bool find(Data data) const
|
|
224
|
+
inline bool find(const Data& data) const
|
|
218
225
|
{
|
|
219
|
-
return (
|
|
226
|
+
return std::find(data_list.begin(), data_list.end(), data) != data_list.end();
|
|
220
227
|
}
|
|
221
228
|
|
|
222
229
|
/**
|
|
223
230
|
* Push a data into the work list.
|
|
224
231
|
*/
|
|
225
|
-
inline bool push(Data data)
|
|
232
|
+
inline bool push(const Data& data)
|
|
226
233
|
{
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
data_list.push_back(data);
|
|
230
|
-
data_set.insert(data);
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
else
|
|
234
|
-
return false;
|
|
234
|
+
data_list.push_back(data);
|
|
235
|
+
return true;
|
|
235
236
|
}
|
|
236
237
|
|
|
237
238
|
/**
|
|
238
239
|
* Pop a data from the END of work list.
|
|
239
240
|
*/
|
|
240
241
|
inline Data pop()
|
|
242
|
+
{
|
|
243
|
+
Data data = back();
|
|
244
|
+
removeBack();
|
|
245
|
+
return data;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Remove a data from the END of work list, no return value
|
|
250
|
+
*/
|
|
251
|
+
inline void removeBack()
|
|
241
252
|
{
|
|
242
253
|
assert(!empty() && "work list is empty");
|
|
243
|
-
Data data = data_list.back();
|
|
244
254
|
data_list.pop_back();
|
|
245
|
-
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Get reference of top data from the END of work list.
|
|
259
|
+
*/
|
|
260
|
+
inline Data& back()
|
|
261
|
+
{
|
|
262
|
+
assert(!empty() && "work list is empty");
|
|
263
|
+
Data& data = data_list.back();
|
|
246
264
|
return data;
|
|
247
265
|
}
|
|
248
266
|
|
|
@@ -252,11 +270,9 @@ public:
|
|
|
252
270
|
inline void clear()
|
|
253
271
|
{
|
|
254
272
|
data_list.clear();
|
|
255
|
-
data_set.clear();
|
|
256
273
|
}
|
|
257
274
|
|
|
258
275
|
private:
|
|
259
|
-
DataSet data_set; ///< store all data in the work list.
|
|
260
276
|
DataVector data_list; ///< work list using std::vector.
|
|
261
277
|
};
|
|
262
278
|
|