svf-tools 1.0.1042 → 1.0.1044
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/include/AE/Svfexe/AbstractInterpretation.h +2 -2
- package/svf/include/CFL/CFLAlias.h +1 -1
- package/svf/include/DDA/ContextDDA.h +6 -6
- package/svf/include/DDA/DDAClient.h +6 -11
- package/svf/include/DDA/DDAPass.h +1 -1
- package/svf/include/DDA/DDAVFSolver.h +2 -2
- package/svf/include/DDA/FlowDDA.h +2 -2
- package/svf/include/Graphs/BasicBlockG.h +17 -9
- package/svf/include/Graphs/CHG.h +9 -10
- package/svf/include/Graphs/CallGraph.h +23 -27
- package/svf/include/Graphs/ConsG.h +2 -2
- package/svf/include/Graphs/GenericGraph.h +1 -286
- package/svf/include/Graphs/ICFG.h +11 -11
- package/svf/include/Graphs/ICFGNode.h +12 -18
- package/svf/include/Graphs/IRGraph.h +11 -9
- package/svf/include/Graphs/SVFG.h +13 -13
- package/svf/include/Graphs/SVFGNode.h +2 -2
- package/svf/include/Graphs/ThreadCallGraph.h +3 -21
- package/svf/include/Graphs/VFG.h +15 -15
- package/svf/include/Graphs/VFGNode.h +10 -10
- package/svf/include/MSSA/MSSAMuChi.h +6 -6
- package/svf/include/MSSA/MemPartition.h +12 -12
- package/svf/include/MSSA/MemRegion.h +21 -21
- package/svf/include/MSSA/MemSSA.h +10 -10
- package/svf/include/MTA/LockAnalysis.h +4 -4
- package/svf/include/MTA/MHP.h +8 -8
- package/svf/include/MTA/MTA.h +2 -2
- package/svf/include/MTA/TCT.h +10 -16
- package/svf/include/MemoryModel/PointerAnalysis.h +5 -11
- package/svf/include/SABER/DoubleFreeChecker.h +3 -3
- package/svf/include/SABER/FileChecker.h +3 -3
- package/svf/include/SABER/LeakChecker.h +5 -5
- package/svf/include/SABER/SaberCheckerAPI.h +6 -5
- package/svf/include/SABER/SaberCondAllocator.h +6 -7
- package/svf/include/SABER/SrcSnkDDA.h +4 -4
- package/svf/include/SVFIR/ObjTypeInfo.h +0 -1
- package/svf/include/SVFIR/SVFIR.h +58 -38
- package/svf/include/SVFIR/SVFStatements.h +1 -0
- package/svf/include/SVFIR/SVFValue.h +202 -798
- package/svf/include/SVFIR/SVFVariables.h +271 -71
- package/svf/include/Util/CDGBuilder.h +2 -2
- package/svf/include/Util/CallGraphBuilder.h +1 -1
- package/svf/include/Util/CxtStmt.h +6 -6
- package/svf/include/Util/ExtAPI.h +20 -16
- package/svf/include/Util/GeneralType.h +1 -0
- package/svf/include/Util/SVFLoopAndDomInfo.h +169 -0
- package/svf/include/Util/SVFUtil.h +19 -31
- package/svf/include/Util/ThreadAPI.h +4 -12
- package/svf/include/WPA/Andersen.h +2 -2
- package/svf/include/WPA/FlowSensitive.h +1 -1
- package/svf/lib/AE/Svfexe/AEDetector.cpp +1 -1
- package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +3 -3
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +6 -6
- package/svf/lib/CFL/CFLAlias.cpp +1 -1
- package/svf/lib/DDA/ContextDDA.cpp +5 -5
- package/svf/lib/DDA/DDAClient.cpp +2 -2
- package/svf/lib/DDA/DDAPass.cpp +13 -13
- package/svf/lib/DDA/FlowDDA.cpp +5 -5
- package/svf/lib/Graphs/CHG.cpp +2 -2
- package/svf/lib/Graphs/CallGraph.cpp +21 -11
- package/svf/lib/Graphs/ConsG.cpp +1 -1
- package/svf/lib/Graphs/ICFG.cpp +15 -7
- package/svf/lib/Graphs/IRGraph.cpp +7 -7
- package/svf/lib/Graphs/SVFG.cpp +5 -5
- package/svf/lib/Graphs/SVFGReadWrite.cpp +0 -1
- package/svf/lib/Graphs/ThreadCallGraph.cpp +26 -6
- package/svf/lib/Graphs/VFG.cpp +6 -7
- package/svf/lib/MSSA/MemPartition.cpp +8 -8
- package/svf/lib/MSSA/MemRegion.cpp +13 -14
- package/svf/lib/MSSA/MemSSA.cpp +9 -8
- package/svf/lib/MSSA/SVFGBuilder.cpp +1 -2
- package/svf/lib/MTA/LockAnalysis.cpp +13 -12
- package/svf/lib/MTA/MHP.cpp +12 -12
- package/svf/lib/MTA/MTA.cpp +6 -5
- package/svf/lib/MTA/MTAStat.cpp +4 -3
- package/svf/lib/MTA/TCT.cpp +18 -18
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +12 -13
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +2 -2
- package/svf/lib/SABER/DoubleFreeChecker.cpp +3 -3
- package/svf/lib/SABER/LeakChecker.cpp +5 -5
- package/svf/lib/SABER/SaberCondAllocator.cpp +7 -7
- package/svf/lib/SABER/SaberSVFGBuilder.cpp +1 -1
- package/svf/lib/SABER/SrcSnkDDA.cpp +4 -4
- package/svf/lib/SVFIR/SVFIR.cpp +17 -3
- package/svf/lib/SVFIR/SVFValue.cpp +2 -58
- package/svf/lib/SVFIR/SVFVariables.cpp +50 -19
- package/svf/lib/Util/CDGBuilder.cpp +6 -7
- package/svf/lib/Util/CallGraphBuilder.cpp +3 -3
- package/svf/lib/Util/ExtAPI.cpp +28 -29
- package/svf/lib/Util/SVFBugReport.cpp +1 -1
- package/svf/lib/Util/SVFStat.cpp +3 -3
- package/svf/lib/Util/SVFUtil.cpp +22 -4
- package/svf/lib/Util/ThreadAPI.cpp +17 -5
- package/svf/lib/WPA/Andersen.cpp +2 -2
- package/svf/lib/WPA/FlowSensitive.cpp +2 -3
- package/svf/lib/WPA/TypeAnalysis.cpp +3 -3
- package/svf/lib/WPA/VersionedFlowSensitive.cpp +1 -1
- package/svf/lib/WPA/WPAPass.cpp +2 -3
- package/svf-llvm/include/SVF-LLVM/BreakConstantExpr.h +1 -1
- package/svf-llvm/include/SVF-LLVM/CppUtil.h +1 -1
- package/svf-llvm/include/SVF-LLVM/DCHG.h +1 -1
- package/svf-llvm/include/SVF-LLVM/LLVMLoopAnalysis.h +1 -1
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +85 -9
- package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +10 -2
- package/svf-llvm/include/SVF-LLVM/ObjTypeInference.h +1 -1
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +5 -2
- package/{svf/include/SVFIR → svf-llvm/include/SVF-LLVM}/SVFModule.h +1 -36
- package/svf-llvm/include/SVF-LLVM/SVFValue.h +805 -0
- package/svf-llvm/lib/CHGBuilder.cpp +13 -13
- package/svf-llvm/lib/DCHG.cpp +3 -3
- package/svf-llvm/lib/ICFGBuilder.cpp +8 -8
- package/svf-llvm/lib/LLVMLoopAnalysis.cpp +3 -3
- package/svf-llvm/lib/LLVMModule.cpp +136 -17
- package/svf-llvm/lib/LLVMUtil.cpp +34 -9
- package/svf-llvm/lib/SVFIRBuilder.cpp +189 -108
- package/svf-llvm/lib/SVFIRExtAPI.cpp +4 -4
- package/{svf/lib/SVFIR → svf-llvm/lib}/SVFModule.cpp +1 -2
- package/svf-llvm/lib/SVFValue.cpp +71 -0
- package/svf-llvm/lib/SymbolTableBuilder.cpp +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1044",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -251,8 +251,8 @@ private:
|
|
|
251
251
|
AEStat* stat;
|
|
252
252
|
|
|
253
253
|
std::vector<const CallICFGNode*> callSiteStack;
|
|
254
|
-
Map<const
|
|
255
|
-
Set<const
|
|
254
|
+
Map<const FunObjVar*, ICFGWTO*> funcToWTO;
|
|
255
|
+
Set<const FunObjVar*> recursiveFuns;
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
AbstractState& getAbsStateFromTrace(const ICFGNode* node)
|
|
@@ -135,7 +135,7 @@ public:
|
|
|
135
135
|
virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap& callsites, CallEdgeMap& newEdges);
|
|
136
136
|
|
|
137
137
|
/// Connect formal and actual parameters for indirect callsites
|
|
138
|
-
void connectCaller2CalleeParams(const CallICFGNode* cs, const
|
|
138
|
+
void connectCaller2CalleeParams(const CallICFGNode* cs, const FunObjVar* F);
|
|
139
139
|
|
|
140
140
|
void heapAllocatorViaIndCall(const CallICFGNode* cs);
|
|
141
141
|
|
|
@@ -110,7 +110,7 @@ public:
|
|
|
110
110
|
virtual bool isHeapCondMemObj(const CxtVar& var, const StoreSVFGNode* store) override;
|
|
111
111
|
|
|
112
112
|
/// refine indirect call edge
|
|
113
|
-
bool testIndCallReachability(CxtLocDPItem& dpm, const
|
|
113
|
+
bool testIndCallReachability(CxtLocDPItem& dpm, const FunObjVar* callee, const CallICFGNode* cs);
|
|
114
114
|
|
|
115
115
|
/// get callsite id from call, return 0 if it is a spurious call edge
|
|
116
116
|
CallSiteID getCSIDAtCall(CxtLocDPItem& dpm, const SVFGEdge* edge);
|
|
@@ -133,8 +133,8 @@ public:
|
|
|
133
133
|
/// Whether call/return inside recursion
|
|
134
134
|
inline virtual bool isEdgeInRecursion(CallSiteID csId)
|
|
135
135
|
{
|
|
136
|
-
const
|
|
137
|
-
const
|
|
136
|
+
const FunObjVar* caller = getCallGraph()->getCallerOfCallSite(csId);
|
|
137
|
+
const FunObjVar* callee = getCallGraph()->getCalleeOfCallSite(csId);
|
|
138
138
|
return inSameCallGraphSCC(caller, callee);
|
|
139
139
|
}
|
|
140
140
|
/// Update call graph.
|
|
@@ -149,7 +149,7 @@ public:
|
|
|
149
149
|
const FunctionSet & functions = iter->second;
|
|
150
150
|
for (FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
|
|
151
151
|
{
|
|
152
|
-
const
|
|
152
|
+
const FunObjVar* func = *func_iter;
|
|
153
153
|
getSVFG()->connectCallerAndCallee(newcs, func, svfgEdges);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -159,8 +159,8 @@ public:
|
|
|
159
159
|
/// Return TRUE if this edge is inside a SVFG SCC, i.e., src node and dst node are in the same SCC on the SVFG.
|
|
160
160
|
inline bool edgeInCallGraphSCC(const SVFGEdge* edge)
|
|
161
161
|
{
|
|
162
|
-
const
|
|
163
|
-
const
|
|
162
|
+
const FunObjVar* srcfun = edge->getSrcNode()->getFun();
|
|
163
|
+
const FunObjVar* dstfun = edge->getDstNode()->getFun();
|
|
164
164
|
|
|
165
165
|
if(srcfun && dstfun)
|
|
166
166
|
return inSameCallGraphSCC(srcfun,dstfun);
|
|
@@ -48,11 +48,11 @@ namespace SVF
|
|
|
48
48
|
class DDAClient
|
|
49
49
|
{
|
|
50
50
|
public:
|
|
51
|
-
DDAClient(
|
|
51
|
+
DDAClient() : pag(nullptr), curPtr(0), solveAll(true) {}
|
|
52
52
|
|
|
53
53
|
virtual ~DDAClient() {}
|
|
54
54
|
|
|
55
|
-
virtual inline void initialise(
|
|
55
|
+
virtual inline void initialise() {}
|
|
56
56
|
|
|
57
57
|
/// Collect candidate pointers for query.
|
|
58
58
|
virtual inline OrderedNodeSet& collectCandidateQueries(SVFIR* p)
|
|
@@ -91,16 +91,12 @@ public:
|
|
|
91
91
|
userInput.insert(ptr);
|
|
92
92
|
solveAll = false;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
inline SVFModule* getModule() const
|
|
96
|
-
{
|
|
97
|
-
return module;
|
|
98
|
-
}
|
|
94
|
+
|
|
99
95
|
virtual void answerQueries(PointerAnalysis* pta);
|
|
100
96
|
|
|
101
97
|
virtual inline void performStat(PointerAnalysis*) {}
|
|
102
98
|
|
|
103
|
-
virtual inline void collectWPANum(
|
|
99
|
+
virtual inline void collectWPANum() {}
|
|
104
100
|
protected:
|
|
105
101
|
void addCandidate(NodeID id)
|
|
106
102
|
{
|
|
@@ -109,7 +105,6 @@ protected:
|
|
|
109
105
|
}
|
|
110
106
|
|
|
111
107
|
SVFIR* pag; ///< SVFIR graph used by current DDA analysis
|
|
112
|
-
SVFModule* module; ///< LLVM module
|
|
113
108
|
NodeID curPtr; ///< current pointer being queried
|
|
114
109
|
OrderedNodeSet candidateQueries; ///< store all candidate pointers to be queried
|
|
115
110
|
|
|
@@ -128,7 +123,7 @@ private:
|
|
|
128
123
|
typedef OrderedMap<NodeID,const CallICFGNode*> VTablePtrToCallSiteMap;
|
|
129
124
|
VTablePtrToCallSiteMap vtableToCallSiteMap;
|
|
130
125
|
public:
|
|
131
|
-
FunptrDDAClient(
|
|
126
|
+
FunptrDDAClient() : DDAClient() {}
|
|
132
127
|
~FunptrDDAClient() {}
|
|
133
128
|
|
|
134
129
|
/// Only collect function pointers as query candidates.
|
|
@@ -147,7 +142,7 @@ class AliasDDAClient : public DDAClient
|
|
|
147
142
|
public:
|
|
148
143
|
typedef OrderedSet<const PAGNode*> PAGNodeSet;
|
|
149
144
|
|
|
150
|
-
AliasDDAClient(
|
|
145
|
+
AliasDDAClient() : DDAClient() {}
|
|
151
146
|
~AliasDDAClient() {}
|
|
152
147
|
|
|
153
148
|
/// Only collect function pointers as query candidates.
|
|
@@ -475,7 +475,7 @@ protected:
|
|
|
475
475
|
assert(baseObj && "base object is null??");
|
|
476
476
|
if(SVFUtil::isa<StackObjVar>(baseObj))
|
|
477
477
|
{
|
|
478
|
-
if(const
|
|
478
|
+
if(const FunObjVar* svffun = _pag->getGNode(id)->getFunction())
|
|
479
479
|
{
|
|
480
480
|
return _callGraphSCC->isInCycle(_callGraph->getCallGraphNode(svffun)->getId());
|
|
481
481
|
}
|
|
@@ -501,7 +501,7 @@ protected:
|
|
|
501
501
|
findPT(funPtrDpm);
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
else if(const
|
|
504
|
+
else if(const FunObjVar* fun = getSVFG()->isFunEntrySVFGNode(dpm.getLoc()))
|
|
505
505
|
{
|
|
506
506
|
CallInstSet csSet;
|
|
507
507
|
/// use pre-analysis call graph to approximate all potential callsites
|
|
@@ -80,7 +80,7 @@ public:
|
|
|
80
80
|
virtual bool handleBKCondition(LocDPItem& dpm, const SVFGEdge* edge) override;
|
|
81
81
|
|
|
82
82
|
/// refine indirect call edge
|
|
83
|
-
bool testIndCallReachability(LocDPItem& dpm, const
|
|
83
|
+
bool testIndCallReachability(LocDPItem& dpm, const FunObjVar* callee, CallSiteID csId);
|
|
84
84
|
|
|
85
85
|
/// Initialization of the analysis
|
|
86
86
|
inline virtual void initialize() override
|
|
@@ -142,7 +142,7 @@ public:
|
|
|
142
142
|
const FunctionSet & functions = iter->second;
|
|
143
143
|
for (FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
|
|
144
144
|
{
|
|
145
|
-
const
|
|
145
|
+
const FunObjVar* func = *func_iter;
|
|
146
146
|
getSVFG()->connectCallerAndCallee(newcs, func, svfgEdges);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
@@ -39,7 +39,8 @@ namespace SVF
|
|
|
39
39
|
class SVFBasicBlock;
|
|
40
40
|
class BasicBlockEdge;
|
|
41
41
|
class ICFGNode;
|
|
42
|
-
class
|
|
42
|
+
class FunObjVar;
|
|
43
|
+
|
|
43
44
|
typedef GenericEdge<SVFBasicBlock> GenericBasicBlockEdgeTy;
|
|
44
45
|
class BasicBlockEdge: public GenericBasicBlockEdgeTy
|
|
45
46
|
{
|
|
@@ -75,7 +76,7 @@ class SVFBasicBlock : public GenericBasicBlockNodeTy
|
|
|
75
76
|
friend class SVFIRWriter;
|
|
76
77
|
friend class SVFIRReader;
|
|
77
78
|
friend class SVFIRBuilder;
|
|
78
|
-
friend class
|
|
79
|
+
friend class FunObjVar;
|
|
79
80
|
friend class ICFGBuilder;
|
|
80
81
|
friend class ICFG;
|
|
81
82
|
|
|
@@ -86,7 +87,7 @@ public:
|
|
|
86
87
|
|
|
87
88
|
private:
|
|
88
89
|
std::vector<const ICFGNode*> allICFGNodes; ///< all ICFGNodes in this BasicBlock
|
|
89
|
-
const
|
|
90
|
+
const FunObjVar* fun; /// Function where this BasicBlock is
|
|
90
91
|
|
|
91
92
|
|
|
92
93
|
|
|
@@ -104,7 +105,7 @@ protected:
|
|
|
104
105
|
|
|
105
106
|
public:
|
|
106
107
|
/// Constructor without name
|
|
107
|
-
SVFBasicBlock(NodeID id, const
|
|
108
|
+
SVFBasicBlock(NodeID id, const FunObjVar* f): GenericBasicBlockNodeTy(id, BasicBlockKd), fun(f)
|
|
108
109
|
{
|
|
109
110
|
|
|
110
111
|
}
|
|
@@ -148,6 +149,12 @@ public:
|
|
|
148
149
|
return allICFGNodes.end();
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
|
|
153
|
+
inline void setFun(const FunObjVar* f)
|
|
154
|
+
{
|
|
155
|
+
fun = f;
|
|
156
|
+
}
|
|
157
|
+
|
|
151
158
|
inline void addSuccBasicBlock(const SVFBasicBlock* succ2)
|
|
152
159
|
{
|
|
153
160
|
// check if the edge already exists
|
|
@@ -181,13 +188,15 @@ public:
|
|
|
181
188
|
pred->succBBs.push_back(this);
|
|
182
189
|
}
|
|
183
190
|
|
|
184
|
-
inline const
|
|
191
|
+
inline const FunObjVar* getParent() const
|
|
185
192
|
{
|
|
193
|
+
assert(fun && "Function is null?");
|
|
186
194
|
return fun;
|
|
187
195
|
}
|
|
188
196
|
|
|
189
|
-
inline const
|
|
197
|
+
inline const FunObjVar* getFunction() const
|
|
190
198
|
{
|
|
199
|
+
assert(fun && "Function is null?");
|
|
191
200
|
return fun;
|
|
192
201
|
}
|
|
193
202
|
|
|
@@ -287,10 +296,9 @@ class BasicBlockGraph: public GenericBasicBlockGraphTy
|
|
|
287
296
|
{
|
|
288
297
|
private:
|
|
289
298
|
NodeID id{0};
|
|
290
|
-
const SVFFunction* fun;
|
|
291
299
|
public:
|
|
292
300
|
/// Constructor
|
|
293
|
-
BasicBlockGraph(
|
|
301
|
+
BasicBlockGraph()
|
|
294
302
|
{
|
|
295
303
|
|
|
296
304
|
}
|
|
@@ -298,7 +306,7 @@ public:
|
|
|
298
306
|
SVFBasicBlock* addBasicBlock(const std::string& bbname)
|
|
299
307
|
{
|
|
300
308
|
id++;
|
|
301
|
-
SVFBasicBlock* bb = new SVFBasicBlock(id,
|
|
309
|
+
SVFBasicBlock* bb = new SVFBasicBlock(id, nullptr);
|
|
302
310
|
addGNode(id, bb);
|
|
303
311
|
bb->setName(bbname);
|
|
304
312
|
return bb;
|
package/svf/include/Graphs/CHG.h
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
#ifndef CHA_H_
|
|
34
34
|
#define CHA_H_
|
|
35
35
|
|
|
36
|
-
#include "
|
|
36
|
+
#include "Util/ThreadAPI.h"
|
|
37
37
|
#include "Graphs/GenericGraph.h"
|
|
38
38
|
#include "Util/WorkList.h"
|
|
39
39
|
|
|
@@ -45,7 +45,7 @@ class CHNode;
|
|
|
45
45
|
class GlobalObjVar;
|
|
46
46
|
|
|
47
47
|
typedef Set<const GlobalObjVar*> VTableSet;
|
|
48
|
-
typedef Set<const
|
|
48
|
+
typedef Set<const FunObjVar*> VFunSet;
|
|
49
49
|
|
|
50
50
|
/// Common base for class hierarchy graph. Only implements what PointerAnalysis needs.
|
|
51
51
|
class CommonCHGraph
|
|
@@ -119,7 +119,7 @@ public:
|
|
|
119
119
|
TEMPLATE = 0x04 // template class
|
|
120
120
|
} CLASSATTR;
|
|
121
121
|
|
|
122
|
-
typedef std::vector<const
|
|
122
|
+
typedef std::vector<const FunObjVar*> FuncVector;
|
|
123
123
|
|
|
124
124
|
CHNode (const std::string& name, NodeID i = 0, GNodeK k = CHNodeKd):
|
|
125
125
|
GenericCHNodeTy(i, k), vtable(nullptr), className(name), flags(0)
|
|
@@ -252,7 +252,7 @@ public:
|
|
|
252
252
|
DESTRUCTOR = 0x2 // connect node based on destructor
|
|
253
253
|
} RELATIONTYPE;
|
|
254
254
|
|
|
255
|
-
CHGraph(
|
|
255
|
+
CHGraph(): classNum(0), vfID(0), buildingCHGTime(0)
|
|
256
256
|
{
|
|
257
257
|
this->kind = Standard;
|
|
258
258
|
}
|
|
@@ -267,18 +267,18 @@ public:
|
|
|
267
267
|
void view();
|
|
268
268
|
void printCH();
|
|
269
269
|
|
|
270
|
-
inline u32_t getVirtualFunctionID(const
|
|
270
|
+
inline u32_t getVirtualFunctionID(const FunObjVar* vfn) const
|
|
271
271
|
{
|
|
272
|
-
Map<const
|
|
272
|
+
Map<const FunObjVar*, u32_t>::const_iterator it =
|
|
273
273
|
virtualFunctionToIDMap.find(vfn);
|
|
274
274
|
if (it != virtualFunctionToIDMap.end())
|
|
275
275
|
return it->second;
|
|
276
276
|
else
|
|
277
277
|
return -1;
|
|
278
278
|
}
|
|
279
|
-
inline const
|
|
279
|
+
inline const FunObjVar* getVirtualFunctionBasedonID(u32_t id) const
|
|
280
280
|
{
|
|
281
|
-
Map<const
|
|
281
|
+
Map<const FunObjVar*, u32_t>::const_iterator it, eit;
|
|
282
282
|
for (it = virtualFunctionToIDMap.begin(), eit =
|
|
283
283
|
virtualFunctionToIDMap.end(); it != eit; ++it)
|
|
284
284
|
{
|
|
@@ -318,7 +318,6 @@ public:
|
|
|
318
318
|
|
|
319
319
|
|
|
320
320
|
private:
|
|
321
|
-
SVFModule* svfMod;
|
|
322
321
|
u32_t classNum;
|
|
323
322
|
u32_t vfID;
|
|
324
323
|
double buildingCHGTime;
|
|
@@ -329,7 +328,7 @@ private:
|
|
|
329
328
|
NameToCHNodesMap templateNameToInstancesMap;
|
|
330
329
|
CallNodeToCHNodesMap callNodeToClassesMap;
|
|
331
330
|
|
|
332
|
-
Map<const
|
|
331
|
+
Map<const FunObjVar*, u32_t> virtualFunctionToIDMap;
|
|
333
332
|
|
|
334
333
|
CallNodeToVTableSetMap callNodeToCHAVtblsMap;
|
|
335
334
|
CallNodeToVFunSetMap callNodeToCHAVFnsMap;
|
|
@@ -168,6 +168,8 @@ public:
|
|
|
168
168
|
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
+
class FunObjVar;
|
|
172
|
+
|
|
171
173
|
/*
|
|
172
174
|
* Call Graph node representing a function
|
|
173
175
|
*/
|
|
@@ -175,22 +177,19 @@ typedef GenericNode<CallGraphNode, CallGraphEdge> GenericPTACallGraphNodeTy;
|
|
|
175
177
|
class CallGraphNode : public GenericPTACallGraphNodeTy
|
|
176
178
|
{
|
|
177
179
|
private:
|
|
178
|
-
const
|
|
180
|
+
const FunObjVar* fun;
|
|
179
181
|
|
|
180
182
|
public:
|
|
181
183
|
/// Constructor
|
|
182
|
-
CallGraphNode(NodeID i, const
|
|
184
|
+
CallGraphNode(NodeID i, const FunObjVar* f) : GenericPTACallGraphNodeTy(i,CallNodeKd), fun(f)
|
|
183
185
|
{
|
|
184
186
|
|
|
185
187
|
}
|
|
186
188
|
|
|
187
|
-
|
|
188
|
-
{
|
|
189
|
-
return fun->getName();
|
|
190
|
-
}
|
|
189
|
+
const std::string &getName() const;
|
|
191
190
|
|
|
192
191
|
/// Get function of this call node
|
|
193
|
-
inline const
|
|
192
|
+
inline const FunObjVar* getFunction() const
|
|
194
193
|
{
|
|
195
194
|
return fun;
|
|
196
195
|
}
|
|
@@ -238,12 +237,12 @@ class CallGraph : public GenericPTACallGraphTy
|
|
|
238
237
|
|
|
239
238
|
public:
|
|
240
239
|
typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
|
|
241
|
-
typedef Map<const
|
|
240
|
+
typedef Map<const FunObjVar*, CallGraphNode*> FunToCallGraphNodeMap;
|
|
242
241
|
typedef Map<const CallICFGNode*, CallGraphEdgeSet> CallInstToCallGraphEdgesMap;
|
|
243
|
-
typedef std::pair<const CallICFGNode*, const
|
|
242
|
+
typedef std::pair<const CallICFGNode*, const FunObjVar*> CallSitePair;
|
|
244
243
|
typedef Map<CallSitePair, CallSiteID> CallSiteToIdMap;
|
|
245
244
|
typedef Map<CallSiteID, CallSitePair> IdToCallSiteMap;
|
|
246
|
-
typedef Set<const
|
|
245
|
+
typedef Set<const FunObjVar*> FunctionSet;
|
|
247
246
|
typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
|
|
248
247
|
typedef CallGraphEdgeSet::iterator CallGraphEdgeIter;
|
|
249
248
|
typedef CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter;
|
|
@@ -275,9 +274,9 @@ protected:
|
|
|
275
274
|
|
|
276
275
|
protected:
|
|
277
276
|
/// Add CallSiteID
|
|
278
|
-
inline CallSiteID addCallSite(const CallICFGNode* cs, const
|
|
277
|
+
inline CallSiteID addCallSite(const CallICFGNode* cs, const FunObjVar* callee)
|
|
279
278
|
{
|
|
280
|
-
std::pair<const CallICFGNode*, const
|
|
279
|
+
std::pair<const CallICFGNode*, const FunObjVar*> newCS(std::make_pair(cs, callee));
|
|
281
280
|
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
282
281
|
//assert(it == csToIdMap.end() && "cannot add a callsite twice");
|
|
283
282
|
if(it == csToIdMap.end())
|
|
@@ -352,9 +351,9 @@ public:
|
|
|
352
351
|
void verifyCallGraph();
|
|
353
352
|
|
|
354
353
|
/// Add direct call edges
|
|
355
|
-
void addDirectCallGraphEdge(const CallICFGNode* call, const
|
|
354
|
+
void addDirectCallGraphEdge(const CallICFGNode* call, const FunObjVar* callerFun, const FunObjVar* calleeFun);
|
|
356
355
|
|
|
357
|
-
void addCallGraphNode(const
|
|
356
|
+
void addCallGraphNode(const FunObjVar* fun);
|
|
358
357
|
|
|
359
358
|
/// Get call graph node
|
|
360
359
|
//@{
|
|
@@ -365,7 +364,7 @@ public:
|
|
|
365
364
|
{
|
|
366
365
|
return getGNode(id);
|
|
367
366
|
}
|
|
368
|
-
inline CallGraphNode* getCallGraphNode(const
|
|
367
|
+
inline CallGraphNode* getCallGraphNode(const FunObjVar* fun) const
|
|
369
368
|
{
|
|
370
369
|
FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun);
|
|
371
370
|
assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!");
|
|
@@ -376,14 +375,14 @@ public:
|
|
|
376
375
|
|
|
377
376
|
/// Get CallSiteID
|
|
378
377
|
//@{
|
|
379
|
-
inline CallSiteID getCallSiteID(const CallICFGNode* cs, const
|
|
378
|
+
inline CallSiteID getCallSiteID(const CallICFGNode* cs, const FunObjVar* callee) const
|
|
380
379
|
{
|
|
381
380
|
CallSitePair newCS(std::make_pair(cs, callee));
|
|
382
381
|
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
383
382
|
assert(it != csToIdMap.end() && "callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
|
|
384
383
|
return it->second;
|
|
385
384
|
}
|
|
386
|
-
inline bool hasCallSiteID(const CallICFGNode* cs, const
|
|
385
|
+
inline bool hasCallSiteID(const CallICFGNode* cs, const FunObjVar* callee) const
|
|
387
386
|
{
|
|
388
387
|
CallSitePair newCS(std::make_pair(cs, callee));
|
|
389
388
|
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
@@ -399,11 +398,8 @@ public:
|
|
|
399
398
|
{
|
|
400
399
|
return getCallSitePair(id).first;
|
|
401
400
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return getCallSite(id)->getCaller();
|
|
405
|
-
}
|
|
406
|
-
inline const SVFFunction* getCalleeOfCallSite(CallSiteID id) const
|
|
401
|
+
const FunObjVar* getCallerOfCallSite(CallSiteID id) const;
|
|
402
|
+
inline const FunObjVar* getCalleeOfCallSite(CallSiteID id) const
|
|
407
403
|
{
|
|
408
404
|
return getCallSitePair(id).second;
|
|
409
405
|
}
|
|
@@ -454,18 +450,18 @@ public:
|
|
|
454
450
|
|
|
455
451
|
/// Add indirect call edges
|
|
456
452
|
//@{
|
|
457
|
-
void addIndirectCallGraphEdge(const CallICFGNode* cs,const
|
|
453
|
+
void addIndirectCallGraphEdge(const CallICFGNode* cs,const FunObjVar* callerFun, const FunObjVar* calleeFun);
|
|
458
454
|
//@}
|
|
459
455
|
|
|
460
456
|
/// Get callsites invoking the callee
|
|
461
457
|
//@{
|
|
462
|
-
void getAllCallSitesInvokingCallee(const
|
|
463
|
-
void getDirCallSitesInvokingCallee(const
|
|
464
|
-
void getIndCallSitesInvokingCallee(const
|
|
458
|
+
void getAllCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
|
|
459
|
+
void getDirCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
|
|
460
|
+
void getIndCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
|
|
465
461
|
//@}
|
|
466
462
|
|
|
467
463
|
/// Whether its reachable between two functions
|
|
468
|
-
bool isReachableBetweenFunctions(const
|
|
464
|
+
bool isReachableBetweenFunctions(const FunObjVar* srcFn, const FunObjVar* dstFn) const;
|
|
469
465
|
|
|
470
466
|
/// Dump the graph
|
|
471
467
|
void dump(const std::string& filename);
|
|
@@ -76,12 +76,12 @@ protected:
|
|
|
76
76
|
|
|
77
77
|
/// Wrappers used internally, not expose to Andersen Pass
|
|
78
78
|
//@{
|
|
79
|
-
inline NodeID getReturnNode(const
|
|
79
|
+
inline NodeID getReturnNode(const FunObjVar* value) const
|
|
80
80
|
{
|
|
81
81
|
return pag->getReturnNode(value);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
inline NodeID getVarargNode(const
|
|
84
|
+
inline NodeID getVarargNode(const FunObjVar* value) const
|
|
85
85
|
{
|
|
86
86
|
return pag->getVarargNode(value);
|
|
87
87
|
}
|