svf-lib 1.0.1375 → 1.0.1376
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/SVF-osx/svf/include/include/AbstractExecution/AbstractValue.h +79 -0
- package/SVF-osx/svf/include/include/AbstractExecution/AddressValue.h +210 -0
- package/SVF-osx/svf/include/include/AbstractExecution/ExeState.h +223 -0
- package/SVF-osx/svf/include/include/AbstractExecution/IntervalExeState.h +425 -0
- package/SVF-osx/svf/include/include/AbstractExecution/IntervalValue.h +868 -0
- package/SVF-osx/svf/include/include/AbstractExecution/NumericLiteral.h +406 -0
- package/SVF-osx/svf/include/include/AbstractExecution/RelExeState.h +225 -0
- package/SVF-osx/svf/include/include/AbstractExecution/RelationSolver.h +68 -0
- package/SVF-osx/svf/include/include/AbstractExecution/SVFIR2ItvExeState.h +186 -0
- package/SVF-osx/svf/include/include/AbstractExecution/WTO.h +845 -0
- package/SVF-osx/svf/include/include/CFL/CFGNormalizer.h +84 -0
- package/SVF-osx/svf/include/include/CFL/CFLAlias.h +176 -0
- package/SVF-osx/svf/include/include/CFL/CFLBase.h +115 -0
- package/SVF-osx/svf/include/include/CFL/CFLData.h +316 -0
- package/SVF-osx/svf/include/include/CFL/CFLDataBuilder.h +91 -0
- package/SVF-osx/svf/include/include/CFL/CFLGramGraphChecker.h +74 -0
- package/SVF-osx/svf/include/include/CFL/CFLGrammar.h +468 -0
- package/SVF-osx/svf/include/include/CFL/CFLGrammar.txt +15 -0
- package/SVF-osx/svf/include/include/CFL/CFLGraphBuilder.h +193 -0
- package/SVF-osx/svf/include/include/CFL/CFLSolver.h +136 -0
- package/SVF-osx/svf/include/include/CFL/CFLStat.h +67 -0
- package/SVF-osx/svf/include/include/CFL/CFLVF.h +65 -0
- package/SVF-osx/svf/include/include/CFL/GrammarBuilder.h +100 -0
- package/SVF-osx/svf/include/include/CFL/PEGGrammar.txt +11 -0
- package/SVF-osx/svf/include/include/CFL/VFG.txt +7 -0
- package/SVF-osx/svf/include/include/DDA/ContextDDA.h +230 -0
- package/SVF-osx/svf/include/include/DDA/DDAClient.h +168 -0
- package/SVF-osx/svf/include/include/DDA/DDAPass.h +99 -0
- package/SVF-osx/svf/include/include/DDA/DDAStat.h +138 -0
- package/SVF-osx/svf/include/include/DDA/DDAVFSolver.h +789 -0
- package/SVF-osx/svf/include/include/DDA/FlowDDA.h +178 -0
- package/SVF-osx/svf/include/include/FastCluster/LICENSE.TXT +13 -0
- package/SVF-osx/svf/include/include/FastCluster/fastcluster.h +80 -0
- package/SVF-osx/svf/include/include/Graphs/CFLGraph.h +215 -0
- package/SVF-osx/svf/include/include/Graphs/CHG.h +351 -0
- package/SVF-osx/svf/include/include/Graphs/ConsG.h +408 -0
- package/SVF-osx/svf/include/include/Graphs/ConsGEdge.h +353 -0
- package/SVF-osx/svf/include/include/Graphs/ConsGNode.h +391 -0
- package/SVF-osx/svf/include/include/Graphs/DOTGraphTraits.h +188 -0
- package/SVF-osx/svf/include/include/Graphs/GenericGraph.h +620 -0
- package/SVF-osx/svf/include/include/Graphs/GraphPrinter.h +111 -0
- package/SVF-osx/svf/include/include/Graphs/GraphTraits.h +150 -0
- package/SVF-osx/svf/include/include/Graphs/GraphWriter.h +380 -0
- package/SVF-osx/svf/include/include/Graphs/ICFG.h +331 -0
- package/SVF-osx/svf/include/include/Graphs/ICFGEdge.h +264 -0
- package/SVF-osx/svf/include/include/Graphs/ICFGNode.h +523 -0
- package/SVF-osx/svf/include/include/Graphs/ICFGStat.h +164 -0
- package/SVF-osx/svf/include/include/Graphs/IRGraph.h +243 -0
- package/SVF-osx/svf/include/include/Graphs/PTACallGraph.h +471 -0
- package/SVF-osx/svf/include/include/Graphs/SVFG.h +490 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGEdge.h +237 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGNode.h +513 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGOPT.h +362 -0
- package/SVF-osx/svf/include/include/Graphs/SVFGStat.h +273 -0
- package/SVF-osx/svf/include/include/Graphs/ThreadCallGraph.h +422 -0
- package/SVF-osx/svf/include/include/Graphs/VFG.h +664 -0
- package/SVF-osx/svf/include/include/Graphs/VFGEdge.h +295 -0
- package/SVF-osx/svf/include/include/Graphs/VFGNode.h +1197 -0
- package/SVF-osx/svf/include/include/MSSA/MSSAMuChi.h +722 -0
- package/SVF-osx/svf/include/include/MSSA/MemPartition.h +169 -0
- package/SVF-osx/svf/include/include/MSSA/MemRegion.h +491 -0
- package/SVF-osx/svf/include/include/MSSA/MemSSA.h +452 -0
- package/SVF-osx/svf/include/include/MSSA/SVFGBuilder.h +98 -0
- package/SVF-osx/svf/include/include/MTA/FSMPTA.h +270 -0
- package/SVF-osx/svf/include/include/MTA/LockAnalysis.h +517 -0
- package/SVF-osx/svf/include/include/MTA/MHP.h +565 -0
- package/SVF-osx/svf/include/include/MTA/MTA.h +101 -0
- package/SVF-osx/svf/include/include/MTA/MTAResultValidator.h +448 -0
- package/SVF-osx/svf/include/include/MTA/MTAStat.h +74 -0
- package/SVF-osx/svf/include/include/MTA/PCG.h +229 -0
- package/SVF-osx/svf/include/include/MTA/TCT.h +599 -0
- package/SVF-osx/svf/include/include/MemoryModel/AbstractPointsToDS.h +316 -0
- package/SVF-osx/svf/include/include/MemoryModel/ConditionalPT.h +878 -0
- package/SVF-osx/svf/include/include/MemoryModel/LocationSet.h +148 -0
- package/SVF-osx/svf/include/include/MemoryModel/MutablePointsToDS.h +1025 -0
- package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToCache.h +463 -0
- package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToDS.h +955 -0
- package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysis.h +452 -0
- package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysisImpl.h +590 -0
- package/SVF-osx/svf/include/include/MemoryModel/PointsTo.h +255 -0
- package/SVF-osx/svf/include/include/MemoryModel/SVFLoop.h +164 -0
- package/SVF-osx/svf/include/include/SABER/DoubleFreeChecker.h +76 -0
- package/SVF-osx/svf/include/include/SABER/FileChecker.h +82 -0
- package/SVF-osx/svf/include/include/SABER/LeakChecker.h +124 -0
- package/SVF-osx/svf/include/include/SABER/ProgSlice.h +313 -0
- package/SVF-osx/svf/include/include/SABER/SaberCheckerAPI.h +166 -0
- package/SVF-osx/svf/include/include/SABER/SaberCondAllocator.h +310 -0
- package/SVF-osx/svf/include/include/SABER/SaberSVFGBuilder.h +104 -0
- package/SVF-osx/svf/include/include/SABER/SrcSnkDDA.h +321 -0
- package/SVF-osx/svf/include/include/SABER/SrcSnkSolver.h +186 -0
- package/SVF-osx/svf/include/include/SVFIR/PAGBuilderFromFile.h +80 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFIR.h +659 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFModule.h +233 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFStatements.h +1136 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFType.h +527 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFValue.h +1120 -0
- package/SVF-osx/svf/include/include/SVFIR/SVFVariables.h +721 -0
- package/SVF-osx/svf/include/include/SVFIR/SymbolTableInfo.h +597 -0
- package/SVF-osx/svf/include/include/Util/Annotator.h +180 -0
- package/SVF-osx/svf/include/include/Util/BitVector.h +55 -0
- package/SVF-osx/svf/include/include/Util/CallGraphBuilder.h +74 -0
- package/SVF-osx/svf/include/include/Util/Casting.h +426 -0
- package/SVF-osx/svf/include/include/Util/CommandLine.h +530 -0
- package/SVF-osx/svf/include/include/Util/CoreBitVector.h +214 -0
- package/SVF-osx/svf/include/include/Util/CppUtil.h +81 -0
- package/SVF-osx/svf/include/include/Util/CxtStmt.h +501 -0
- package/SVF-osx/svf/include/include/Util/DPItem.h +618 -0
- package/SVF-osx/svf/include/include/Util/ExtAPI.h +339 -0
- package/SVF-osx/svf/include/include/Util/ExtAPI.json +5707 -0
- package/SVF-osx/svf/include/include/Util/GraphReachSolver.h +186 -0
- package/SVF-osx/svf/include/include/Util/NodeIDAllocator.h +194 -0
- package/SVF-osx/svf/include/include/Util/Options.h +266 -0
- package/SVF-osx/svf/include/include/Util/PTAStat.h +65 -0
- package/SVF-osx/svf/include/include/Util/SCC.h +354 -0
- package/SVF-osx/svf/include/include/Util/SVFStat.h +100 -0
- package/SVF-osx/svf/include/include/Util/SVFUtil.h +660 -0
- package/SVF-osx/svf/include/include/Util/SparseBitVector.h +1202 -0
- package/SVF-osx/svf/include/include/Util/ThreadAPI.h +330 -0
- package/SVF-osx/svf/include/include/Util/WorkList.h +317 -0
- package/SVF-osx/svf/include/include/Util/Z3Expr.h +318 -0
- package/SVF-osx/svf/include/include/Util/cJSON.h +300 -0
- package/SVF-osx/svf/include/include/Util/iterator.h +407 -0
- package/SVF-osx/svf/include/include/Util/iterator_range.h +76 -0
- package/SVF-osx/svf/include/include/WPA/Andersen.h +416 -0
- package/SVF-osx/svf/include/include/WPA/AndersenPWC.h +160 -0
- package/SVF-osx/svf/include/include/WPA/CSC.h +95 -0
- package/SVF-osx/svf/include/include/WPA/FlowSensitive.h +317 -0
- package/SVF-osx/svf/include/include/WPA/Steensgaard.h +126 -0
- package/SVF-osx/svf/include/include/WPA/TypeAnalysis.h +83 -0
- package/SVF-osx/svf/include/include/WPA/VersionedFlowSensitive.h +287 -0
- package/SVF-osx/svf/include/include/WPA/WPAFSSolver.h +254 -0
- package/SVF-osx/svf/include/include/WPA/WPAPass.h +119 -0
- package/SVF-osx/svf/include/include/WPA/WPASolver.h +205 -0
- package/SVF-osx/svf/include/include/WPA/WPAStat.h +222 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BasicTypes.h +250 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BreakConstantExpr.h +94 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/CHGBuilder.h +73 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/DCHG.h +484 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/ICFGBuilder.h +106 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMLoopAnalysis.h +61 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMModule.h +360 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMUtil.h +466 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SVFIRBuilder.h +417 -0
- package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SymbolTableBuilder.h +110 -0
- package/package.json +1 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
//===----- CHG.h -- Class hirachary graph ---------------------------//
|
|
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
|
+
* CHG.h (previously CHA.h)
|
|
25
|
+
*
|
|
26
|
+
* Created on: Apr 13, 2016
|
|
27
|
+
* Author: Xiaokang Fan
|
|
28
|
+
*
|
|
29
|
+
* Created on: Aug 24, 2019
|
|
30
|
+
* Author: Mohamad Barbar
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
#ifndef CHA_H_
|
|
34
|
+
#define CHA_H_
|
|
35
|
+
|
|
36
|
+
#include "SVFIR/SVFModule.h"
|
|
37
|
+
#include "Graphs/GenericGraph.h"
|
|
38
|
+
#include "Util/WorkList.h"
|
|
39
|
+
|
|
40
|
+
namespace SVF
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
class SVFModule;
|
|
44
|
+
class CHNode;
|
|
45
|
+
|
|
46
|
+
typedef Set<const SVFGlobalValue*> VTableSet;
|
|
47
|
+
typedef Set<const SVFFunction*> VFunSet;
|
|
48
|
+
|
|
49
|
+
/// Common base for class hierarchy graph. Only implements what PointerAnalysis needs.
|
|
50
|
+
class CommonCHGraph
|
|
51
|
+
{
|
|
52
|
+
public:
|
|
53
|
+
virtual ~CommonCHGraph() { };
|
|
54
|
+
enum CHGKind
|
|
55
|
+
{
|
|
56
|
+
Standard,
|
|
57
|
+
DI
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
virtual bool csHasVFnsBasedonCHA(CallSite cs) = 0;
|
|
61
|
+
virtual const VFunSet &getCSVFsBasedonCHA(CallSite cs) = 0;
|
|
62
|
+
virtual bool csHasVtblsBasedonCHA(CallSite cs) = 0;
|
|
63
|
+
virtual const VTableSet &getCSVtblsBasedonCHA(CallSite cs) = 0;
|
|
64
|
+
virtual void getVFnsFromVtbls(CallSite cs, const VTableSet &vtbls, VFunSet &virtualFunctions) = 0;
|
|
65
|
+
|
|
66
|
+
CHGKind getKind(void) const
|
|
67
|
+
{
|
|
68
|
+
return kind;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected:
|
|
72
|
+
CHGKind kind;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
typedef GenericEdge<CHNode> GenericCHEdgeTy;
|
|
77
|
+
class CHEdge: public GenericCHEdgeTy
|
|
78
|
+
{
|
|
79
|
+
public:
|
|
80
|
+
typedef enum
|
|
81
|
+
{
|
|
82
|
+
INHERITANCE = 0x1, // inheritance relation
|
|
83
|
+
INSTANTCE = 0x2 // template-instance relation
|
|
84
|
+
} CHEDGETYPE;
|
|
85
|
+
|
|
86
|
+
typedef GenericNode<CHNode,CHEdge>::GEdgeSetTy CHEdgeSetTy;
|
|
87
|
+
|
|
88
|
+
CHEdge(CHNode *s, CHNode *d, CHEDGETYPE et, GEdgeFlag k = 0):
|
|
89
|
+
GenericCHEdgeTy(s,d,k)
|
|
90
|
+
{
|
|
91
|
+
edgeType = et;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
CHEDGETYPE getEdgeType() const
|
|
95
|
+
{
|
|
96
|
+
return edgeType;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private:
|
|
100
|
+
CHEDGETYPE edgeType;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
typedef GenericNode<CHNode,CHEdge> GenericCHNodeTy;
|
|
104
|
+
class CHNode: public GenericCHNodeTy
|
|
105
|
+
{
|
|
106
|
+
public:
|
|
107
|
+
typedef enum
|
|
108
|
+
{
|
|
109
|
+
PURE_ABSTRACT = 0x1, // pure virtual abstract class
|
|
110
|
+
MULTI_INHERITANCE = 0x2, // multi inheritance class
|
|
111
|
+
TEMPLATE = 0x04 // template class
|
|
112
|
+
} CLASSATTR;
|
|
113
|
+
|
|
114
|
+
typedef std::vector<const SVFFunction*> FuncVector;
|
|
115
|
+
|
|
116
|
+
CHNode (const std::string name, NodeID i = 0, GNodeK k = 0):
|
|
117
|
+
GenericCHNodeTy(i, k), vtable(nullptr), className(name), flags(0)
|
|
118
|
+
{
|
|
119
|
+
}
|
|
120
|
+
~CHNode()
|
|
121
|
+
{
|
|
122
|
+
}
|
|
123
|
+
std::string getName() const
|
|
124
|
+
{
|
|
125
|
+
return className;
|
|
126
|
+
}
|
|
127
|
+
/// Flags
|
|
128
|
+
//@{
|
|
129
|
+
inline void setFlag(CLASSATTR mask)
|
|
130
|
+
{
|
|
131
|
+
flags |= mask;
|
|
132
|
+
}
|
|
133
|
+
inline bool hasFlag(CLASSATTR mask) const
|
|
134
|
+
{
|
|
135
|
+
return (flags & mask) == mask;
|
|
136
|
+
}
|
|
137
|
+
//@}
|
|
138
|
+
|
|
139
|
+
/// Attribute
|
|
140
|
+
//@{
|
|
141
|
+
inline void setPureAbstract()
|
|
142
|
+
{
|
|
143
|
+
setFlag(PURE_ABSTRACT);
|
|
144
|
+
}
|
|
145
|
+
inline void setMultiInheritance()
|
|
146
|
+
{
|
|
147
|
+
setFlag(MULTI_INHERITANCE);
|
|
148
|
+
}
|
|
149
|
+
inline void setTemplate()
|
|
150
|
+
{
|
|
151
|
+
setFlag(TEMPLATE);
|
|
152
|
+
}
|
|
153
|
+
inline bool isPureAbstract() const
|
|
154
|
+
{
|
|
155
|
+
return hasFlag(PURE_ABSTRACT);
|
|
156
|
+
}
|
|
157
|
+
inline bool isMultiInheritance() const
|
|
158
|
+
{
|
|
159
|
+
return hasFlag(MULTI_INHERITANCE);
|
|
160
|
+
}
|
|
161
|
+
inline bool isTemplate() const
|
|
162
|
+
{
|
|
163
|
+
return hasFlag(TEMPLATE);
|
|
164
|
+
}
|
|
165
|
+
//@}
|
|
166
|
+
|
|
167
|
+
void addVirtualFunctionVector(FuncVector vfuncvec)
|
|
168
|
+
{
|
|
169
|
+
virtualFunctionVectors.push_back(vfuncvec);
|
|
170
|
+
}
|
|
171
|
+
const std::vector<FuncVector> &getVirtualFunctionVectors() const
|
|
172
|
+
{
|
|
173
|
+
return virtualFunctionVectors;
|
|
174
|
+
}
|
|
175
|
+
void getVirtualFunctions(u32_t idx, FuncVector &virtualFunctions) const;
|
|
176
|
+
|
|
177
|
+
const SVFGlobalValue *getVTable() const
|
|
178
|
+
{
|
|
179
|
+
return vtable;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void setVTable(const SVFGlobalValue *vtbl)
|
|
183
|
+
{
|
|
184
|
+
vtable = vtbl;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private:
|
|
188
|
+
const SVFGlobalValue* vtable;
|
|
189
|
+
std::string className;
|
|
190
|
+
size_t flags;
|
|
191
|
+
/*
|
|
192
|
+
* virtual functions inherited from different classes are separately stored
|
|
193
|
+
* to model different vtables inherited from different fathers.
|
|
194
|
+
*
|
|
195
|
+
* Example:
|
|
196
|
+
* class C: public A, public B
|
|
197
|
+
* vtableC = {Af1, Af2, ..., inttoptr, Bg1, Bg2, ...} ("inttoptr"
|
|
198
|
+
* instruction works as the delimiter for separating virtual functions
|
|
199
|
+
* inherited from different classes)
|
|
200
|
+
*
|
|
201
|
+
* virtualFunctionVectors = {{Af1, Af2, ...}, {Bg1, Bg2, ...}}
|
|
202
|
+
*/
|
|
203
|
+
std::vector<FuncVector> virtualFunctionVectors;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/// class hierarchy graph
|
|
207
|
+
typedef GenericGraph<CHNode,CHEdge> GenericCHGraphTy;
|
|
208
|
+
class CHGraph: public CommonCHGraph, public GenericCHGraphTy
|
|
209
|
+
{
|
|
210
|
+
friend class CHGBuilder;
|
|
211
|
+
|
|
212
|
+
public:
|
|
213
|
+
typedef Set<const CHNode*> CHNodeSetTy;
|
|
214
|
+
typedef FIFOWorkList<const CHNode*> WorkList;
|
|
215
|
+
typedef Map<std::string, CHNodeSetTy> NameToCHNodesMap;
|
|
216
|
+
typedef Map<CallSite, CHNodeSetTy> CallSiteToCHNodesMap;
|
|
217
|
+
typedef Map<CallSite, VTableSet> CallSiteToVTableSetMap;
|
|
218
|
+
typedef Map<CallSite, VFunSet> CallSiteToVFunSetMap;
|
|
219
|
+
|
|
220
|
+
typedef enum
|
|
221
|
+
{
|
|
222
|
+
CONSTRUCTOR = 0x1, // connect node based on constructor
|
|
223
|
+
DESTRUCTOR = 0x2 // connect node based on destructor
|
|
224
|
+
} RELATIONTYPE;
|
|
225
|
+
|
|
226
|
+
CHGraph(SVFModule* svfModule): svfMod(svfModule), classNum(0), vfID(0), buildingCHGTime(0)
|
|
227
|
+
{
|
|
228
|
+
this->kind = Standard;
|
|
229
|
+
}
|
|
230
|
+
~CHGraph() override = default;
|
|
231
|
+
|
|
232
|
+
void addEdge(const std::string className,
|
|
233
|
+
const std::string baseClassName,
|
|
234
|
+
CHEdge::CHEDGETYPE edgeType);
|
|
235
|
+
CHNode *getNode(const std::string name) const;
|
|
236
|
+
void getVFnsFromVtbls(CallSite cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
|
|
237
|
+
void dump(const std::string& filename);
|
|
238
|
+
void view();
|
|
239
|
+
void printCH();
|
|
240
|
+
|
|
241
|
+
inline u32_t getVirtualFunctionID(const SVFFunction* vfn) const
|
|
242
|
+
{
|
|
243
|
+
Map<const SVFFunction*, u32_t>::const_iterator it =
|
|
244
|
+
virtualFunctionToIDMap.find(vfn);
|
|
245
|
+
if (it != virtualFunctionToIDMap.end())
|
|
246
|
+
return it->second;
|
|
247
|
+
else
|
|
248
|
+
return -1;
|
|
249
|
+
}
|
|
250
|
+
inline const SVFFunction* getVirtualFunctionBasedonID(u32_t id) const
|
|
251
|
+
{
|
|
252
|
+
Map<const SVFFunction*, u32_t>::const_iterator it, eit;
|
|
253
|
+
for (it = virtualFunctionToIDMap.begin(), eit =
|
|
254
|
+
virtualFunctionToIDMap.end(); it != eit; ++it)
|
|
255
|
+
{
|
|
256
|
+
if (it->second == id)
|
|
257
|
+
return it->first;
|
|
258
|
+
}
|
|
259
|
+
return nullptr;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
inline void addInstances(const std::string templateName, CHNode* node)
|
|
263
|
+
{
|
|
264
|
+
NameToCHNodesMap::iterator it = templateNameToInstancesMap.find(
|
|
265
|
+
templateName);
|
|
266
|
+
if (it != templateNameToInstancesMap.end())
|
|
267
|
+
it->second.insert(node);
|
|
268
|
+
else
|
|
269
|
+
templateNameToInstancesMap[templateName].insert(node);
|
|
270
|
+
}
|
|
271
|
+
inline const CHNodeSetTy &getDescendants(const std::string className)
|
|
272
|
+
{
|
|
273
|
+
return classNameToDescendantsMap[className];
|
|
274
|
+
}
|
|
275
|
+
inline const CHNodeSetTy &getInstances(const std::string className)
|
|
276
|
+
{
|
|
277
|
+
return templateNameToInstancesMap[className];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
inline bool csHasVtblsBasedonCHA(CallSite cs) override
|
|
281
|
+
{
|
|
282
|
+
CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
|
|
283
|
+
return it != csToCHAVtblsMap.end();
|
|
284
|
+
}
|
|
285
|
+
inline bool csHasVFnsBasedonCHA(CallSite cs) override
|
|
286
|
+
{
|
|
287
|
+
CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
|
|
288
|
+
return it != csToCHAVFnsMap.end();
|
|
289
|
+
}
|
|
290
|
+
inline const VTableSet &getCSVtblsBasedonCHA(CallSite cs) override
|
|
291
|
+
{
|
|
292
|
+
CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
|
|
293
|
+
assert(it != csToCHAVtblsMap.end() && "cs does not have vtabls based on CHA.");
|
|
294
|
+
return it->second;
|
|
295
|
+
}
|
|
296
|
+
inline const VFunSet &getCSVFsBasedonCHA(CallSite cs) override
|
|
297
|
+
{
|
|
298
|
+
CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
|
|
299
|
+
assert(it != csToCHAVFnsMap.end() && "cs does not have vfns based on CHA.");
|
|
300
|
+
return it->second;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
static inline bool classof(const CommonCHGraph *chg)
|
|
304
|
+
{
|
|
305
|
+
return chg->getKind() == Standard;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
private:
|
|
310
|
+
SVFModule* svfMod;
|
|
311
|
+
u32_t classNum;
|
|
312
|
+
u32_t vfID;
|
|
313
|
+
double buildingCHGTime;
|
|
314
|
+
Map<std::string, CHNode *> classNameToNodeMap;
|
|
315
|
+
NameToCHNodesMap classNameToDescendantsMap;
|
|
316
|
+
NameToCHNodesMap classNameToAncestorsMap;
|
|
317
|
+
NameToCHNodesMap classNameToInstAndDescsMap;
|
|
318
|
+
NameToCHNodesMap templateNameToInstancesMap;
|
|
319
|
+
CallSiteToCHNodesMap csToClassesMap;
|
|
320
|
+
|
|
321
|
+
Map<const SVFFunction*, u32_t> virtualFunctionToIDMap;
|
|
322
|
+
CallSiteToVTableSetMap csToCHAVtblsMap;
|
|
323
|
+
CallSiteToVFunSetMap csToCHAVFnsMap;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
} // End namespace SVF
|
|
327
|
+
|
|
328
|
+
namespace SVF
|
|
329
|
+
{
|
|
330
|
+
/* !
|
|
331
|
+
* GenericGraphTraits specializations for generic graph algorithms.
|
|
332
|
+
* Provide graph traits for traversing from a constraint node using standard graph traversals.
|
|
333
|
+
*/
|
|
334
|
+
template<> struct GenericGraphTraits<SVF::CHNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::CHNode,SVF::CHEdge>* >
|
|
335
|
+
{
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
/// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
|
|
339
|
+
template<>
|
|
340
|
+
struct GenericGraphTraits<Inverse<SVF::CHNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::CHNode,SVF::CHEdge>* > >
|
|
341
|
+
{
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
template<> struct GenericGraphTraits<SVF::CHGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::CHNode,SVF::CHEdge>* >
|
|
345
|
+
{
|
|
346
|
+
typedef SVF::CHNode *NodeRef;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
} // End namespace llvm
|
|
350
|
+
|
|
351
|
+
#endif /* CHA_H_ */
|