svf-lib 1.0.1277 → 1.0.1279
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-linux/Release-build/lib/libSvf.a +0 -0
- package/SVF-linux/include/DDA/DDAVFSolver.h +1 -2
- package/SVF-linux/include/Graphs/ICFG.h +16 -16
- package/SVF-linux/include/Graphs/ICFGEdge.h +6 -6
- package/SVF-linux/include/Graphs/ICFGNode.h +16 -16
- package/SVF-linux/include/Graphs/IRGraph.h +6 -6
- package/SVF-linux/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-linux/include/Graphs/VFGNode.h +1 -1
- package/SVF-linux/include/MSSA/MSSAMuChi.h +11 -11
- package/SVF-linux/include/MSSA/MemRegion.h +2 -2
- package/SVF-linux/include/MSSA/MemSSA.h +13 -13
- package/SVF-linux/include/MTA/FSMPTA.h +1 -1
- package/SVF-linux/include/MTA/LockAnalysis.h +33 -33
- package/SVF-linux/include/MTA/LockResultValidator.h +7 -6
- package/SVF-linux/include/MTA/MHP.h +46 -46
- package/SVF-linux/include/MTA/MTA.h +4 -4
- package/SVF-linux/include/MTA/MTAAnnotator.h +6 -4
- package/SVF-linux/include/MTA/MTAResultValidator.h +51 -44
- package/SVF-linux/include/MTA/PCG.h +22 -27
- package/SVF-linux/include/MTA/TCT.h +28 -37
- package/SVF-linux/include/MemoryModel/SVFStatements.h +11 -6
- package/SVF-linux/include/MemoryModel/SVFVariables.h +4 -4
- package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +13 -19
- package/SVF-linux/include/SABER/ProgSlice.h +5 -5
- package/SVF-linux/include/SABER/SaberCheckerAPI.h +4 -4
- package/SVF-linux/include/SABER/SaberCondAllocator.h +32 -35
- package/SVF-linux/include/SVF-FE/BasicTypes.h +10 -0
- package/SVF-linux/include/SVF-FE/CPPUtil.h +9 -8
- package/SVF-linux/include/SVF-FE/DCHG.h +4 -4
- package/SVF-linux/include/SVF-FE/DataFlowUtil.h +1 -1
- package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
- package/SVF-linux/include/SVF-FE/ICFGBuilder.h +9 -9
- package/SVF-linux/include/SVF-FE/IRAnnotator.h +9 -9
- package/SVF-linux/include/SVF-FE/LLVMModule.h +119 -22
- package/SVF-linux/include/SVF-FE/LLVMUtil.h +31 -52
- package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +14 -20
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +8 -8
- package/SVF-linux/include/Util/Annotator.h +22 -22
- package/SVF-linux/include/Util/BasicTypes.h +476 -72
- package/SVF-linux/include/Util/Casting.h +1 -1
- package/SVF-linux/include/Util/CxtStmt.h +13 -12
- package/SVF-linux/include/Util/SVFBasicTypes.h +0 -78
- package/SVF-linux/include/Util/SVFInstruction.h +40 -0
- package/SVF-linux/include/Util/SVFModule.h +58 -124
- package/SVF-linux/include/Util/SVFUtil.h +48 -39
- package/SVF-linux/include/Util/ThreadAPI.h +17 -28
- package/SVF-linux/include/WPA/WPAPass.h +4 -4
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/DDA/DDAVFSolver.h +1 -2
- package/SVF-osx/include/Graphs/ICFG.h +16 -16
- package/SVF-osx/include/Graphs/ICFGEdge.h +6 -6
- package/SVF-osx/include/Graphs/ICFGNode.h +16 -16
- package/SVF-osx/include/Graphs/IRGraph.h +6 -6
- package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-osx/include/Graphs/VFGNode.h +1 -1
- package/SVF-osx/include/MSSA/MSSAMuChi.h +11 -11
- package/SVF-osx/include/MSSA/MemRegion.h +2 -2
- package/SVF-osx/include/MSSA/MemSSA.h +13 -13
- package/SVF-osx/include/MTA/FSMPTA.h +1 -1
- package/SVF-osx/include/MTA/LockAnalysis.h +33 -33
- package/SVF-osx/include/MTA/LockResultValidator.h +7 -6
- package/SVF-osx/include/MTA/MHP.h +46 -46
- package/SVF-osx/include/MTA/MTA.h +4 -4
- package/SVF-osx/include/MTA/MTAAnnotator.h +6 -4
- package/SVF-osx/include/MTA/MTAResultValidator.h +51 -44
- package/SVF-osx/include/MTA/PCG.h +22 -27
- package/SVF-osx/include/MTA/TCT.h +28 -37
- package/SVF-osx/include/MemoryModel/SVFStatements.h +11 -6
- package/SVF-osx/include/MemoryModel/SVFVariables.h +4 -4
- package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +13 -19
- package/SVF-osx/include/SABER/ProgSlice.h +5 -5
- package/SVF-osx/include/SABER/SaberCheckerAPI.h +4 -4
- package/SVF-osx/include/SABER/SaberCondAllocator.h +32 -35
- package/SVF-osx/include/SVF-FE/BasicTypes.h +10 -0
- package/SVF-osx/include/SVF-FE/CPPUtil.h +9 -8
- package/SVF-osx/include/SVF-FE/DCHG.h +4 -4
- package/SVF-osx/include/SVF-FE/DataFlowUtil.h +1 -1
- package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
- package/SVF-osx/include/SVF-FE/ICFGBuilder.h +9 -9
- package/SVF-osx/include/SVF-FE/IRAnnotator.h +9 -9
- package/SVF-osx/include/SVF-FE/LLVMModule.h +119 -22
- package/SVF-osx/include/SVF-FE/LLVMUtil.h +31 -52
- package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +14 -20
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +8 -8
- package/SVF-osx/include/Util/Annotator.h +22 -22
- package/SVF-osx/include/Util/BasicTypes.h +476 -72
- package/SVF-osx/include/Util/Casting.h +1 -1
- package/SVF-osx/include/Util/CxtStmt.h +13 -12
- package/SVF-osx/include/Util/SVFBasicTypes.h +0 -78
- package/SVF-osx/include/Util/SVFInstruction.h +40 -0
- package/SVF-osx/include/Util/SVFModule.h +58 -124
- package/SVF-osx/include/Util/SVFUtil.h +48 -39
- package/SVF-osx/include/Util/ThreadAPI.h +17 -28
- package/SVF-osx/include/WPA/WPAPass.h +4 -4
- package/package.json +1 -1
|
@@ -55,7 +55,7 @@ public:
|
|
|
55
55
|
typedef Map<const SVFGNode*, Condition> SVFGNodeToCondMap; ///< map a SVFGNode to its condition during value-flow guard computation
|
|
56
56
|
|
|
57
57
|
typedef FIFOWorkList<const SVFGNode*> VFWorkList; ///< worklist for value-flow guard computation
|
|
58
|
-
typedef FIFOWorkList<const
|
|
58
|
+
typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
|
|
59
59
|
|
|
60
60
|
/// Constructor
|
|
61
61
|
ProgSlice(const SVFGNode* src, SaberCondAllocator* pa, const SVFG* graph):
|
|
@@ -246,15 +246,15 @@ protected:
|
|
|
246
246
|
|
|
247
247
|
/// Compute guards for value-flows
|
|
248
248
|
//@{
|
|
249
|
-
inline Condition ComputeIntraVFGGuard(const
|
|
249
|
+
inline Condition ComputeIntraVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst)
|
|
250
250
|
{
|
|
251
251
|
return pathAllocator->ComputeIntraVFGGuard(src,dst);
|
|
252
252
|
}
|
|
253
|
-
inline Condition ComputeInterCallVFGGuard(const
|
|
253
|
+
inline Condition ComputeInterCallVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* callBB)
|
|
254
254
|
{
|
|
255
255
|
return pathAllocator->ComputeInterCallVFGGuard(src,dst,callBB);
|
|
256
256
|
}
|
|
257
|
-
inline Condition ComputeInterRetVFGGuard(const
|
|
257
|
+
inline Condition ComputeInterRetVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* retBB)
|
|
258
258
|
{
|
|
259
259
|
return pathAllocator->ComputeInterRetVFGGuard(src,dst,retBB);
|
|
260
260
|
}
|
|
@@ -268,7 +268,7 @@ protected:
|
|
|
268
268
|
/// Return the basic block where a SVFGNode resides in
|
|
269
269
|
/// a SVFGNode may not in a basic block if it is not a program statement
|
|
270
270
|
/// (e.g. PAGEdge is an global assignment or NullPtrSVFGNode)
|
|
271
|
-
inline const
|
|
271
|
+
inline const SVFBasicBlock* getSVFGNodeBB(const SVFGNode* node) const
|
|
272
272
|
{
|
|
273
273
|
const ICFGNode* icfgNode = node->getICFGNode();
|
|
274
274
|
if(SVFUtil::isa<NullPtrSVFGNode>(node) == false)
|
|
@@ -101,7 +101,7 @@ public:
|
|
|
101
101
|
{
|
|
102
102
|
return getType(fun) == CK_ALLOC;
|
|
103
103
|
}
|
|
104
|
-
inline bool isMemAlloc(const
|
|
104
|
+
inline bool isMemAlloc(const SVFInstruction* inst) const
|
|
105
105
|
{
|
|
106
106
|
return getType(SVFUtil::getCallee(inst)) == CK_ALLOC;
|
|
107
107
|
}
|
|
@@ -117,7 +117,7 @@ public:
|
|
|
117
117
|
{
|
|
118
118
|
return getType(fun) == CK_FREE;
|
|
119
119
|
}
|
|
120
|
-
inline bool isMemDealloc(const
|
|
120
|
+
inline bool isMemDealloc(const SVFInstruction *inst) const
|
|
121
121
|
{
|
|
122
122
|
return getType(SVFUtil::getCallee(inst)) == CK_FREE;
|
|
123
123
|
}
|
|
@@ -133,7 +133,7 @@ public:
|
|
|
133
133
|
{
|
|
134
134
|
return getType(fun) == CK_FOPEN;
|
|
135
135
|
}
|
|
136
|
-
inline bool isFOpen(const
|
|
136
|
+
inline bool isFOpen(const SVFInstruction* inst) const
|
|
137
137
|
{
|
|
138
138
|
return getType(SVFUtil::getCallee(inst)) == CK_FOPEN;
|
|
139
139
|
}
|
|
@@ -149,7 +149,7 @@ public:
|
|
|
149
149
|
{
|
|
150
150
|
return getType(fun) == CK_FCLOSE;
|
|
151
151
|
}
|
|
152
|
-
inline bool isFClose(const
|
|
152
|
+
inline bool isFClose(const SVFInstruction* inst) const
|
|
153
153
|
{
|
|
154
154
|
return getType(SVFUtil::getCallee(inst)) == CK_FCLOSE;
|
|
155
155
|
}
|
|
@@ -50,13 +50,13 @@ class SaberCondAllocator
|
|
|
50
50
|
public:
|
|
51
51
|
|
|
52
52
|
typedef Z3Expr Condition; /// z3 condition
|
|
53
|
-
typedef Map<u32_t, const
|
|
53
|
+
typedef Map<u32_t, const SVFInstruction *> IndexToTermInstMap; /// id to instruction map for z3
|
|
54
54
|
typedef Map<u32_t,Condition> CondPosMap; ///< map a branch to its Condition
|
|
55
|
-
typedef Map<const
|
|
56
|
-
typedef Set<const
|
|
57
|
-
typedef Map<const
|
|
58
|
-
typedef Map<const
|
|
59
|
-
typedef FIFOWorkList<const
|
|
55
|
+
typedef Map<const SVFBasicBlock*, CondPosMap > BBCondMap; /// map bb to a Condition
|
|
56
|
+
typedef Set<const SVFBasicBlock*> BasicBlockSet;
|
|
57
|
+
typedef Map<const SVFFunction*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
|
|
58
|
+
typedef Map<const SVFBasicBlock*, Condition> BBToCondMap; ///< map a basic block to its condition during control-flow guard computation
|
|
59
|
+
typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
/// Constructor
|
|
@@ -118,21 +118,21 @@ public:
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/// Allocate a new condition
|
|
121
|
-
Condition newCond(const
|
|
121
|
+
Condition newCond(const SVFInstruction* inst);
|
|
122
122
|
|
|
123
123
|
/// Perform path allocation
|
|
124
124
|
void allocate(const SVFModule* module);
|
|
125
125
|
|
|
126
126
|
/// Get/Set instruction based on Z3 expression id
|
|
127
127
|
//{@
|
|
128
|
-
inline const
|
|
128
|
+
inline const SVFInstruction* getCondInst(u32_t id) const
|
|
129
129
|
{
|
|
130
130
|
IndexToTermInstMap::const_iterator it = idToTermInstMap.find(id);
|
|
131
131
|
assert(it != idToTermInstMap.end() && "this should be a fresh condition");
|
|
132
132
|
return it->second;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
inline void setCondInst(const Condition &condition, const
|
|
135
|
+
inline void setCondInst(const Condition &condition, const SVFInstruction* inst)
|
|
136
136
|
{
|
|
137
137
|
assert(idToTermInstMap.find(condition.id()) == idToTermInstMap.end() && "this should be a fresh condition");
|
|
138
138
|
idToTermInstMap[condition.id()] = inst;
|
|
@@ -144,38 +144,35 @@ public:
|
|
|
144
144
|
return negConds.test(id);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
inline bool postDominate(const
|
|
147
|
+
inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
148
148
|
{
|
|
149
|
-
const SVFFunction* keyFunc =
|
|
150
|
-
const SVFFunction* valueFunc =
|
|
149
|
+
const SVFFunction* keyFunc = bbKey->getParent();
|
|
150
|
+
const SVFFunction* valueFunc = bbValue->getParent();
|
|
151
151
|
bool funcEq = (keyFunc == valueFunc);
|
|
152
152
|
(void)funcEq; // Suppress warning of unused variable under release build
|
|
153
153
|
assert(funcEq && "two basicblocks should be in the same function!");
|
|
154
|
-
|
|
155
154
|
return keyFunc->postDominate(bbKey,bbValue);
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
inline bool dominate(const
|
|
157
|
+
inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
159
158
|
{
|
|
160
|
-
const SVFFunction* keyFunc =
|
|
161
|
-
const SVFFunction* valueFunc =
|
|
159
|
+
const SVFFunction* keyFunc = bbKey->getParent();
|
|
160
|
+
const SVFFunction* valueFunc = bbValue->getParent();
|
|
162
161
|
bool funcEq = (keyFunc == valueFunc);
|
|
163
162
|
(void)funcEq; // Suppress warning of unused variable under release build
|
|
164
|
-
|
|
165
163
|
assert(funcEq && "two basicblocks should be in the same function!");
|
|
166
|
-
|
|
167
164
|
return keyFunc->dominate(bbKey,bbValue);
|
|
168
165
|
}
|
|
169
166
|
|
|
170
167
|
/// Guard Computation for a value-flow (between two basic blocks)
|
|
171
168
|
//@{
|
|
172
|
-
virtual Condition ComputeIntraVFGGuard(const
|
|
173
|
-
virtual Condition ComputeInterCallVFGGuard(const
|
|
174
|
-
virtual Condition ComputeInterRetVFGGuard(const
|
|
169
|
+
virtual Condition ComputeIntraVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst);
|
|
170
|
+
virtual Condition ComputeInterCallVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* callBB);
|
|
171
|
+
virtual Condition ComputeInterRetVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* retBB);
|
|
175
172
|
|
|
176
173
|
/// Get complement condition (from B1 to B0) according to a complementBB (BB2) at a phi
|
|
177
174
|
/// e.g., B0: dstBB; B1:incomingBB; B2:complementBB
|
|
178
|
-
virtual Condition getPHIComplementCond(const
|
|
175
|
+
virtual Condition getPHIComplementCond(const SVFBasicBlock* BB1, const SVFBasicBlock* BB2, const SVFBasicBlock* BB0);
|
|
179
176
|
|
|
180
177
|
inline void clearCFCond()
|
|
181
178
|
{
|
|
@@ -215,7 +212,7 @@ public:
|
|
|
215
212
|
|
|
216
213
|
/// Get/Set control-flow conditions
|
|
217
214
|
//@{
|
|
218
|
-
inline bool setCFCond(const
|
|
215
|
+
inline bool setCFCond(const SVFBasicBlock* bb, const Condition& cond)
|
|
219
216
|
{
|
|
220
217
|
BBToCondMap::iterator it = bbToCondMap.find(bb);
|
|
221
218
|
// until a fixed-point is reached (condition is not changed)
|
|
@@ -225,7 +222,7 @@ public:
|
|
|
225
222
|
bbToCondMap[bb] = cond;
|
|
226
223
|
return true;
|
|
227
224
|
}
|
|
228
|
-
inline Condition getCFCond(const
|
|
225
|
+
inline Condition getCFCond(const SVFBasicBlock* bb) const
|
|
229
226
|
{
|
|
230
227
|
BBToCondMap::const_iterator it = bbToCondMap.find(bb);
|
|
231
228
|
if(it==bbToCondMap.end())
|
|
@@ -238,7 +235,7 @@ public:
|
|
|
238
235
|
|
|
239
236
|
|
|
240
237
|
/// mark neg Z3 expression
|
|
241
|
-
inline void setNegCondInst(const Condition &condition, const
|
|
238
|
+
inline void setNegCondInst(const Condition &condition, const SVFInstruction* inst)
|
|
242
239
|
{
|
|
243
240
|
setCondInst(condition, inst);
|
|
244
241
|
negConds.set(condition.id());
|
|
@@ -246,30 +243,30 @@ public:
|
|
|
246
243
|
private:
|
|
247
244
|
|
|
248
245
|
/// Allocate path condition for every basic block
|
|
249
|
-
virtual void allocateForBB(const
|
|
246
|
+
virtual void allocateForBB(const SVFBasicBlock& bb);
|
|
250
247
|
|
|
251
248
|
/// Get/Set a branch condition, and its terminator instruction
|
|
252
249
|
//@{
|
|
253
250
|
/// Set branch condition
|
|
254
|
-
void setBranchCond(const
|
|
251
|
+
void setBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ, const Condition& cond);
|
|
255
252
|
/// Get branch condition
|
|
256
|
-
Condition getBranchCond(const
|
|
253
|
+
Condition getBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ) const;
|
|
257
254
|
///Get a condition, evaluate the value for conditions if necessary (e.g., testNull like express)
|
|
258
|
-
Condition getEvalBrCond(const
|
|
255
|
+
Condition getEvalBrCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ);
|
|
259
256
|
//@}
|
|
260
257
|
/// Evaluate branch conditions
|
|
261
258
|
//@{
|
|
262
259
|
/// Evaluate the branch condtion
|
|
263
|
-
Condition evaluateBranchCond(const
|
|
260
|
+
Condition evaluateBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ) ;
|
|
264
261
|
/// Evaluate loop exit branch
|
|
265
|
-
Condition evaluateLoopExitBranch(const
|
|
262
|
+
Condition evaluateLoopExitBranch(const SVFBasicBlock* bb, const SVFBasicBlock* succ);
|
|
266
263
|
/// Return branch condition after evaluating test null like expression
|
|
267
|
-
Condition evaluateTestNullLikeExpr(const BranchStmt* branchStmt, const
|
|
264
|
+
Condition evaluateTestNullLikeExpr(const BranchStmt* branchStmt, const SVFBasicBlock* succ);
|
|
268
265
|
/// Return condition when there is a branch calls program exit
|
|
269
|
-
Condition evaluateProgExit(const BranchStmt* branchStmt, const
|
|
266
|
+
Condition evaluateProgExit(const BranchStmt* branchStmt, const SVFBasicBlock* succ);
|
|
270
267
|
/// Collect basic block contains program exit function call
|
|
271
|
-
void collectBBCallingProgExit(const
|
|
272
|
-
bool isBBCallsProgExit(const
|
|
268
|
+
void collectBBCallingProgExit(const SVFBasicBlock& bb);
|
|
269
|
+
bool isBBCallsProgExit(const SVFBasicBlock* bb);
|
|
273
270
|
//@}
|
|
274
271
|
|
|
275
272
|
/// Evaluate test null/not null like expressions
|
|
@@ -88,6 +88,9 @@ typedef llvm::LoopInfo LoopInfo;
|
|
|
88
88
|
typedef llvm::User User;
|
|
89
89
|
|
|
90
90
|
// LLVM Instructions
|
|
91
|
+
typedef llvm::CallInst CallInst;
|
|
92
|
+
typedef llvm::StoreInst StoreInst;
|
|
93
|
+
typedef llvm::LoadInst LoadInst;
|
|
91
94
|
typedef llvm::AllocaInst AllocaInst;
|
|
92
95
|
typedef llvm::AtomicCmpXchgInst AtomicCmpXchgInst;
|
|
93
96
|
typedef llvm::AtomicRMWInst AtomicRMWInst;
|
|
@@ -183,6 +186,7 @@ namespace dwarf = llvm::dwarf;
|
|
|
183
186
|
|
|
184
187
|
// Iterators.
|
|
185
188
|
typedef llvm::inst_iterator inst_iterator;
|
|
189
|
+
typedef llvm::const_inst_iterator const_inst_iterator;
|
|
186
190
|
typedef llvm::gep_type_iterator gep_type_iterator;
|
|
187
191
|
typedef llvm::bridge_gep_iterator bridge_gep_iterator;
|
|
188
192
|
typedef llvm::const_inst_iterator const_inst_iterator;
|
|
@@ -204,6 +208,12 @@ typedef llvm::VectorType VectorType;
|
|
|
204
208
|
typedef llvm::FunctionCallee FunctionCallee;
|
|
205
209
|
#endif
|
|
206
210
|
|
|
211
|
+
/// LLVM Iterators
|
|
212
|
+
#if LLVM_VERSION_MAJOR >= 11
|
|
213
|
+
typedef llvm::const_succ_iterator succ_const_iterator;
|
|
214
|
+
#else
|
|
215
|
+
typedef llvm::succ_const_iterator succ_const_iterator;
|
|
216
|
+
#endif
|
|
207
217
|
} // End namespace SVF
|
|
208
218
|
|
|
209
219
|
#endif // SVF_FE_BASIC_TYPES_H
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
#define CPPUtil_H_
|
|
32
32
|
|
|
33
33
|
#include "Util/BasicTypes.h"
|
|
34
|
+
#include "SVF-FE/BasicTypes.h"
|
|
34
35
|
|
|
35
36
|
namespace SVF
|
|
36
37
|
{
|
|
@@ -53,13 +54,13 @@ struct DemangledName
|
|
|
53
54
|
struct DemangledName demangle(const std::string &name);
|
|
54
55
|
|
|
55
56
|
std::string getBeforeBrackets(const std::string &name);
|
|
56
|
-
bool isValVtbl(const Value
|
|
57
|
+
bool isValVtbl(const Value* val);
|
|
57
58
|
bool isLoadVtblInst(const LoadInst *loadInst);
|
|
58
59
|
bool isVirtualCallSite(CallSite cs);
|
|
59
|
-
bool isConstructor(const Function
|
|
60
|
-
bool isDestructor(const Function
|
|
61
|
-
bool isCPPThunkFunction(const Function
|
|
62
|
-
const Function
|
|
60
|
+
bool isConstructor(const Function* F);
|
|
61
|
+
bool isDestructor(const Function* F);
|
|
62
|
+
bool isCPPThunkFunction(const Function* F);
|
|
63
|
+
const Function* getThunkTarget(const Function* F);
|
|
63
64
|
|
|
64
65
|
/*
|
|
65
66
|
* VtableA = {&A::foo}
|
|
@@ -83,10 +84,10 @@ const Function *getThunkTarget(const Function *F);
|
|
|
83
84
|
* getClassNameFromType(type of p) return type A
|
|
84
85
|
*/
|
|
85
86
|
const Argument* getConstructorThisPtr(const Function* fun);
|
|
86
|
-
const Value
|
|
87
|
-
const Value
|
|
87
|
+
const Value* getVCallThisPtr(CallSite cs);
|
|
88
|
+
const Value* getVCallVtblPtr(CallSite cs);
|
|
88
89
|
u64_t getVCallIdx(CallSite cs);
|
|
89
|
-
std::string getClassNameFromVtblObj(const Value
|
|
90
|
+
std::string getClassNameFromVtblObj(const Value* value);
|
|
90
91
|
std::string getClassNameFromType(const Type *ty);
|
|
91
92
|
std::string getClassNameOfThisPtr(CallSite cs);
|
|
92
93
|
std::string getFunNameOfVCallSite(CallSite cs);
|
|
@@ -172,13 +172,13 @@ public:
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/// Returns the vector of virtual function vectors.
|
|
175
|
-
const std::vector<std::vector<const Function
|
|
175
|
+
const std::vector<std::vector<const Function* >> &getVfnVectors(void) const
|
|
176
176
|
{
|
|
177
177
|
return vfnVectors;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
/// Return the nth virtual function vector in the vtable.
|
|
181
|
-
std::vector<const Function
|
|
181
|
+
std::vector<const Function* > &getVfnVector(unsigned n)
|
|
182
182
|
{
|
|
183
183
|
if (vfnVectors.size() < n + 1)
|
|
184
184
|
{
|
|
@@ -197,7 +197,7 @@ private:
|
|
|
197
197
|
std::string typeName;
|
|
198
198
|
size_t flags;
|
|
199
199
|
/// The virtual functions which this class actually defines/overrides.
|
|
200
|
-
std::vector<const Function
|
|
200
|
+
std::vector<const Function* > primaryVTable;
|
|
201
201
|
/// If a vtable is split into more than one vfn vector for multiple inheritance,
|
|
202
202
|
/// 0 would be the primary base + this classes virtual functions, 1 would be
|
|
203
203
|
/// the second parent, 2 would be third parent, etc.
|
|
@@ -406,7 +406,7 @@ private:
|
|
|
406
406
|
/// Retrieves the metadata associated with a *virtual* callsite.
|
|
407
407
|
const DIType *getCSStaticType(CallSite cs) const
|
|
408
408
|
{
|
|
409
|
-
MDNode *md = cs.getInstruction()->getMetadata(cppUtil::ctir::derefMDName);
|
|
409
|
+
MDNode *md = cs.getInstruction()->getLLVMInstruction()->getMetadata(cppUtil::ctir::derefMDName);
|
|
410
410
|
assert(md != nullptr && "Missing type metadata at virtual callsite");
|
|
411
411
|
DIType *diType = SVFUtil::dyn_cast<DIType>(md);
|
|
412
412
|
assert(diType != nullptr && "Incorrect metadata type at virtual callsite");
|
|
@@ -41,14 +41,14 @@ class ICFGBuilder
|
|
|
41
41
|
|
|
42
42
|
public:
|
|
43
43
|
|
|
44
|
-
typedef std::vector<const
|
|
45
|
-
typedef Set<const
|
|
44
|
+
typedef std::vector<const SVFInstruction*> InstVec;
|
|
45
|
+
typedef Set<const SVFInstruction*> BBSet;
|
|
46
46
|
|
|
47
47
|
private:
|
|
48
48
|
ICFG* icfg;
|
|
49
49
|
|
|
50
50
|
public:
|
|
51
|
-
typedef FIFOWorkList<const
|
|
51
|
+
typedef FIFOWorkList<const SVFInstruction*> WorkList;
|
|
52
52
|
|
|
53
53
|
ICFGBuilder(ICFG* i): icfg(i)
|
|
54
54
|
{
|
|
@@ -69,10 +69,10 @@ private:
|
|
|
69
69
|
void connectGlobalToProgEntry(SVFModule* svfModule);
|
|
70
70
|
|
|
71
71
|
/// Add/Get an inter block ICFGNode
|
|
72
|
-
InterICFGNode* getOrAddInterBlockICFGNode(const
|
|
72
|
+
InterICFGNode* getOrAddInterBlockICFGNode(const SVFInstruction* inst);
|
|
73
73
|
|
|
74
74
|
/// Add/Get a basic block ICFGNode
|
|
75
|
-
inline ICFGNode* getOrAddBlockICFGNode(const
|
|
75
|
+
inline ICFGNode* getOrAddBlockICFGNode(const SVFInstruction* inst)
|
|
76
76
|
{
|
|
77
77
|
if(SVFUtil::isNonInstricCallSite(inst))
|
|
78
78
|
return getOrAddInterBlockICFGNode(inst);
|
|
@@ -81,21 +81,21 @@ private:
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/// Create edges between ICFG nodes across functions
|
|
84
|
-
void addICFGInterEdges(const
|
|
84
|
+
void addICFGInterEdges(const SVFInstruction* cs, const SVFFunction* callee);
|
|
85
85
|
|
|
86
86
|
/// Add a call node
|
|
87
|
-
inline CallICFGNode* getCallICFGNode(const
|
|
87
|
+
inline CallICFGNode* getCallICFGNode(const SVFInstruction* cs)
|
|
88
88
|
{
|
|
89
89
|
return icfg->getCallICFGNode(cs);
|
|
90
90
|
}
|
|
91
91
|
/// Add a return node
|
|
92
|
-
inline RetICFGNode* getRetICFGNode(const
|
|
92
|
+
inline RetICFGNode* getRetICFGNode(const SVFInstruction* cs)
|
|
93
93
|
{
|
|
94
94
|
return icfg->getRetICFGNode(cs);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/// Add and get IntraBlock ICFGNode
|
|
98
|
-
IntraICFGNode* getOrAddIntraBlockICFGNode(const
|
|
98
|
+
IntraICFGNode* getOrAddIntraBlockICFGNode(const SVFInstruction* inst)
|
|
99
99
|
{
|
|
100
100
|
return icfg->getIntraICFGNode(inst);
|
|
101
101
|
}
|
|
@@ -108,17 +108,17 @@ private:
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// Deduce the LLVM value's type, and process the metadata accordingly
|
|
111
|
-
void processPAGNode(const Value
|
|
111
|
+
void processPAGNode(const Value* value, SVF::NodeID nodeId, bool writeFlag)
|
|
112
112
|
{
|
|
113
|
-
if (auto instruction = const_cast<Instruction
|
|
113
|
+
if (auto instruction = const_cast<Instruction* >(SVFUtil::dyn_cast<Instruction>(value)))
|
|
114
114
|
{
|
|
115
115
|
processInstructionNode(instruction, nodeId, writeFlag);
|
|
116
116
|
}
|
|
117
|
-
else if (auto argument = const_cast<Argument
|
|
117
|
+
else if (auto argument = const_cast<Argument* >(SVFUtil::dyn_cast<Argument>(value)))
|
|
118
118
|
{
|
|
119
119
|
processArgumentNode(argument, nodeId, writeFlag);
|
|
120
120
|
}
|
|
121
|
-
else if (auto function = const_cast<Function
|
|
121
|
+
else if (auto function = const_cast<Function* >(SVFUtil::dyn_cast<Function>(value)))
|
|
122
122
|
{
|
|
123
123
|
processFunctionNode(function, nodeId, writeFlag);
|
|
124
124
|
}
|
|
@@ -126,7 +126,7 @@ private:
|
|
|
126
126
|
{
|
|
127
127
|
processGlobalVarNode(globalVar, nodeId, writeFlag);
|
|
128
128
|
}
|
|
129
|
-
else if (auto basicBlock = const_cast<BasicBlock
|
|
129
|
+
else if (auto basicBlock = const_cast<BasicBlock* >(SVFUtil::dyn_cast<BasicBlock>(value)))
|
|
130
130
|
{
|
|
131
131
|
processBasicBlockNode(basicBlock, nodeId, writeFlag);
|
|
132
132
|
}
|
|
@@ -145,7 +145,7 @@ private:
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
void processInstructionNode(Instruction
|
|
148
|
+
void processInstructionNode(Instruction* instruction, const SVF::NodeID &nodeId, bool writeFlag)
|
|
149
149
|
{
|
|
150
150
|
std::string label = "inode-" + std::to_string(nodeId);
|
|
151
151
|
|
|
@@ -163,7 +163,7 @@ private:
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
void processArgumentNode(Argument
|
|
166
|
+
void processArgumentNode(Argument* argument, const SVF::NodeID &nodeId, bool writeFlag)
|
|
167
167
|
{
|
|
168
168
|
std::string label = "anode-" + std::to_string(nodeId);
|
|
169
169
|
|
|
@@ -181,7 +181,7 @@ private:
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
void processFunctionNode(Function
|
|
184
|
+
void processFunctionNode(Function* function, const SVF::NodeID &nodeId, bool writeFlag)
|
|
185
185
|
{
|
|
186
186
|
std::string label = "fnode-" + std::to_string(nodeId);
|
|
187
187
|
|
|
@@ -217,7 +217,7 @@ private:
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
void processBasicBlockNode(BasicBlock
|
|
220
|
+
void processBasicBlockNode(BasicBlock* basicBlock, const SVF::NodeID &nodeId, bool writeFlag)
|
|
221
221
|
{
|
|
222
222
|
std::string label = "bnode-" + std::to_string(nodeId);
|
|
223
223
|
|