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,94 +0,0 @@
|
|
|
1
|
-
//===- BreakConstantGEPs.h - Change constant GEPs into GEP instructions --- --//
|
|
2
|
-
//
|
|
3
|
-
// The SAFECode Compiler
|
|
4
|
-
//
|
|
5
|
-
// This file was developed by the LLVM research group and is distributed under
|
|
6
|
-
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
7
|
-
//
|
|
8
|
-
//===----------------------------------------------------------------------===//
|
|
9
|
-
//
|
|
10
|
-
// This pass changes all GEP constant expressions into GEP instructions. This
|
|
11
|
-
// permits the rest of SAFECode to put run-time checks on them if necessary.
|
|
12
|
-
//
|
|
13
|
-
//===----------------------------------------------------------------------===//
|
|
14
|
-
|
|
15
|
-
#ifndef BREAKCONSTANTGEPS_H
|
|
16
|
-
#define BREAKCONSTANTGEPS_H
|
|
17
|
-
|
|
18
|
-
#include "Util/BasicTypes.h"
|
|
19
|
-
|
|
20
|
-
namespace SVF
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
// Pass: BreakConstantGEPs
|
|
25
|
-
//
|
|
26
|
-
// Description:
|
|
27
|
-
// This pass modifies a function so that it uses GEP instructions instead of
|
|
28
|
-
// GEP constant expressions.
|
|
29
|
-
//
|
|
30
|
-
class BreakConstantGEPs : public ModulePass
|
|
31
|
-
{
|
|
32
|
-
private:
|
|
33
|
-
// Private methods
|
|
34
|
-
|
|
35
|
-
// Private variables
|
|
36
|
-
|
|
37
|
-
public:
|
|
38
|
-
static char ID;
|
|
39
|
-
BreakConstantGEPs() : ModulePass(ID) {}
|
|
40
|
-
llvm::StringRef getPassName() const
|
|
41
|
-
{
|
|
42
|
-
return "Remove Constant GEP Expressions";
|
|
43
|
-
}
|
|
44
|
-
virtual bool runOnModule (Module & M);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
// Pass: MergeFunctionRets
|
|
50
|
-
//
|
|
51
|
-
// Description:
|
|
52
|
-
// This pass modifies a function so that each function only have one unified exit basic block
|
|
53
|
-
//
|
|
54
|
-
class MergeFunctionRets : public ModulePass
|
|
55
|
-
{
|
|
56
|
-
private:
|
|
57
|
-
// Private methods
|
|
58
|
-
|
|
59
|
-
// Private variables
|
|
60
|
-
|
|
61
|
-
public:
|
|
62
|
-
static char ID;
|
|
63
|
-
MergeFunctionRets() : ModulePass(ID) {}
|
|
64
|
-
llvm::StringRef getPassName() const
|
|
65
|
-
{
|
|
66
|
-
return "unify function exit into one dummy exit basic block";
|
|
67
|
-
}
|
|
68
|
-
virtual bool runOnModule (Module & M)
|
|
69
|
-
{
|
|
70
|
-
UnifyFunctionExit(M);
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
inline void UnifyFunctionExit(Module& module)
|
|
74
|
-
{
|
|
75
|
-
for (Module::const_iterator iter = module.begin(), eiter = module.end();
|
|
76
|
-
iter != eiter; ++iter)
|
|
77
|
-
{
|
|
78
|
-
const Function& fun = *iter;
|
|
79
|
-
if(fun.isDeclaration())
|
|
80
|
-
continue;
|
|
81
|
-
getUnifyExit(fun)->runOnFunction(const_cast<Function&>(fun));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/// Get Unified Exit basic block node
|
|
85
|
-
inline UnifyFunctionExitNodes* getUnifyExit(const Function& fn)
|
|
86
|
-
{
|
|
87
|
-
assert(!fn.isDeclaration() && "external function does not have DF");
|
|
88
|
-
return &getAnalysis<UnifyFunctionExitNodes>(const_cast<Function&>(fn));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
} // End namespace SVF
|
|
93
|
-
|
|
94
|
-
#endif
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
//===----- CHG.h -- Base class of pointer analyses ---------------------------//
|
|
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
|
-
* CHG.h (previously CHA.h)
|
|
25
|
-
*
|
|
26
|
-
* Created on: Apr 13, 2016
|
|
27
|
-
* Author: Xiaokang Fan
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef CHA_H_
|
|
31
|
-
#define CHA_H_
|
|
32
|
-
|
|
33
|
-
#include "Util/SVFModule.h"
|
|
34
|
-
#include "SVF-FE/CommonCHG.h"
|
|
35
|
-
#include "Graphs/GenericGraph.h"
|
|
36
|
-
#include "Util/WorkList.h"
|
|
37
|
-
|
|
38
|
-
namespace SVF
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
class SVFModule;
|
|
42
|
-
class CHNode;
|
|
43
|
-
|
|
44
|
-
typedef GenericEdge<CHNode> GenericCHEdgeTy;
|
|
45
|
-
class CHEdge: public GenericCHEdgeTy
|
|
46
|
-
{
|
|
47
|
-
public:
|
|
48
|
-
typedef enum
|
|
49
|
-
{
|
|
50
|
-
INHERITANCE = 0x1, // inheritance relation
|
|
51
|
-
INSTANTCE = 0x2 // template-instance relation
|
|
52
|
-
} CHEDGETYPE;
|
|
53
|
-
|
|
54
|
-
typedef GenericNode<CHNode,CHEdge>::GEdgeSetTy CHEdgeSetTy;
|
|
55
|
-
|
|
56
|
-
CHEdge(CHNode *s, CHNode *d, CHEDGETYPE et, GEdgeFlag k = 0):
|
|
57
|
-
GenericCHEdgeTy(s,d,k)
|
|
58
|
-
{
|
|
59
|
-
edgeType = et;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
CHEDGETYPE getEdgeType() const
|
|
63
|
-
{
|
|
64
|
-
return edgeType;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private:
|
|
68
|
-
CHEDGETYPE edgeType;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
typedef GenericNode<CHNode,CHEdge> GenericCHNodeTy;
|
|
72
|
-
class CHNode: public GenericCHNodeTy
|
|
73
|
-
{
|
|
74
|
-
public:
|
|
75
|
-
typedef enum
|
|
76
|
-
{
|
|
77
|
-
PURE_ABSTRACT = 0x1, // pure virtual abstract class
|
|
78
|
-
MULTI_INHERITANCE = 0x2, // multi inheritance class
|
|
79
|
-
TEMPLATE = 0x04 // template class
|
|
80
|
-
} CLASSATTR;
|
|
81
|
-
|
|
82
|
-
typedef std::vector<const SVFFunction*> FuncVector;
|
|
83
|
-
|
|
84
|
-
CHNode (const std::string name, NodeID i = 0, GNodeK k = 0):
|
|
85
|
-
GenericCHNodeTy(i, k), vtable(nullptr), className(name), flags(0)
|
|
86
|
-
{
|
|
87
|
-
}
|
|
88
|
-
~CHNode()
|
|
89
|
-
{
|
|
90
|
-
}
|
|
91
|
-
std::string getName() const
|
|
92
|
-
{
|
|
93
|
-
return className;
|
|
94
|
-
}
|
|
95
|
-
/// Flags
|
|
96
|
-
//@{
|
|
97
|
-
inline void setFlag(CLASSATTR mask)
|
|
98
|
-
{
|
|
99
|
-
flags |= mask;
|
|
100
|
-
}
|
|
101
|
-
inline bool hasFlag(CLASSATTR mask) const
|
|
102
|
-
{
|
|
103
|
-
return (flags & mask) == mask;
|
|
104
|
-
}
|
|
105
|
-
//@}
|
|
106
|
-
|
|
107
|
-
/// Attribute
|
|
108
|
-
//@{
|
|
109
|
-
inline void setPureAbstract()
|
|
110
|
-
{
|
|
111
|
-
setFlag(PURE_ABSTRACT);
|
|
112
|
-
}
|
|
113
|
-
inline void setMultiInheritance()
|
|
114
|
-
{
|
|
115
|
-
setFlag(MULTI_INHERITANCE);
|
|
116
|
-
}
|
|
117
|
-
inline void setTemplate()
|
|
118
|
-
{
|
|
119
|
-
setFlag(TEMPLATE);
|
|
120
|
-
}
|
|
121
|
-
inline bool isPureAbstract() const
|
|
122
|
-
{
|
|
123
|
-
return hasFlag(PURE_ABSTRACT);
|
|
124
|
-
}
|
|
125
|
-
inline bool isMultiInheritance() const
|
|
126
|
-
{
|
|
127
|
-
return hasFlag(MULTI_INHERITANCE);
|
|
128
|
-
}
|
|
129
|
-
inline bool isTemplate() const
|
|
130
|
-
{
|
|
131
|
-
return hasFlag(TEMPLATE);
|
|
132
|
-
}
|
|
133
|
-
//@}
|
|
134
|
-
|
|
135
|
-
void addVirtualFunctionVector(FuncVector vfuncvec)
|
|
136
|
-
{
|
|
137
|
-
virtualFunctionVectors.push_back(vfuncvec);
|
|
138
|
-
}
|
|
139
|
-
const std::vector<FuncVector> &getVirtualFunctionVectors() const
|
|
140
|
-
{
|
|
141
|
-
return virtualFunctionVectors;
|
|
142
|
-
}
|
|
143
|
-
void getVirtualFunctions(u32_t idx, FuncVector &virtualFunctions) const;
|
|
144
|
-
|
|
145
|
-
const GlobalValue *getVTable() const
|
|
146
|
-
{
|
|
147
|
-
return vtable;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
void setVTable(const GlobalValue *vtbl)
|
|
151
|
-
{
|
|
152
|
-
vtable = vtbl;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private:
|
|
156
|
-
const GlobalValue* vtable;
|
|
157
|
-
std::string className;
|
|
158
|
-
size_t flags;
|
|
159
|
-
/*
|
|
160
|
-
* virtual functions inherited from different classes are separately stored
|
|
161
|
-
* to model different vtables inherited from different fathers.
|
|
162
|
-
*
|
|
163
|
-
* Example:
|
|
164
|
-
* class C: public A, public B
|
|
165
|
-
* vtableC = {Af1, Af2, ..., inttoptr, Bg1, Bg2, ...} ("inttoptr"
|
|
166
|
-
* instruction works as the delimiter for separating virtual functions
|
|
167
|
-
* inherited from different classes)
|
|
168
|
-
*
|
|
169
|
-
* virtualFunctionVectors = {{Af1, Af2, ...}, {Bg1, Bg2, ...}}
|
|
170
|
-
*/
|
|
171
|
-
std::vector<FuncVector> virtualFunctionVectors;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/// class hierarchy graph
|
|
175
|
-
typedef GenericGraph<CHNode,CHEdge> GenericCHGraphTy;
|
|
176
|
-
class CHGraph: public CommonCHGraph, public GenericCHGraphTy
|
|
177
|
-
{
|
|
178
|
-
public:
|
|
179
|
-
typedef Set<const CHNode*> CHNodeSetTy;
|
|
180
|
-
typedef FIFOWorkList<const CHNode*> WorkList;
|
|
181
|
-
typedef Map<std::string, CHNodeSetTy> NameToCHNodesMap;
|
|
182
|
-
typedef Map<CallSite, CHNodeSetTy> CallSiteToCHNodesMap;
|
|
183
|
-
typedef Map<CallSite, VTableSet> CallSiteToVTableSetMap;
|
|
184
|
-
typedef Map<CallSite, VFunSet> CallSiteToVFunSetMap;
|
|
185
|
-
|
|
186
|
-
typedef enum
|
|
187
|
-
{
|
|
188
|
-
CONSTRUCTOR = 0x1, // connect node based on constructor
|
|
189
|
-
DESTRUCTOR = 0x2 // connect node based on destructor
|
|
190
|
-
} RELATIONTYPE;
|
|
191
|
-
|
|
192
|
-
CHGraph(SVFModule* svfModule): svfMod(svfModule), classNum(0), vfID(0), buildingCHGTime(0)
|
|
193
|
-
{
|
|
194
|
-
this->kind = Standard;
|
|
195
|
-
}
|
|
196
|
-
~CHGraph() override = default;
|
|
197
|
-
|
|
198
|
-
void buildCHG();
|
|
199
|
-
void buildInternalMaps();
|
|
200
|
-
void buildCHGNodes(const GlobalValue *V);
|
|
201
|
-
void buildCHGNodes(const SVFFunction* F);
|
|
202
|
-
void buildCHGEdges(const SVFFunction* F);
|
|
203
|
-
void connectInheritEdgeViaCall(const SVFFunction* caller, CallSite cs);
|
|
204
|
-
void connectInheritEdgeViaStore(const SVFFunction* caller, const StoreInst* store);
|
|
205
|
-
void addEdge(const std::string className,
|
|
206
|
-
const std::string baseClassName,
|
|
207
|
-
CHEdge::CHEDGETYPE edgeType);
|
|
208
|
-
CHNode *getNode(const std::string name) const;
|
|
209
|
-
CHNode *createNode(const std::string name);
|
|
210
|
-
void buildClassNameToAncestorsDescendantsMap();
|
|
211
|
-
void buildVirtualFunctionToIDMap();
|
|
212
|
-
void buildCSToCHAVtblsAndVfnsMap();
|
|
213
|
-
void readInheritanceMetadataFromModule(const Module &M);
|
|
214
|
-
void analyzeVTables(const Module &M);
|
|
215
|
-
const CHGraph::CHNodeSetTy& getInstancesAndDescendants(const std::string className);
|
|
216
|
-
const CHNodeSetTy& getCSClasses(CallSite cs);
|
|
217
|
-
void getVFnsFromVtbls(CallSite cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
|
|
218
|
-
void dump(const std::string& filename);
|
|
219
|
-
void view();
|
|
220
|
-
void printCH();
|
|
221
|
-
|
|
222
|
-
inline s32_t getVirtualFunctionID(const SVFFunction* vfn) const
|
|
223
|
-
{
|
|
224
|
-
Map<const SVFFunction*, s32_t>::const_iterator it =
|
|
225
|
-
virtualFunctionToIDMap.find(vfn);
|
|
226
|
-
if (it != virtualFunctionToIDMap.end())
|
|
227
|
-
return it->second;
|
|
228
|
-
else
|
|
229
|
-
return -1;
|
|
230
|
-
}
|
|
231
|
-
inline const SVFFunction* getVirtualFunctionBasedonID(s32_t id) const
|
|
232
|
-
{
|
|
233
|
-
Map<const SVFFunction*, s32_t>::const_iterator it, eit;
|
|
234
|
-
for (it = virtualFunctionToIDMap.begin(), eit =
|
|
235
|
-
virtualFunctionToIDMap.end(); it != eit; ++it)
|
|
236
|
-
{
|
|
237
|
-
if (it->second == id)
|
|
238
|
-
return it->first;
|
|
239
|
-
}
|
|
240
|
-
return nullptr;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
inline void addInstances(const std::string templateName, CHNode* node)
|
|
244
|
-
{
|
|
245
|
-
NameToCHNodesMap::iterator it = templateNameToInstancesMap.find(
|
|
246
|
-
templateName);
|
|
247
|
-
if (it != templateNameToInstancesMap.end())
|
|
248
|
-
it->second.insert(node);
|
|
249
|
-
else
|
|
250
|
-
templateNameToInstancesMap[templateName].insert(node);
|
|
251
|
-
}
|
|
252
|
-
inline const CHNodeSetTy &getDescendants(const std::string className)
|
|
253
|
-
{
|
|
254
|
-
return classNameToDescendantsMap[className];
|
|
255
|
-
}
|
|
256
|
-
inline const CHNodeSetTy &getInstances(const std::string className)
|
|
257
|
-
{
|
|
258
|
-
return templateNameToInstancesMap[className];
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
inline bool csHasVtblsBasedonCHA(CallSite cs) override
|
|
262
|
-
{
|
|
263
|
-
CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
|
|
264
|
-
return it != csToCHAVtblsMap.end();
|
|
265
|
-
}
|
|
266
|
-
inline bool csHasVFnsBasedonCHA(CallSite cs) override
|
|
267
|
-
{
|
|
268
|
-
CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
|
|
269
|
-
return it != csToCHAVFnsMap.end();
|
|
270
|
-
}
|
|
271
|
-
inline const VTableSet &getCSVtblsBasedonCHA(CallSite cs) override
|
|
272
|
-
{
|
|
273
|
-
CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
|
|
274
|
-
assert(it != csToCHAVtblsMap.end() && "cs does not have vtabls based on CHA.");
|
|
275
|
-
return it->second;
|
|
276
|
-
}
|
|
277
|
-
inline const VFunSet &getCSVFsBasedonCHA(CallSite cs) override
|
|
278
|
-
{
|
|
279
|
-
CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
|
|
280
|
-
assert(it != csToCHAVFnsMap.end() && "cs does not have vfns based on CHA.");
|
|
281
|
-
return it->second;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
static inline bool classof(const CommonCHGraph *chg)
|
|
285
|
-
{
|
|
286
|
-
return chg->getKind() == Standard;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
protected:
|
|
290
|
-
void addFuncToFuncVector(CHNode::FuncVector &v, const SVFFunction *f);
|
|
291
|
-
|
|
292
|
-
private:
|
|
293
|
-
SVFModule* svfMod;
|
|
294
|
-
u32_t classNum;
|
|
295
|
-
s32_t vfID;
|
|
296
|
-
double buildingCHGTime;
|
|
297
|
-
Map<std::string, CHNode *> classNameToNodeMap;
|
|
298
|
-
NameToCHNodesMap classNameToDescendantsMap;
|
|
299
|
-
NameToCHNodesMap classNameToAncestorsMap;
|
|
300
|
-
NameToCHNodesMap classNameToInstAndDescsMap;
|
|
301
|
-
NameToCHNodesMap templateNameToInstancesMap;
|
|
302
|
-
CallSiteToCHNodesMap csToClassesMap;
|
|
303
|
-
|
|
304
|
-
Map<const SVFFunction*, s32_t> virtualFunctionToIDMap;
|
|
305
|
-
CallSiteToVTableSetMap csToCHAVtblsMap;
|
|
306
|
-
CallSiteToVFunSetMap csToCHAVFnsMap;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
} // End namespace SVF
|
|
310
|
-
|
|
311
|
-
namespace llvm
|
|
312
|
-
{
|
|
313
|
-
/* !
|
|
314
|
-
* GraphTraits specializations for generic graph algorithms.
|
|
315
|
-
* Provide graph traits for traversing from a constraint node using standard graph traversals.
|
|
316
|
-
*/
|
|
317
|
-
template<> struct GraphTraits<SVF::CHNode*> : public GraphTraits<SVF::GenericNode<SVF::CHNode,SVF::CHEdge>* >
|
|
318
|
-
{
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
/// Inverse GraphTraits specializations for call graph node, it is used for inverse traversal.
|
|
322
|
-
template<>
|
|
323
|
-
struct GraphTraits<Inverse<SVF::CHNode*> > : public GraphTraits<Inverse<SVF::GenericNode<SVF::CHNode,SVF::CHEdge>* > >
|
|
324
|
-
{
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
template<> struct GraphTraits<SVF::CHGraph*> : public GraphTraits<SVF::GenericGraph<SVF::CHNode,SVF::CHEdge>* >
|
|
328
|
-
{
|
|
329
|
-
typedef SVF::CHNode *NodeRef;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
} // End namespace llvm
|
|
333
|
-
|
|
334
|
-
#endif /* CHA_H_ */
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
//===----- CHGBuiler.h -- Class hierarchy graph 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
|
-
* CHGBuiler.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: Jun 4, 2021
|
|
27
|
-
* Author: Yulei Sui
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#include "Graphs/CHG.h"
|
|
31
|
-
#include "SVF-FE/BasicTypes.h"
|
|
32
|
-
|
|
33
|
-
namespace SVF
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
class CHGBuilder
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
private:
|
|
40
|
-
CHGraph* chg;
|
|
41
|
-
|
|
42
|
-
public:
|
|
43
|
-
typedef CHGraph::CHNodeSetTy CHNodeSetTy;
|
|
44
|
-
typedef CHGraph::WorkList WorkList;
|
|
45
|
-
|
|
46
|
-
CHGBuilder(CHGraph* c): chg(c)
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
void buildCHG();
|
|
51
|
-
void buildCHGNodes(const GlobalValue *V);
|
|
52
|
-
void buildCHGNodes(const SVFFunction* F);
|
|
53
|
-
void buildCHGEdges(const SVFFunction* F);
|
|
54
|
-
void buildInternalMaps();
|
|
55
|
-
void readInheritanceMetadataFromModule(const Module &M);
|
|
56
|
-
|
|
57
|
-
CHNode *createNode(const std::string name);
|
|
58
|
-
|
|
59
|
-
void connectInheritEdgeViaCall(const SVFFunction* caller, CallSite cs);
|
|
60
|
-
void connectInheritEdgeViaStore(const SVFFunction* caller, const StoreInst* store);
|
|
61
|
-
|
|
62
|
-
void buildClassNameToAncestorsDescendantsMap();
|
|
63
|
-
const CHGraph::CHNodeSetTy& getInstancesAndDescendants(const std::string className);
|
|
64
|
-
|
|
65
|
-
void analyzeVTables(const Module &M);
|
|
66
|
-
void buildVirtualFunctionToIDMap();
|
|
67
|
-
void buildCSToCHAVtblsAndVfnsMap();
|
|
68
|
-
const CHNodeSetTy& getCSClasses(CallSite cs);
|
|
69
|
-
void addFuncToFuncVector(CHNode::FuncVector &v, const SVFFunction *f);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
} // End namespace SVF
|
|
73
|
-
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
//===- CPPUtil.h -- Base class of pointer analyses ---------------------------//
|
|
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
|
-
* CPPUtil.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: Apr 13, 2016
|
|
27
|
-
* Author: Xiaokang Fan
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef CPPUtil_H_
|
|
31
|
-
#define CPPUtil_H_
|
|
32
|
-
|
|
33
|
-
#include "Util/BasicTypes.h"
|
|
34
|
-
#include "SVF-FE/BasicTypes.h"
|
|
35
|
-
|
|
36
|
-
namespace SVF
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
class CHGraph;
|
|
40
|
-
/*
|
|
41
|
-
* Util class to assist pointer analysis for cpp programs
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
namespace cppUtil
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
struct DemangledName
|
|
48
|
-
{
|
|
49
|
-
std::string className;
|
|
50
|
-
std::string funcName;
|
|
51
|
-
bool isThunkFunc;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
struct DemangledName demangle(const std::string &name);
|
|
55
|
-
|
|
56
|
-
std::string getBeforeBrackets(const std::string &name);
|
|
57
|
-
bool isValVtbl(const Value* val);
|
|
58
|
-
bool isLoadVtblInst(const LoadInst *loadInst);
|
|
59
|
-
bool isVirtualCallSite(CallSite cs);
|
|
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);
|
|
64
|
-
|
|
65
|
-
/*
|
|
66
|
-
* VtableA = {&A::foo}
|
|
67
|
-
* A::A(this){
|
|
68
|
-
* *this = &VtableA;
|
|
69
|
-
* }
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* A* p = new A;
|
|
73
|
-
* cs: p->foo(...)
|
|
74
|
-
* ==>
|
|
75
|
-
* vtptr = *p;
|
|
76
|
-
* vfn = &vtptr[i]
|
|
77
|
-
* %funp = *vfn
|
|
78
|
-
* call %funp(p,...)
|
|
79
|
-
* getConstructorThisPtr(A) return "this" pointer
|
|
80
|
-
* getVCallThisPtr(cs) return p (this pointer)
|
|
81
|
-
* getVCallVtblPtr(cs) return vtptr
|
|
82
|
-
* getVCallIdx(cs) return i
|
|
83
|
-
* getClassNameFromVtblObj(VtableA) return
|
|
84
|
-
* getClassNameFromType(type of p) return type A
|
|
85
|
-
*/
|
|
86
|
-
const Argument* getConstructorThisPtr(const Function* fun);
|
|
87
|
-
const Value* getVCallThisPtr(CallSite cs);
|
|
88
|
-
const Value* getVCallVtblPtr(CallSite cs);
|
|
89
|
-
u64_t getVCallIdx(CallSite cs);
|
|
90
|
-
std::string getClassNameFromVtblObj(const Value* value);
|
|
91
|
-
std::string getClassNameFromType(const Type *ty);
|
|
92
|
-
std::string getClassNameOfThisPtr(CallSite cs);
|
|
93
|
-
std::string getFunNameOfVCallSite(CallSite cs);
|
|
94
|
-
bool VCallInCtorOrDtor(CallSite cs);
|
|
95
|
-
|
|
96
|
-
/*
|
|
97
|
-
* A(A* this){
|
|
98
|
-
* store this this.addr;
|
|
99
|
-
* tmp = load this.addr;
|
|
100
|
-
* this1 = bitcast(tmp);
|
|
101
|
-
* B(this1);
|
|
102
|
-
* }
|
|
103
|
-
* this and this1 are the same thisPtr in the constructor
|
|
104
|
-
*/
|
|
105
|
-
bool isSameThisPtrInConstructor(const Argument* thisPtr1, const Value* thisPtr2);
|
|
106
|
-
|
|
107
|
-
/// Constants pertaining to CTir, for C and C++.
|
|
108
|
-
/// TODO: move helper functions here too?
|
|
109
|
-
namespace ctir
|
|
110
|
-
{
|
|
111
|
-
/// On loads, stores, GEPs representing dereferences, and calls
|
|
112
|
-
/// representing virtual calls.
|
|
113
|
-
/// (The static type.)
|
|
114
|
-
const std::string derefMDName = "ctir";
|
|
115
|
-
/// On the (global) virtual table itself.
|
|
116
|
-
/// (The class it corresponds to.)
|
|
117
|
-
const std::string vtMDName = "ctir.vt";
|
|
118
|
-
/// On the bitcast of `this` to i8*.
|
|
119
|
-
/// (The class the constructor it corresponds to.)
|
|
120
|
-
const std::string vtInitMDName = "ctir.vt.init";
|
|
121
|
-
|
|
122
|
-
/// Value we expect a ctir-annotated module to have.
|
|
123
|
-
const uint32_t moduleFlagValue = 1;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
} // End namespace cppUtil
|
|
127
|
-
|
|
128
|
-
} // End namespace SVF
|
|
129
|
-
|
|
130
|
-
#endif /* CPPUtil_H_ */
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
//===- CallGraphBuilder.h ----------------------------------------------------------------//
|
|
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
|
-
/*
|
|
25
|
-
* CallGraphBuilder.h
|
|
26
|
-
*
|
|
27
|
-
* Created on: 13Mar.,2020
|
|
28
|
-
* Author: Yulei Sui
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
#ifndef INCLUDE_SVF_FE_CALLGRAPHBUILDER_H_
|
|
32
|
-
#define INCLUDE_SVF_FE_CALLGRAPHBUILDER_H_
|
|
33
|
-
|
|
34
|
-
#include "Graphs/PTACallGraph.h"
|
|
35
|
-
#include "Graphs/ThreadCallGraph.h"
|
|
36
|
-
|
|
37
|
-
namespace SVF
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
class ICFG;
|
|
41
|
-
|
|
42
|
-
class CallGraphBuilder
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
protected:
|
|
46
|
-
PTACallGraph* callgraph;
|
|
47
|
-
ICFG* icfg;
|
|
48
|
-
public:
|
|
49
|
-
CallGraphBuilder(PTACallGraph* cg, ICFG* i): callgraph(cg),icfg(i)
|
|
50
|
-
{
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/// Build normal callgraph
|
|
54
|
-
PTACallGraph* buildCallGraph(SVFModule* svfModule);
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
class ThreadCallGraphBuilder : public CallGraphBuilder
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
public:
|
|
62
|
-
ThreadCallGraphBuilder(ThreadCallGraph* cg, ICFG* i): CallGraphBuilder(cg,i)
|
|
63
|
-
{
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/// Build thread-aware callgraph
|
|
67
|
-
PTACallGraph* buildThreadCallGraph(SVFModule* svfModule);
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
} // End namespace SVF
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
#endif /* INCLUDE_UTIL_CALLGRAPHBUILDER_H_ */
|