svf-lib 1.0.1301 → 1.0.1302
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/package.json +1 -1
- package/SVF-linux/include/SVF-FE/BasicTypes.h +0 -219
- package/SVF-linux/include/SVF-FE/BreakConstantExpr.h +0 -94
- package/SVF-linux/include/SVF-FE/CHG.h +0 -334
- package/SVF-linux/include/SVF-FE/CHGBuilder.h +0 -73
- package/SVF-linux/include/SVF-FE/CPPUtil.h +0 -130
- package/SVF-linux/include/SVF-FE/CallGraphBuilder.h +0 -74
- package/SVF-linux/include/SVF-FE/CommonCHG.h +0 -49
- package/SVF-linux/include/SVF-FE/DCHG.h +0 -470
- package/SVF-linux/include/SVF-FE/DataFlowUtil.h +0 -190
- package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
- package/SVF-linux/include/SVF-FE/Graph2Json.h +0 -30
- package/SVF-linux/include/SVF-FE/ICFGBuilder.h +0 -106
- package/SVF-linux/include/SVF-FE/IRAnnotator.h +0 -323
- package/SVF-linux/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
- package/SVF-linux/include/SVF-FE/LLVMModule.h +0 -319
- package/SVF-linux/include/SVF-FE/LLVMUtil.h +0 -303
- package/SVF-linux/include/SVF-FE/LocMemModel.h +0 -35
- package/SVF-linux/include/SVF-FE/MemModelBuilder.h +0 -102
- package/SVF-linux/include/SVF-FE/PAGBuilder.h +0 -390
- package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +0 -412
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +0 -99
- package/SVF-linux/include/SVF-FE/SymbolTableInfo.h +0 -439
- package/SVF-osx/include/SVF-FE/BasicTypes.h +0 -219
- package/SVF-osx/include/SVF-FE/BreakConstantExpr.h +0 -94
- package/SVF-osx/include/SVF-FE/CHG.h +0 -334
- package/SVF-osx/include/SVF-FE/CHGBuilder.h +0 -73
- package/SVF-osx/include/SVF-FE/CPPUtil.h +0 -130
- package/SVF-osx/include/SVF-FE/CallGraphBuilder.h +0 -74
- package/SVF-osx/include/SVF-FE/CommonCHG.h +0 -49
- package/SVF-osx/include/SVF-FE/DCHG.h +0 -470
- package/SVF-osx/include/SVF-FE/DataFlowUtil.h +0 -190
- package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
- package/SVF-osx/include/SVF-FE/Graph2Json.h +0 -30
- package/SVF-osx/include/SVF-FE/ICFGBuilder.h +0 -106
- package/SVF-osx/include/SVF-FE/IRAnnotator.h +0 -323
- package/SVF-osx/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
- package/SVF-osx/include/SVF-FE/LLVMModule.h +0 -319
- package/SVF-osx/include/SVF-FE/LLVMUtil.h +0 -303
- package/SVF-osx/include/SVF-FE/LocMemModel.h +0 -35
- package/SVF-osx/include/SVF-FE/MemModelBuilder.h +0 -102
- package/SVF-osx/include/SVF-FE/PAGBuilder.h +0 -390
- package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +0 -412
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +0 -99
- package/SVF-osx/include/SVF-FE/SymbolTableInfo.h +0 -439
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
//===- SVFIRBuilder.h -- Building SVFIR-------------------------------------------//
|
|
2
|
-
//
|
|
3
|
-
// SVF: Static Value-Flow Analysis
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) <2013-2017> <Yulei Sui>
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
// This program is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
|
|
13
|
-
// This program is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
//
|
|
21
|
-
//===----------------------------------------------------------------------===//
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* SVFIRBuilder.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: Nov 1, 2013
|
|
27
|
-
* Author: Yulei Sui
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef PAGBUILDER_H_
|
|
31
|
-
#define PAGBUILDER_H_
|
|
32
|
-
|
|
33
|
-
#include "MemoryModel/SVFIR.h"
|
|
34
|
-
#include "Util/ExtAPI.h"
|
|
35
|
-
#include "SVF-FE/BasicTypes.h"
|
|
36
|
-
#include "SVF-FE/ICFGBuilder.h"
|
|
37
|
-
|
|
38
|
-
namespace SVF
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
class SVFModule;
|
|
42
|
-
/*!
|
|
43
|
-
* SVFIR Builder to create SVF variables and statements and PAG
|
|
44
|
-
*/
|
|
45
|
-
class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
private:
|
|
49
|
-
SVFIR* pag;
|
|
50
|
-
SVFModule* svfModule;
|
|
51
|
-
const BasicBlock* curBB; ///< Current basic block during SVFIR construction when visiting the module
|
|
52
|
-
const Value* curVal; ///< Current Value during SVFIR construction when visiting the module
|
|
53
|
-
|
|
54
|
-
public:
|
|
55
|
-
/// Constructor
|
|
56
|
-
SVFIRBuilder(SVFModule* mod): pag(SVFIR::getPAG()), svfModule(mod), curBB(nullptr),curVal(nullptr)
|
|
57
|
-
{
|
|
58
|
-
}
|
|
59
|
-
/// Destructor
|
|
60
|
-
virtual ~SVFIRBuilder()
|
|
61
|
-
{
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/// Start building SVFIR here
|
|
65
|
-
virtual SVFIR* build();
|
|
66
|
-
|
|
67
|
-
/// Return SVFIR
|
|
68
|
-
SVFIR* getPAG() const
|
|
69
|
-
{
|
|
70
|
-
return pag;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/// Initialize nodes and edges
|
|
74
|
-
//@{
|
|
75
|
-
void initialiseNodes();
|
|
76
|
-
void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
|
|
77
|
-
s32_t offset = 0, Instruction* cs = nullptr);
|
|
78
|
-
// @}
|
|
79
|
-
|
|
80
|
-
/// Sanity check for SVFIR
|
|
81
|
-
void sanityCheck();
|
|
82
|
-
|
|
83
|
-
/// Get different kinds of node
|
|
84
|
-
//@{
|
|
85
|
-
// GetValNode - Return the value node according to a LLVM Value.
|
|
86
|
-
NodeID getValueNode(const Value* V)
|
|
87
|
-
{
|
|
88
|
-
// first handle gep edge if val if a constant expression
|
|
89
|
-
processCE(V);
|
|
90
|
-
|
|
91
|
-
// strip off the constant cast and return the value node
|
|
92
|
-
return pag->getValueNode(V);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
|
|
96
|
-
inline NodeID getObjectNode(const Value* V)
|
|
97
|
-
{
|
|
98
|
-
return pag->getObjectNode(V);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/// getReturnNode - Return the node representing the unique return value of a function.
|
|
102
|
-
inline NodeID getReturnNode(const SVFFunction *func)
|
|
103
|
-
{
|
|
104
|
-
return pag->getReturnNode(func);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/// getVarargNode - Return the node representing the unique variadic argument of a function.
|
|
108
|
-
inline NodeID getVarargNode(const SVFFunction *func)
|
|
109
|
-
{
|
|
110
|
-
return pag->getVarargNode(func);
|
|
111
|
-
}
|
|
112
|
-
//@}
|
|
113
|
-
/// Update SVFIR given a call graph (creating new CallPE and RetPE for resolved indirect calls)
|
|
114
|
-
void updateCallGraph(PTACallGraph* callgraph);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/// Our visit overrides.
|
|
118
|
-
//@{
|
|
119
|
-
// Instructions that cannot be folded away.
|
|
120
|
-
virtual void visitAllocaInst(AllocaInst &AI);
|
|
121
|
-
void visitPHINode(PHINode &I);
|
|
122
|
-
void visitStoreInst(StoreInst &I);
|
|
123
|
-
void visitLoadInst(LoadInst &I);
|
|
124
|
-
void visitGetElementPtrInst(GetElementPtrInst &I);
|
|
125
|
-
void visitCallInst(CallInst &I);
|
|
126
|
-
void visitInvokeInst(InvokeInst &II);
|
|
127
|
-
void visitCallBrInst(CallBrInst &I);
|
|
128
|
-
void visitCallSite(CallSite cs);
|
|
129
|
-
void visitReturnInst(ReturnInst &I);
|
|
130
|
-
void visitCastInst(CastInst &I);
|
|
131
|
-
void visitSelectInst(SelectInst &I);
|
|
132
|
-
void visitExtractValueInst(ExtractValueInst &EVI);
|
|
133
|
-
void visitBranchInst(BranchInst &I);
|
|
134
|
-
void visitSwitchInst(SwitchInst &I);
|
|
135
|
-
void visitInsertValueInst(InsertValueInst &I)
|
|
136
|
-
{
|
|
137
|
-
addBlackHoleAddrEdge(getValueNode(&I));
|
|
138
|
-
}
|
|
139
|
-
// TerminatorInst and UnwindInst have been removed since llvm-8.0.0
|
|
140
|
-
// void visitTerminatorInst(TerminatorInst &TI) {}
|
|
141
|
-
// void visitUnwindInst(UnwindInst &I) { /*returns void*/}
|
|
142
|
-
|
|
143
|
-
void visitBinaryOperator(BinaryOperator &I);
|
|
144
|
-
void visitUnaryOperator(UnaryOperator &I);
|
|
145
|
-
void visitCmpInst(CmpInst &I);
|
|
146
|
-
|
|
147
|
-
/// TODO: var arguments need to be handled.
|
|
148
|
-
/// https://llvm.org/docs/LangRef.html#id1911
|
|
149
|
-
void visitVAArgInst(VAArgInst&);
|
|
150
|
-
void visitVACopyInst(VACopyInst&) {}
|
|
151
|
-
void visitVAEndInst(VAEndInst&) {}
|
|
152
|
-
void visitVAStartInst(VAStartInst&) {}
|
|
153
|
-
|
|
154
|
-
/// <result> = freeze ty <val>
|
|
155
|
-
/// If <val> is undef or poison, ‘freeze’ returns an arbitrary, but fixed value of type `ty`
|
|
156
|
-
/// Otherwise, this instruction is a no-op and returns the input <val>
|
|
157
|
-
void visitFreezeInst(FreezeInst& I);
|
|
158
|
-
|
|
159
|
-
void visitExtractElementInst(ExtractElementInst &I);
|
|
160
|
-
|
|
161
|
-
void visitInsertElementInst(InsertElementInst &I)
|
|
162
|
-
{
|
|
163
|
-
addBlackHoleAddrEdge(getValueNode(&I));
|
|
164
|
-
}
|
|
165
|
-
void visitShuffleVectorInst(ShuffleVectorInst &I)
|
|
166
|
-
{
|
|
167
|
-
addBlackHoleAddrEdge(getValueNode(&I));
|
|
168
|
-
}
|
|
169
|
-
void visitLandingPadInst(LandingPadInst &I)
|
|
170
|
-
{
|
|
171
|
-
addBlackHoleAddrEdge(getValueNode(&I));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/// Instruction not that often
|
|
175
|
-
void visitResumeInst(ResumeInst&) /*returns void*/
|
|
176
|
-
{
|
|
177
|
-
}
|
|
178
|
-
void visitUnreachableInst(UnreachableInst&) /*returns void*/
|
|
179
|
-
{
|
|
180
|
-
}
|
|
181
|
-
void visitFenceInst(FenceInst &I) /*returns void*/
|
|
182
|
-
{
|
|
183
|
-
addBlackHoleAddrEdge(getValueNode(&I));
|
|
184
|
-
}
|
|
185
|
-
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
|
|
186
|
-
{
|
|
187
|
-
addBlackHoleAddrEdge(getValueNode(&I));
|
|
188
|
-
}
|
|
189
|
-
void visitAtomicRMWInst(AtomicRMWInst &I)
|
|
190
|
-
{
|
|
191
|
-
addBlackHoleAddrEdge(getValueNode(&I));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/// Provide base case for our instruction visit.
|
|
195
|
-
inline void visitInstruction(Instruction&)
|
|
196
|
-
{
|
|
197
|
-
// If a new instruction is added to LLVM that we don't handle.
|
|
198
|
-
// TODO: ignore here:
|
|
199
|
-
}
|
|
200
|
-
//}@
|
|
201
|
-
|
|
202
|
-
protected:
|
|
203
|
-
/// Handle globals including (global variable and functions)
|
|
204
|
-
//@{
|
|
205
|
-
void visitGlobal(SVFModule* svfModule);
|
|
206
|
-
void InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
207
|
-
u32_t offset);
|
|
208
|
-
NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset, Type* tpy);
|
|
209
|
-
//@}
|
|
210
|
-
|
|
211
|
-
/// Process constant expression
|
|
212
|
-
void processCE(const Value* val);
|
|
213
|
-
|
|
214
|
-
/// Infer field index from byteoffset.
|
|
215
|
-
u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s32_t idx);
|
|
216
|
-
|
|
217
|
-
/// Compute offset of a gep instruction or gep constant expression
|
|
218
|
-
bool computeGepOffset(const User *V, LocationSet& ls);
|
|
219
|
-
|
|
220
|
-
/// Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst, i8* src, int size))
|
|
221
|
-
const Value* getBaseValueForExtArg(const Value* V);
|
|
222
|
-
|
|
223
|
-
/// Get the base type and max offset
|
|
224
|
-
const Type *getBaseTypeAndFlattenedFields(const Value* V, std::vector<LocationSet> &fields, const Value* sz);
|
|
225
|
-
|
|
226
|
-
/// Handle direct call
|
|
227
|
-
void handleDirectCall(CallSite cs, const SVFFunction *F);
|
|
228
|
-
|
|
229
|
-
/// Handle indirect call
|
|
230
|
-
void handleIndCall(CallSite cs);
|
|
231
|
-
|
|
232
|
-
/// Handle external call
|
|
233
|
-
//@{
|
|
234
|
-
virtual void parseOperations(std::vector<ExtAPI::Operation> &operations, CallSite cs);
|
|
235
|
-
virtual void handleExtCall(CallSite cs, const SVFFunction *F);
|
|
236
|
-
void addComplexConsForExt(const Value* D, const Value* S, const Value* sz);
|
|
237
|
-
//@}
|
|
238
|
-
|
|
239
|
-
/// Set current basic block in order to keep track of control flow information
|
|
240
|
-
inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
|
|
241
|
-
{
|
|
242
|
-
curBB = bb;
|
|
243
|
-
curVal = val;
|
|
244
|
-
}
|
|
245
|
-
inline const Value* getCurrentValue() const
|
|
246
|
-
{
|
|
247
|
-
return curVal;
|
|
248
|
-
}
|
|
249
|
-
inline const BasicBlock* getCurrentBB() const
|
|
250
|
-
{
|
|
251
|
-
return curBB;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/// Add global black hole Address edge
|
|
255
|
-
void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
|
|
256
|
-
{
|
|
257
|
-
const Value* cval = getCurrentValue();
|
|
258
|
-
const BasicBlock* cbb = getCurrentBB();
|
|
259
|
-
setCurrentLocation(int2Ptrce,nullptr);
|
|
260
|
-
addBlackHoleAddrEdge(node);
|
|
261
|
-
setCurrentLocation(cval,cbb);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/// Add NullPtr PAGNode
|
|
265
|
-
inline NodeID addNullPtrNode()
|
|
266
|
-
{
|
|
267
|
-
NodeID nullPtr = pag->addDummyValNode(pag->getNullPtr());
|
|
268
|
-
/// let all undef value or non-determined pointers points-to black hole
|
|
269
|
-
LLVMContext &cxt = LLVMModuleSet::getLLVMModuleSet()->getContext();
|
|
270
|
-
ConstantPointerNull *constNull = ConstantPointerNull::get(Type::getInt8PtrTy(cxt));
|
|
271
|
-
setCurrentLocation(constNull, nullptr);
|
|
272
|
-
addBlackHoleAddrEdge(pag->getBlkPtr());
|
|
273
|
-
return nullPtr;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
NodeID getGepValVar(const Value* val, const LocationSet& ls, const Type *baseType);
|
|
277
|
-
|
|
278
|
-
void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
|
|
279
|
-
|
|
280
|
-
inline void addBlackHoleAddrEdge(NodeID node)
|
|
281
|
-
{
|
|
282
|
-
if(PAGEdge *edge = pag->addBlackHoleAddrStmt(node))
|
|
283
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/// Add Address edge
|
|
287
|
-
inline AddrStmt* addAddrEdge(NodeID src, NodeID dst)
|
|
288
|
-
{
|
|
289
|
-
if(AddrStmt *edge = pag->addAddrStmt(src, dst))
|
|
290
|
-
{
|
|
291
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
292
|
-
return edge;
|
|
293
|
-
}
|
|
294
|
-
return nullptr;
|
|
295
|
-
}
|
|
296
|
-
/// Add Copy edge
|
|
297
|
-
inline CopyStmt* addCopyEdge(NodeID src, NodeID dst)
|
|
298
|
-
{
|
|
299
|
-
if(CopyStmt *edge = pag->addCopyStmt(src, dst))
|
|
300
|
-
{
|
|
301
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
302
|
-
return edge;
|
|
303
|
-
}
|
|
304
|
-
return nullptr;
|
|
305
|
-
}
|
|
306
|
-
/// Add Copy edge
|
|
307
|
-
inline void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
|
|
308
|
-
{
|
|
309
|
-
/// If we already added this phi node, then skip this adding
|
|
310
|
-
if(PhiStmt *edge = pag->addPhiStmt(res,opnd,pred))
|
|
311
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
312
|
-
}
|
|
313
|
-
/// Add SelectStmt
|
|
314
|
-
inline void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
|
|
315
|
-
{
|
|
316
|
-
if(SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond))
|
|
317
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
318
|
-
}
|
|
319
|
-
/// Add Copy edge
|
|
320
|
-
inline void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
|
|
321
|
-
{
|
|
322
|
-
if(CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict))
|
|
323
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
324
|
-
}
|
|
325
|
-
/// Add Copy edge
|
|
326
|
-
inline void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
|
|
327
|
-
{
|
|
328
|
-
if(BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode))
|
|
329
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
330
|
-
}
|
|
331
|
-
/// Add Unary edge
|
|
332
|
-
inline void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
|
|
333
|
-
{
|
|
334
|
-
if(UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode))
|
|
335
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
336
|
-
}
|
|
337
|
-
/// Add Branch statement
|
|
338
|
-
inline void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs)
|
|
339
|
-
{
|
|
340
|
-
if(BranchStmt *edge = pag->addBranchStmt(br, cond, succs))
|
|
341
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
342
|
-
}
|
|
343
|
-
/// Add Load edge
|
|
344
|
-
inline void addLoadEdge(NodeID src, NodeID dst)
|
|
345
|
-
{
|
|
346
|
-
if(LoadStmt *edge = pag->addLoadStmt(src, dst))
|
|
347
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
348
|
-
}
|
|
349
|
-
/// Add Store edge
|
|
350
|
-
inline void addStoreEdge(NodeID src, NodeID dst)
|
|
351
|
-
{
|
|
352
|
-
IntraICFGNode* node;
|
|
353
|
-
if(const Instruction* i = SVFUtil::dyn_cast<Instruction>(curVal))
|
|
354
|
-
{
|
|
355
|
-
const SVFInstruction* inst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(i);
|
|
356
|
-
node = pag->getICFG()->getIntraICFGNode(inst);
|
|
357
|
-
}
|
|
358
|
-
else
|
|
359
|
-
node = nullptr;
|
|
360
|
-
if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
|
|
361
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
362
|
-
}
|
|
363
|
-
/// Add Call edge
|
|
364
|
-
inline void addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
|
|
365
|
-
{
|
|
366
|
-
if(CallPE *edge = pag->addCallPE(src, dst, cs, entry))
|
|
367
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
368
|
-
}
|
|
369
|
-
/// Add Return edge
|
|
370
|
-
inline void addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
|
|
371
|
-
{
|
|
372
|
-
if(RetPE *edge = pag->addRetPE(src, dst, cs, exit))
|
|
373
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
374
|
-
}
|
|
375
|
-
/// Add Gep edge
|
|
376
|
-
inline void addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
|
|
377
|
-
{
|
|
378
|
-
if(GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep))
|
|
379
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
380
|
-
}
|
|
381
|
-
/// Add Offset(Gep) edge
|
|
382
|
-
inline void addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
|
|
383
|
-
{
|
|
384
|
-
if(GepStmt *edge = pag->addNormalGepStmt(src, dst, ls))
|
|
385
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
386
|
-
}
|
|
387
|
-
/// Add Variant(Gep) edge
|
|
388
|
-
inline void addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
|
|
389
|
-
{
|
|
390
|
-
if(GepStmt *edge = pag->addVariantGepStmt(src, dst, ls))
|
|
391
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
392
|
-
}
|
|
393
|
-
/// Add Thread fork edge for parameter passing
|
|
394
|
-
inline void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
|
|
395
|
-
{
|
|
396
|
-
if(TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry))
|
|
397
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
398
|
-
}
|
|
399
|
-
/// Add Thread join edge for parameter passing
|
|
400
|
-
inline void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
|
|
401
|
-
{
|
|
402
|
-
if(TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit))
|
|
403
|
-
setCurrentBBAndValueForPAGEdge(edge);
|
|
404
|
-
}
|
|
405
|
-
//@}
|
|
406
|
-
|
|
407
|
-
LocationSet getLocationSetFromBaseNode(NodeID nodeId);
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
} // End namespace SVF
|
|
411
|
-
|
|
412
|
-
#endif /* PAGBUILDER_H_ */
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
//===- SymbolTableBuilder.h -- Symbol Table builder-----------------------//
|
|
2
|
-
//
|
|
3
|
-
// SVF: Static Value-Flow Analysis
|
|
4
|
-
//
|
|
5
|
-
// Copyright (C) <2013-> <Yulei Sui>
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
// This program is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
|
|
13
|
-
// This program is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
//
|
|
21
|
-
//===----------------------------------------------------------------------===//
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* SymbolTableBuilder.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: Apr 28, 2014
|
|
27
|
-
* Author: Yulei
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef SymbolTableBuilder_H_
|
|
31
|
-
#define SymbolTableBuilder_H_
|
|
32
|
-
|
|
33
|
-
#include "SVF-FE/LLVMModule.h"
|
|
34
|
-
#include "MemoryModel/SymbolTableInfo.h"
|
|
35
|
-
|
|
36
|
-
/*
|
|
37
|
-
* This class is to build SymbolTableInfo, MemObjs and ObjTypeInfo
|
|
38
|
-
*/
|
|
39
|
-
namespace SVF
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
class SymbolTableBuilder
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
private:
|
|
46
|
-
SymbolTableInfo* symInfo;
|
|
47
|
-
|
|
48
|
-
public:
|
|
49
|
-
/// Constructor
|
|
50
|
-
SymbolTableBuilder(SymbolTableInfo* si): symInfo(si)
|
|
51
|
-
{
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/// Start building memory model
|
|
55
|
-
void buildMemModel(SVFModule* svfModule);
|
|
56
|
-
|
|
57
|
-
/// collect the syms
|
|
58
|
-
//@{
|
|
59
|
-
void collectNullPtrBlackholeSyms(const Value* val);
|
|
60
|
-
|
|
61
|
-
void collectSpecialSym(const Value* val);
|
|
62
|
-
|
|
63
|
-
void collectSym(const Value* val);
|
|
64
|
-
|
|
65
|
-
void collectVal(const Value* val);
|
|
66
|
-
|
|
67
|
-
void collectObj(const Value* val);
|
|
68
|
-
|
|
69
|
-
void collectRet(const Function* val);
|
|
70
|
-
|
|
71
|
-
void collectVararg(const Function* val);
|
|
72
|
-
//@}
|
|
73
|
-
|
|
74
|
-
/// Handle constant expression
|
|
75
|
-
// @{
|
|
76
|
-
void handleGlobalCE(const GlobalVariable *G);
|
|
77
|
-
void handleGlobalInitializerCE(const Constant *C);
|
|
78
|
-
void handleCE(const Value* val);
|
|
79
|
-
// @}
|
|
80
|
-
|
|
81
|
-
/// Create an objectInfo based on LLVM value
|
|
82
|
-
ObjTypeInfo* createObjTypeInfo(const Value* val);
|
|
83
|
-
|
|
84
|
-
/// Initialize TypeInfo based on LLVM Value
|
|
85
|
-
void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value);
|
|
86
|
-
/// Analyse types of all flattened fields of this object
|
|
87
|
-
void analyzeObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
88
|
-
/// Analyse types of heap and static objects
|
|
89
|
-
void analyzeHeapObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
90
|
-
/// Analyse types of heap and static objects
|
|
91
|
-
void analyzeStaticObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
92
|
-
|
|
93
|
-
/// Return size of this object based on LLVM value
|
|
94
|
-
u32_t getObjSize(const Type* type);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
} // End namespace SVF
|
|
98
|
-
|
|
99
|
-
#endif /* SymbolTableBuilder_H_ */
|