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,1120 @@
|
|
|
1
|
+
//===- BasicTypes.h -- Basic types used in SVF-------------------------------//
|
|
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
|
+
* BasicTypes.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Apr 1, 2014
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef INCLUDE_SVFIR_SVFVALUE_H_
|
|
31
|
+
#define INCLUDE_SVFIR_SVFVALUE_H_
|
|
32
|
+
|
|
33
|
+
#include "SVFIR/SVFType.h"
|
|
34
|
+
#include "Graphs/GraphPrinter.h"
|
|
35
|
+
#include "Util/Casting.h"
|
|
36
|
+
|
|
37
|
+
namespace SVF
|
|
38
|
+
{
|
|
39
|
+
|
|
40
|
+
/// LLVM Aliases and constants
|
|
41
|
+
typedef SVF::GraphPrinter GraphPrinter;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class SVFInstruction;
|
|
45
|
+
class SVFBasicBlock;
|
|
46
|
+
class SVFArgument;
|
|
47
|
+
class SVFFunction;
|
|
48
|
+
class SVFType;
|
|
49
|
+
|
|
50
|
+
class SVFLoopAndDomInfo
|
|
51
|
+
{
|
|
52
|
+
public:
|
|
53
|
+
typedef Set<const SVFBasicBlock*> BBSet;
|
|
54
|
+
typedef std::vector<const SVFBasicBlock*> BBList;
|
|
55
|
+
typedef BBList LoopBBs;
|
|
56
|
+
|
|
57
|
+
private:
|
|
58
|
+
BBList reachableBBs; ///< reachable BasicBlocks from the function entry.
|
|
59
|
+
Map<const SVFBasicBlock*,BBSet> dtBBsMap; ///< map a BasicBlock to BasicBlocks it Dominates
|
|
60
|
+
Map<const SVFBasicBlock*,BBSet> pdtBBsMap; ///< map a BasicBlock to BasicBlocks it PostDominates
|
|
61
|
+
Map<const SVFBasicBlock*,BBSet> dfBBsMap; ///< map a BasicBlock to its Dominate Frontier BasicBlocks
|
|
62
|
+
Map<const SVFBasicBlock*, LoopBBs> bb2LoopMap; ///< map a BasicBlock (if it is in a loop) to all the BasicBlocks in this loop
|
|
63
|
+
public:
|
|
64
|
+
SVFLoopAndDomInfo()
|
|
65
|
+
{
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
virtual ~SVFLoopAndDomInfo() {}
|
|
69
|
+
|
|
70
|
+
inline const Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap() const
|
|
71
|
+
{
|
|
72
|
+
return dfBBsMap;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
inline Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap()
|
|
76
|
+
{
|
|
77
|
+
return dfBBsMap;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
inline bool hasLoopInfo(const SVFBasicBlock* bb) const
|
|
81
|
+
{
|
|
82
|
+
return bb2LoopMap.find(bb)!=bb2LoopMap.end();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const;
|
|
86
|
+
|
|
87
|
+
inline const SVFBasicBlock* getLoopHeader(const LoopBBs& lp) const
|
|
88
|
+
{
|
|
89
|
+
assert(!lp.empty() && "this is not a loop, empty basic block");
|
|
90
|
+
return lp.front();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
inline bool loopContainsBB(const LoopBBs& lp, const SVFBasicBlock* bb) const
|
|
94
|
+
{
|
|
95
|
+
return std::find(lp.begin(), lp.end(), bb)!=lp.end();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
inline void addToBB2LoopMap(const SVFBasicBlock* bb, const SVFBasicBlock* loopBB)
|
|
99
|
+
{
|
|
100
|
+
bb2LoopMap[bb].push_back(loopBB);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
inline const Map<const SVFBasicBlock*,BBSet>& getPostDomTreeMap() const
|
|
104
|
+
{
|
|
105
|
+
return pdtBBsMap;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
inline Map<const SVFBasicBlock*,BBSet>& getPostDomTreeMap()
|
|
109
|
+
{
|
|
110
|
+
return pdtBBsMap;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
inline Map<const SVFBasicBlock*,BBSet>& getDomTreeMap()
|
|
114
|
+
{
|
|
115
|
+
return dtBBsMap;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
inline const Map<const SVFBasicBlock*,BBSet>& getDomTreeMap() const
|
|
119
|
+
{
|
|
120
|
+
return dtBBsMap;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
inline bool isUnreachable(const SVFBasicBlock* bb) const
|
|
124
|
+
{
|
|
125
|
+
return std::find(reachableBBs.begin(), reachableBBs.end(), bb)==reachableBBs.end();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
inline const BBList& getReachableBBs() const
|
|
129
|
+
{
|
|
130
|
+
return reachableBBs;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
inline void setReachableBBs(BBList& bbs)
|
|
134
|
+
{
|
|
135
|
+
reachableBBs = bbs;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const;
|
|
139
|
+
|
|
140
|
+
bool isLoopHeader(const SVFBasicBlock* bb) const;
|
|
141
|
+
|
|
142
|
+
bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
|
|
143
|
+
|
|
144
|
+
bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
class SVFValue
|
|
148
|
+
{
|
|
149
|
+
friend class LLVMModuleSet;
|
|
150
|
+
|
|
151
|
+
public:
|
|
152
|
+
typedef s64_t GNodeK;
|
|
153
|
+
|
|
154
|
+
enum SVFValKind
|
|
155
|
+
{
|
|
156
|
+
SVFVal,
|
|
157
|
+
SVFFunc,
|
|
158
|
+
SVFBB,
|
|
159
|
+
SVFInst,
|
|
160
|
+
SVFCall,
|
|
161
|
+
SVFVCall,
|
|
162
|
+
SVFGlob,
|
|
163
|
+
SVFArg,
|
|
164
|
+
SVFConst,
|
|
165
|
+
SVFConstData,
|
|
166
|
+
SVFConstInt,
|
|
167
|
+
SVFConstFP,
|
|
168
|
+
SVFNullPtr,
|
|
169
|
+
SVFBlackHole,
|
|
170
|
+
SVFMetaAsValue,
|
|
171
|
+
SVFOther
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
private:
|
|
175
|
+
GNodeK kind; ///< used for classof
|
|
176
|
+
bool ptrInUncalledFun; ///< true if this pointer is in an uncalled function
|
|
177
|
+
bool constDataOrAggData; ///< true if this value is a ConstantData (e.g., numbers, string, floats) or a constantAggregate
|
|
178
|
+
|
|
179
|
+
protected:
|
|
180
|
+
const SVFType* type; ///< Type of this SVFValue
|
|
181
|
+
std::string name; ///< Short name of this value for debugging
|
|
182
|
+
std::string sourceLoc; ///< Source code information of this value
|
|
183
|
+
/// Constructor
|
|
184
|
+
SVFValue(const std::string& val, const SVFType* ty, SVFValKind k): kind(k),
|
|
185
|
+
ptrInUncalledFun(false), constDataOrAggData(SVFConstData==k), type(ty),
|
|
186
|
+
name(val), sourceLoc("No source code Info")
|
|
187
|
+
{
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
191
|
+
inline void setConstDataOrAggData()
|
|
192
|
+
{
|
|
193
|
+
constDataOrAggData = true;
|
|
194
|
+
}
|
|
195
|
+
inline void setPtrInUncalledFunction()
|
|
196
|
+
{
|
|
197
|
+
ptrInUncalledFun = true;
|
|
198
|
+
}
|
|
199
|
+
///@}
|
|
200
|
+
public:
|
|
201
|
+
SVFValue() = delete;
|
|
202
|
+
virtual ~SVFValue() = default;
|
|
203
|
+
|
|
204
|
+
/// Get the type of this SVFValue
|
|
205
|
+
inline GNodeK getKind() const
|
|
206
|
+
{
|
|
207
|
+
return kind;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
inline virtual const std::string getName() const
|
|
211
|
+
{
|
|
212
|
+
return name;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
inline virtual const SVFType* getType() const
|
|
216
|
+
{
|
|
217
|
+
return type;
|
|
218
|
+
}
|
|
219
|
+
inline bool isConstDataOrAggData() const
|
|
220
|
+
{
|
|
221
|
+
return constDataOrAggData;
|
|
222
|
+
}
|
|
223
|
+
inline bool ptrInUncalledFunction() const
|
|
224
|
+
{
|
|
225
|
+
return ptrInUncalledFun;
|
|
226
|
+
}
|
|
227
|
+
inline bool isblackHole() const
|
|
228
|
+
{
|
|
229
|
+
return getKind() == SVFBlackHole;;
|
|
230
|
+
}
|
|
231
|
+
inline bool isNullPtr() const
|
|
232
|
+
{
|
|
233
|
+
return getKind() == SVFNullPtr;
|
|
234
|
+
}
|
|
235
|
+
inline virtual void setSourceLoc(const std::string& sourceCodeInfo)
|
|
236
|
+
{
|
|
237
|
+
sourceLoc = sourceCodeInfo;
|
|
238
|
+
}
|
|
239
|
+
inline virtual const std::string getSourceLoc() const
|
|
240
|
+
{
|
|
241
|
+
return sourceLoc;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// Needs to be implemented by a specific SVF front end (e.g., the implementation in LLVMUtil)
|
|
245
|
+
virtual const std::string toString() const;
|
|
246
|
+
|
|
247
|
+
/// Overloading operator << for dumping ICFG node ID
|
|
248
|
+
//@{
|
|
249
|
+
friend OutStream& operator<< (OutStream &o, const SVFValue &node)
|
|
250
|
+
{
|
|
251
|
+
o << node.toString();
|
|
252
|
+
return o;
|
|
253
|
+
}
|
|
254
|
+
//@}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
class SVFFunction : public SVFValue
|
|
258
|
+
{
|
|
259
|
+
friend class LLVMModuleSet;
|
|
260
|
+
|
|
261
|
+
public:
|
|
262
|
+
typedef std::vector<const SVFBasicBlock*>::const_iterator const_iterator;
|
|
263
|
+
typedef SVFLoopAndDomInfo::BBSet BBSet;
|
|
264
|
+
typedef SVFLoopAndDomInfo::BBList BBList;
|
|
265
|
+
typedef SVFLoopAndDomInfo::LoopBBs LoopBBs;
|
|
266
|
+
|
|
267
|
+
private:
|
|
268
|
+
bool isDecl; /// return true if this function does not have a body
|
|
269
|
+
bool intricsic; /// return true if this function is an intricsic function (e.g., llvm.dbg), which does not reside in the application code
|
|
270
|
+
bool addrTaken; /// return true if this function is address-taken (for indirect call purposes)
|
|
271
|
+
bool isUncalled; /// return true if this function is never called
|
|
272
|
+
bool isNotRet; /// return true if this function never returns
|
|
273
|
+
bool varArg; /// return true if this function supports variable arguments
|
|
274
|
+
const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVFFunction
|
|
275
|
+
SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
|
|
276
|
+
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
|
|
277
|
+
std::vector<const SVFBasicBlock*> allBBs; /// all BasicBlocks of this function
|
|
278
|
+
std::vector<const SVFArgument*> allArgs; /// all formal arguments of this function
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
protected:
|
|
282
|
+
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
283
|
+
inline void addBasicBlock(const SVFBasicBlock* bb)
|
|
284
|
+
{
|
|
285
|
+
allBBs.push_back(bb);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
inline void addArgument(SVFArgument* arg)
|
|
289
|
+
{
|
|
290
|
+
allArgs.push_back(arg);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
inline void setIsUncalledFunction(bool uncalledFunction)
|
|
294
|
+
{
|
|
295
|
+
isUncalled = uncalledFunction;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
inline void setIsNotRet(bool notRet)
|
|
299
|
+
{
|
|
300
|
+
isNotRet = notRet;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
inline void setDefFunForMultipleModule(const SVFFunction* deffun)
|
|
304
|
+
{
|
|
305
|
+
realDefFun = deffun;
|
|
306
|
+
}
|
|
307
|
+
/// @}
|
|
308
|
+
|
|
309
|
+
public:
|
|
310
|
+
SVFFunction(const std::string& f, const SVFType* ty,const SVFFunctionType* ft, bool declare, bool intricsic, bool addrTaken, bool varg, SVFLoopAndDomInfo* ld);
|
|
311
|
+
SVFFunction(const std::string& f) = delete;
|
|
312
|
+
SVFFunction(void) = delete;
|
|
313
|
+
virtual ~SVFFunction();
|
|
314
|
+
|
|
315
|
+
static inline bool classof(const SVFValue *node)
|
|
316
|
+
{
|
|
317
|
+
return node->getKind() == SVFFunc;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
inline SVFLoopAndDomInfo* getLoopAndDomInfo()
|
|
321
|
+
{
|
|
322
|
+
return loopAndDom;
|
|
323
|
+
}
|
|
324
|
+
inline bool isDeclaration() const
|
|
325
|
+
{
|
|
326
|
+
return isDecl;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
inline bool isIntrinsic() const
|
|
330
|
+
{
|
|
331
|
+
return intricsic;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
inline bool hasAddressTaken() const
|
|
335
|
+
{
|
|
336
|
+
return addrTaken;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/// Returns the FunctionType
|
|
340
|
+
inline const SVFFunctionType* getFunctionType() const
|
|
341
|
+
{
|
|
342
|
+
return funcType;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/// Returns the FunctionType
|
|
346
|
+
inline const SVFType* getReturnType() const
|
|
347
|
+
{
|
|
348
|
+
return funcType->getReturnType();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
inline const SVFFunction* getDefFunForMultipleModule() const
|
|
352
|
+
{
|
|
353
|
+
if(realDefFun==nullptr)
|
|
354
|
+
return this;
|
|
355
|
+
return realDefFun;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
u32_t arg_size() const;
|
|
359
|
+
const SVFArgument* getArg(u32_t idx) const;
|
|
360
|
+
bool isVarArg() const;
|
|
361
|
+
|
|
362
|
+
inline bool hasBasicBlock() const
|
|
363
|
+
{
|
|
364
|
+
return !allBBs.empty();
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
inline const SVFBasicBlock* getEntryBlock() const
|
|
368
|
+
{
|
|
369
|
+
assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
|
|
370
|
+
return allBBs.front();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
inline const SVFBasicBlock* getExitBB() const
|
|
374
|
+
{
|
|
375
|
+
assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
|
|
376
|
+
return allBBs.back();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
inline const SVFBasicBlock* front() const
|
|
380
|
+
{
|
|
381
|
+
return getEntryBlock();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
inline const SVFBasicBlock* back() const
|
|
385
|
+
{
|
|
386
|
+
return getExitBB();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
inline const_iterator begin() const
|
|
390
|
+
{
|
|
391
|
+
return allBBs.begin();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
inline const_iterator end() const
|
|
395
|
+
{
|
|
396
|
+
return allBBs.end();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
inline const std::vector<const SVFBasicBlock*>& getBasicBlockList() const
|
|
400
|
+
{
|
|
401
|
+
return allBBs;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
inline const std::vector<const SVFBasicBlock*>& getReachableBBs() const
|
|
405
|
+
{
|
|
406
|
+
return loopAndDom->getReachableBBs();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
inline bool isUncalledFunction() const
|
|
410
|
+
{
|
|
411
|
+
return isUncalled;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
inline bool isNotRetFunction() const
|
|
415
|
+
{
|
|
416
|
+
return isNotRet;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
inline void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const
|
|
420
|
+
{
|
|
421
|
+
return loopAndDom->getExitBlocksOfLoop(bb,exitbbs);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
inline bool hasLoopInfo(const SVFBasicBlock* bb) const
|
|
425
|
+
{
|
|
426
|
+
return loopAndDom->hasLoopInfo(bb);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const
|
|
430
|
+
{
|
|
431
|
+
return loopAndDom->getLoopInfo(bb);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
inline const SVFBasicBlock* getLoopHeader(const BBList& lp) const
|
|
435
|
+
{
|
|
436
|
+
return loopAndDom->getLoopHeader(lp);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
inline bool loopContainsBB(const BBList& lp, const SVFBasicBlock* bb) const
|
|
440
|
+
{
|
|
441
|
+
return loopAndDom->loopContainsBB(lp,bb);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
inline const Map<const SVFBasicBlock*,BBSet>& getDomTreeMap() const
|
|
445
|
+
{
|
|
446
|
+
return loopAndDom->getDomTreeMap();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
inline const Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap() const
|
|
450
|
+
{
|
|
451
|
+
return loopAndDom->getDomFrontierMap();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
inline bool isLoopHeader(const SVFBasicBlock* bb) const
|
|
455
|
+
{
|
|
456
|
+
return loopAndDom->isLoopHeader(bb);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
460
|
+
{
|
|
461
|
+
return loopAndDom->dominate(bbKey,bbValue);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
|
|
465
|
+
{
|
|
466
|
+
return loopAndDom->postDominate(bbKey,bbValue);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
class SVFBasicBlock : public SVFValue
|
|
472
|
+
{
|
|
473
|
+
friend class LLVMModuleSet;
|
|
474
|
+
|
|
475
|
+
public:
|
|
476
|
+
typedef std::vector<const SVFInstruction*>::const_iterator const_iterator;
|
|
477
|
+
|
|
478
|
+
private:
|
|
479
|
+
std::vector<const SVFInstruction*> allInsts; ///< all Instructions in this BasicBlock
|
|
480
|
+
std::vector<const SVFBasicBlock*> succBBs; ///< all successor BasicBlocks of this BasicBlock
|
|
481
|
+
std::vector<const SVFBasicBlock*> predBBs; ///< all predecessor BasicBlocks of this BasicBlock
|
|
482
|
+
const SVFFunction* fun; /// Function where this BasicBlock is
|
|
483
|
+
|
|
484
|
+
protected:
|
|
485
|
+
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
486
|
+
inline void addInstruction(const SVFInstruction* inst)
|
|
487
|
+
{
|
|
488
|
+
allInsts.push_back(inst);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
inline void addSuccBasicBlock(const SVFBasicBlock* succ)
|
|
492
|
+
{
|
|
493
|
+
succBBs.push_back(succ);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
inline void addPredBasicBlock(const SVFBasicBlock* pred)
|
|
497
|
+
{
|
|
498
|
+
predBBs.push_back(pred);
|
|
499
|
+
}
|
|
500
|
+
/// @}
|
|
501
|
+
|
|
502
|
+
public:
|
|
503
|
+
SVFBasicBlock(const std::string& b, const SVFType* ty, const SVFFunction* f);
|
|
504
|
+
SVFBasicBlock() = delete;
|
|
505
|
+
~SVFBasicBlock() override;
|
|
506
|
+
|
|
507
|
+
static inline bool classof(const SVFValue *node)
|
|
508
|
+
{
|
|
509
|
+
return node->getKind() == SVFBB;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
inline const std::vector<const SVFInstruction*>& getInstructionList() const
|
|
513
|
+
{
|
|
514
|
+
return allInsts;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
inline const_iterator begin() const
|
|
518
|
+
{
|
|
519
|
+
return allInsts.begin();
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
inline const_iterator end() const
|
|
523
|
+
{
|
|
524
|
+
return allInsts.end();
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
inline const SVFFunction* getParent() const
|
|
528
|
+
{
|
|
529
|
+
return fun;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
inline const SVFFunction* getFunction() const
|
|
533
|
+
{
|
|
534
|
+
return fun;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
inline const SVFInstruction* front() const
|
|
538
|
+
{
|
|
539
|
+
return allInsts.front();
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
inline const SVFInstruction* back() const
|
|
543
|
+
{
|
|
544
|
+
return allInsts.back();
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/// Returns the terminator instruction if the block is well formed or null
|
|
548
|
+
/// if the block is not well formed.
|
|
549
|
+
const SVFInstruction* getTerminator() const;
|
|
550
|
+
|
|
551
|
+
inline const std::vector<const SVFBasicBlock*>& getSuccessors() const
|
|
552
|
+
{
|
|
553
|
+
return succBBs;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
inline const std::vector<const SVFBasicBlock*>& getPredecessors() const
|
|
557
|
+
{
|
|
558
|
+
return predBBs;
|
|
559
|
+
}
|
|
560
|
+
u32_t getNumSuccessors() const
|
|
561
|
+
{
|
|
562
|
+
return succBBs.size();
|
|
563
|
+
}
|
|
564
|
+
u32_t getBBSuccessorPos(const SVFBasicBlock* succbb);
|
|
565
|
+
u32_t getBBSuccessorPos(const SVFBasicBlock* succbb) const;
|
|
566
|
+
u32_t getBBPredecessorPos(const SVFBasicBlock* succbb);
|
|
567
|
+
u32_t getBBPredecessorPos(const SVFBasicBlock* succbb) const;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
class SVFInstruction : public SVFValue
|
|
571
|
+
{
|
|
572
|
+
public:
|
|
573
|
+
typedef std::vector<const SVFInstruction*> InstVec;
|
|
574
|
+
|
|
575
|
+
private:
|
|
576
|
+
const SVFBasicBlock* bb; /// The BasicBlock where this Instruction resides
|
|
577
|
+
bool terminator; /// return true if this is a terminator instruction
|
|
578
|
+
bool ret; /// return true if this is an return instruction of a function
|
|
579
|
+
InstVec succInsts; /// successor Instructions
|
|
580
|
+
InstVec predInsts; /// predecessor Instructions
|
|
581
|
+
|
|
582
|
+
public:
|
|
583
|
+
SVFInstruction(const std::string& i, const SVFType* ty, const SVFBasicBlock* b, bool tm, bool isRet, SVFValKind k = SVFInst);
|
|
584
|
+
SVFInstruction(const std::string& i) = delete;
|
|
585
|
+
SVFInstruction(void) = delete;
|
|
586
|
+
|
|
587
|
+
static inline bool classof(const SVFValue *node)
|
|
588
|
+
{
|
|
589
|
+
return node->getKind() == SVFInst ||
|
|
590
|
+
node->getKind() == SVFCall ||
|
|
591
|
+
node->getKind() == SVFVCall;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
inline const SVFBasicBlock* getParent() const
|
|
595
|
+
{
|
|
596
|
+
return bb;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
inline InstVec& getSuccInstructions()
|
|
600
|
+
{
|
|
601
|
+
return succInsts;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
inline InstVec& getPredInstructions()
|
|
605
|
+
{
|
|
606
|
+
return predInsts;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
inline const InstVec& getSuccInstructions() const
|
|
610
|
+
{
|
|
611
|
+
return succInsts;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
inline const InstVec& getPredInstructions() const
|
|
615
|
+
{
|
|
616
|
+
return predInsts;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
inline const SVFFunction* getFunction() const
|
|
620
|
+
{
|
|
621
|
+
return bb->getParent();
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
inline bool isTerminator() const
|
|
625
|
+
{
|
|
626
|
+
return terminator;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
inline bool isRetInst() const
|
|
630
|
+
{
|
|
631
|
+
return ret;
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
class SVFCallInst : public SVFInstruction
|
|
636
|
+
{
|
|
637
|
+
friend class LLVMModuleSet;
|
|
638
|
+
|
|
639
|
+
private:
|
|
640
|
+
std::vector<const SVFValue*> args;
|
|
641
|
+
bool varArg;
|
|
642
|
+
const SVFValue* calledVal;
|
|
643
|
+
|
|
644
|
+
protected:
|
|
645
|
+
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
646
|
+
inline void addArgument(const SVFValue* a)
|
|
647
|
+
{
|
|
648
|
+
args.push_back(a);
|
|
649
|
+
}
|
|
650
|
+
inline void setCalledOperand(const SVFValue* v)
|
|
651
|
+
{
|
|
652
|
+
calledVal = v;
|
|
653
|
+
}
|
|
654
|
+
/// @}
|
|
655
|
+
|
|
656
|
+
public:
|
|
657
|
+
SVFCallInst(const std::string& i, const SVFType* ty, const SVFBasicBlock* b, bool va, bool tm, SVFValKind k = SVFCall) :
|
|
658
|
+
SVFInstruction(i, ty, b, tm, false, k), varArg(va), calledVal(nullptr)
|
|
659
|
+
{
|
|
660
|
+
}
|
|
661
|
+
SVFCallInst(const std::string& i) = delete;
|
|
662
|
+
SVFCallInst(void) = delete;
|
|
663
|
+
|
|
664
|
+
static inline bool classof(const SVFValue *node)
|
|
665
|
+
{
|
|
666
|
+
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
667
|
+
}
|
|
668
|
+
static inline bool classof(const SVFInstruction *node)
|
|
669
|
+
{
|
|
670
|
+
return node->getKind() == SVFCall || node->getKind() == SVFVCall;
|
|
671
|
+
}
|
|
672
|
+
inline u32_t arg_size() const
|
|
673
|
+
{
|
|
674
|
+
return args.size();
|
|
675
|
+
}
|
|
676
|
+
inline bool arg_empty() const
|
|
677
|
+
{
|
|
678
|
+
return args.empty();
|
|
679
|
+
}
|
|
680
|
+
inline const SVFValue* getArgOperand(u32_t i) const
|
|
681
|
+
{
|
|
682
|
+
assert(i < arg_size() && "out of bound access of the argument");
|
|
683
|
+
return args[i];
|
|
684
|
+
}
|
|
685
|
+
inline u32_t getNumArgOperands() const
|
|
686
|
+
{
|
|
687
|
+
return arg_size();
|
|
688
|
+
}
|
|
689
|
+
inline const SVFValue* getCalledOperand() const
|
|
690
|
+
{
|
|
691
|
+
return calledVal;
|
|
692
|
+
}
|
|
693
|
+
inline bool isVarArg() const
|
|
694
|
+
{
|
|
695
|
+
return varArg;
|
|
696
|
+
}
|
|
697
|
+
inline const SVFFunction* getCalledFunction() const
|
|
698
|
+
{
|
|
699
|
+
return SVFUtil::dyn_cast<SVFFunction>(calledVal);
|
|
700
|
+
}
|
|
701
|
+
inline const SVFFunction* getCaller() const
|
|
702
|
+
{
|
|
703
|
+
return getFunction();
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
class SVFVirtualCallInst : public SVFCallInst
|
|
708
|
+
{
|
|
709
|
+
friend class LLVMModuleSet;
|
|
710
|
+
|
|
711
|
+
private:
|
|
712
|
+
const SVFValue* vCallVtblPtr; /// virtual table pointer
|
|
713
|
+
s32_t virtualFunIdx; /// virtual function index of the virtual table(s) at a virtual call
|
|
714
|
+
std::string funNameOfVcall; /// the function name of this virtual call
|
|
715
|
+
|
|
716
|
+
protected:
|
|
717
|
+
inline void setFunIdxInVtable(s32_t idx)
|
|
718
|
+
{
|
|
719
|
+
virtualFunIdx = idx;
|
|
720
|
+
}
|
|
721
|
+
inline void setFunNameOfVirtualCall(const std::string& name)
|
|
722
|
+
{
|
|
723
|
+
funNameOfVcall = name;
|
|
724
|
+
}
|
|
725
|
+
inline void setVtablePtr(const SVFValue* vptr)
|
|
726
|
+
{
|
|
727
|
+
vCallVtblPtr = vptr;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
public:
|
|
731
|
+
SVFVirtualCallInst(const std::string& i, const SVFType* ty, const SVFBasicBlock* b, bool vararg, bool tm) :
|
|
732
|
+
SVFCallInst(i,ty,b,vararg,tm, SVFVCall), vCallVtblPtr(nullptr), virtualFunIdx(-1), funNameOfVcall("")
|
|
733
|
+
{
|
|
734
|
+
}
|
|
735
|
+
inline const SVFValue* getVtablePtr() const
|
|
736
|
+
{
|
|
737
|
+
assert(vCallVtblPtr && "virtual call does not have a vtblptr? set it first");
|
|
738
|
+
return vCallVtblPtr;
|
|
739
|
+
}
|
|
740
|
+
inline s32_t getFunIdxInVtable() const
|
|
741
|
+
{
|
|
742
|
+
assert(virtualFunIdx >=0 && "virtual function idx is less than 0? not set yet?");
|
|
743
|
+
return virtualFunIdx;
|
|
744
|
+
}
|
|
745
|
+
inline const std::string& getFunNameOfVirtualCall() const
|
|
746
|
+
{
|
|
747
|
+
return funNameOfVcall;
|
|
748
|
+
}
|
|
749
|
+
static inline bool classof(const SVFValue *node)
|
|
750
|
+
{
|
|
751
|
+
return node->getKind() == SVFVCall;
|
|
752
|
+
}
|
|
753
|
+
static inline bool classof(const SVFInstruction *node)
|
|
754
|
+
{
|
|
755
|
+
return node->getKind() == SVFVCall;
|
|
756
|
+
}
|
|
757
|
+
static inline bool classof(const SVFCallInst *node)
|
|
758
|
+
{
|
|
759
|
+
return node->getKind() == SVFVCall;
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
class SVFConstant : public SVFValue
|
|
764
|
+
{
|
|
765
|
+
public:
|
|
766
|
+
SVFConstant(const std::string& _const, const SVFType* ty, SVFValKind k = SVFConst): SVFValue(_const, ty, k)
|
|
767
|
+
{
|
|
768
|
+
}
|
|
769
|
+
SVFConstant() = delete;
|
|
770
|
+
|
|
771
|
+
static inline bool classof(const SVFValue *node)
|
|
772
|
+
{
|
|
773
|
+
return node->getKind() == SVFConst ||
|
|
774
|
+
node->getKind() == SVFGlob ||
|
|
775
|
+
node->getKind() == SVFConstData ||
|
|
776
|
+
node->getKind() == SVFConstInt ||
|
|
777
|
+
node->getKind() == SVFConstFP ||
|
|
778
|
+
node->getKind() == SVFNullPtr ||
|
|
779
|
+
node->getKind() == SVFBlackHole;
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
class SVFGlobalValue : public SVFConstant
|
|
784
|
+
{
|
|
785
|
+
friend class LLVMModuleSet;
|
|
786
|
+
|
|
787
|
+
private:
|
|
788
|
+
const SVFValue* realDefGlobal; /// the definition of a function across multiple modules
|
|
789
|
+
|
|
790
|
+
protected:
|
|
791
|
+
inline void setDefGlobalForMultipleModule(const SVFValue* defg)
|
|
792
|
+
{
|
|
793
|
+
realDefGlobal = defg;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
public:
|
|
797
|
+
SVFGlobalValue(const std::string& _gv, const SVFType* ty): SVFConstant(_gv, ty, SVFValue::SVFGlob), realDefGlobal(nullptr)
|
|
798
|
+
{
|
|
799
|
+
}
|
|
800
|
+
SVFGlobalValue() = delete;
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
inline const SVFValue* getDefGlobalForMultipleModule() const
|
|
804
|
+
{
|
|
805
|
+
if(realDefGlobal==nullptr)
|
|
806
|
+
return this;
|
|
807
|
+
return realDefGlobal;
|
|
808
|
+
}
|
|
809
|
+
static inline bool classof(const SVFValue *node)
|
|
810
|
+
{
|
|
811
|
+
return node->getKind() == SVFGlob;
|
|
812
|
+
}
|
|
813
|
+
static inline bool classof(const SVFConstant *node)
|
|
814
|
+
{
|
|
815
|
+
return node->getKind() == SVFGlob;
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
class SVFArgument : public SVFValue
|
|
820
|
+
{
|
|
821
|
+
private:
|
|
822
|
+
const SVFFunction* fun;
|
|
823
|
+
u32_t argNo;
|
|
824
|
+
bool uncalled;
|
|
825
|
+
public:
|
|
826
|
+
SVFArgument(const std::string& _arg, const SVFType* ty, const SVFFunction* _fun, u32_t _argNo, bool _uncalled): SVFValue(_arg, ty, SVFValue::SVFArg), fun(_fun), argNo(_argNo), uncalled(_uncalled)
|
|
827
|
+
{
|
|
828
|
+
}
|
|
829
|
+
SVFArgument() = delete;
|
|
830
|
+
|
|
831
|
+
inline const SVFFunction* getParent() const
|
|
832
|
+
{
|
|
833
|
+
return fun;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/// Return the index of this formal argument in its containing function.
|
|
837
|
+
/// For example in "void foo(int a, float b)" a is 0 and b is 1.
|
|
838
|
+
inline u32_t getArgNo() const
|
|
839
|
+
{
|
|
840
|
+
return argNo;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
inline bool isArgOfUncalledFunction() const
|
|
844
|
+
{
|
|
845
|
+
return uncalled;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
static inline bool classof(const SVFValue *node)
|
|
849
|
+
{
|
|
850
|
+
return node->getKind() == SVFArg;
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
class SVFConstantData : public SVFConstant
|
|
857
|
+
{
|
|
858
|
+
public:
|
|
859
|
+
SVFConstantData(const std::string& _const, const SVFType* ty, SVFValKind k = SVFConstData): SVFConstant(_const, ty, k)
|
|
860
|
+
{
|
|
861
|
+
}
|
|
862
|
+
SVFConstantData() = delete;
|
|
863
|
+
|
|
864
|
+
static inline bool classof(const SVFValue *node)
|
|
865
|
+
{
|
|
866
|
+
return node->getKind() == SVFConstData ||
|
|
867
|
+
node->getKind() == SVFConstInt ||
|
|
868
|
+
node->getKind() == SVFConstFP ||
|
|
869
|
+
node->getKind() == SVFNullPtr ||
|
|
870
|
+
node->getKind() == SVFBlackHole;
|
|
871
|
+
}
|
|
872
|
+
static inline bool classof(const SVFConstantData *node)
|
|
873
|
+
{
|
|
874
|
+
return node->getKind() == SVFConstData ||
|
|
875
|
+
node->getKind() == SVFConstInt ||
|
|
876
|
+
node->getKind() == SVFConstFP ||
|
|
877
|
+
node->getKind() == SVFNullPtr ||
|
|
878
|
+
node->getKind() == SVFBlackHole;
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
class SVFConstantInt : public SVFConstantData
|
|
884
|
+
{
|
|
885
|
+
private:
|
|
886
|
+
u64_t zval;
|
|
887
|
+
s64_t sval;
|
|
888
|
+
public:
|
|
889
|
+
SVFConstantInt(const std::string& _const, const SVFType* ty, u64_t z, s64_t s): SVFConstantData(_const, ty, SVFValue::SVFConstInt), zval(z), sval(s)
|
|
890
|
+
{
|
|
891
|
+
}
|
|
892
|
+
SVFConstantInt() = delete;
|
|
893
|
+
|
|
894
|
+
static inline bool classof(const SVFValue *node)
|
|
895
|
+
{
|
|
896
|
+
return node->getKind() == SVFConstInt;
|
|
897
|
+
}
|
|
898
|
+
static inline bool classof(const SVFConstantData *node)
|
|
899
|
+
{
|
|
900
|
+
return node->getKind() == SVFConstInt;
|
|
901
|
+
}
|
|
902
|
+
// Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate for the type of this constant.
|
|
903
|
+
inline u64_t getZExtValue () const
|
|
904
|
+
{
|
|
905
|
+
return zval;
|
|
906
|
+
}
|
|
907
|
+
// Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the type of this constan
|
|
908
|
+
inline s64_t getSExtValue () const
|
|
909
|
+
{
|
|
910
|
+
return sval;
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
class SVFConstantFP : public SVFConstantData
|
|
916
|
+
{
|
|
917
|
+
private:
|
|
918
|
+
float dval;
|
|
919
|
+
public:
|
|
920
|
+
SVFConstantFP(const std::string& _const, const SVFType* ty, double d): SVFConstantData(_const, ty, SVFValue::SVFConstFP), dval(d)
|
|
921
|
+
{
|
|
922
|
+
}
|
|
923
|
+
SVFConstantFP() = delete;
|
|
924
|
+
|
|
925
|
+
inline double getFPValue () const
|
|
926
|
+
{
|
|
927
|
+
return dval;
|
|
928
|
+
}
|
|
929
|
+
static inline bool classof(const SVFValue *node)
|
|
930
|
+
{
|
|
931
|
+
return node->getKind() == SVFConstFP;
|
|
932
|
+
}
|
|
933
|
+
static inline bool classof(const SVFConstantData *node)
|
|
934
|
+
{
|
|
935
|
+
return node->getKind() == SVFConstFP;
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
class SVFConstantNullPtr : public SVFConstantData
|
|
941
|
+
{
|
|
942
|
+
|
|
943
|
+
public:
|
|
944
|
+
SVFConstantNullPtr(const std::string& _const, const SVFType* ty): SVFConstantData(_const, ty, SVFValue::SVFNullPtr)
|
|
945
|
+
{
|
|
946
|
+
}
|
|
947
|
+
SVFConstantNullPtr() = delete;
|
|
948
|
+
|
|
949
|
+
static inline bool classof(const SVFValue *node)
|
|
950
|
+
{
|
|
951
|
+
return node->getKind() == SVFNullPtr;
|
|
952
|
+
}
|
|
953
|
+
static inline bool classof(const SVFConstantData *node)
|
|
954
|
+
{
|
|
955
|
+
return node->getKind() == SVFNullPtr;
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
class SVFBlackHoleValue : public SVFConstantData
|
|
960
|
+
{
|
|
961
|
+
|
|
962
|
+
public:
|
|
963
|
+
SVFBlackHoleValue(const std::string& _const, const SVFType* ty): SVFConstantData(_const, ty, SVFValue::SVFBlackHole)
|
|
964
|
+
{
|
|
965
|
+
}
|
|
966
|
+
SVFBlackHoleValue() = delete;
|
|
967
|
+
|
|
968
|
+
static inline bool classof(const SVFValue *node)
|
|
969
|
+
{
|
|
970
|
+
return node->getKind() == SVFBlackHole;
|
|
971
|
+
}
|
|
972
|
+
static inline bool classof(const SVFConstantData *node)
|
|
973
|
+
{
|
|
974
|
+
return node->getKind() == SVFBlackHole;
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
class SVFOtherValue : public SVFValue
|
|
979
|
+
{
|
|
980
|
+
public:
|
|
981
|
+
SVFOtherValue(const std::string& other, const SVFType* ty, SVFValKind k = SVFValue::SVFOther): SVFValue(other, ty, k)
|
|
982
|
+
{
|
|
983
|
+
}
|
|
984
|
+
SVFOtherValue() = delete;
|
|
985
|
+
|
|
986
|
+
static inline bool classof(const SVFValue *node)
|
|
987
|
+
{
|
|
988
|
+
return node->getKind() == SVFOther;
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
/*
|
|
993
|
+
* This class is only for LLVM's MetadataAsValue
|
|
994
|
+
*/
|
|
995
|
+
class SVFMetadataAsValue : public SVFOtherValue
|
|
996
|
+
{
|
|
997
|
+
public:
|
|
998
|
+
SVFMetadataAsValue(const std::string& other, const SVFType* ty): SVFOtherValue(other, ty, SVFValue::SVFMetaAsValue)
|
|
999
|
+
{
|
|
1000
|
+
}
|
|
1001
|
+
SVFMetadataAsValue() = delete;
|
|
1002
|
+
|
|
1003
|
+
static inline bool classof(const SVFValue *node)
|
|
1004
|
+
{
|
|
1005
|
+
return node->getKind() == SVFMetaAsValue;
|
|
1006
|
+
}
|
|
1007
|
+
static inline bool classof(const SVFOtherValue *node)
|
|
1008
|
+
{
|
|
1009
|
+
return node->getKind() == SVFMetaAsValue;
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
class CallSite
|
|
1015
|
+
{
|
|
1016
|
+
private:
|
|
1017
|
+
const SVFCallInst *CB;
|
|
1018
|
+
public:
|
|
1019
|
+
CallSite(const SVFInstruction *I) : CB(SVFUtil::dyn_cast<SVFCallInst>(I))
|
|
1020
|
+
{
|
|
1021
|
+
assert(CB && "not a callsite?");
|
|
1022
|
+
}
|
|
1023
|
+
const SVFInstruction* getInstruction() const
|
|
1024
|
+
{
|
|
1025
|
+
return CB;
|
|
1026
|
+
}
|
|
1027
|
+
const SVFValue* getArgument(u32_t ArgNo) const
|
|
1028
|
+
{
|
|
1029
|
+
return CB->getArgOperand(ArgNo);
|
|
1030
|
+
}
|
|
1031
|
+
const SVFType* getType() const
|
|
1032
|
+
{
|
|
1033
|
+
return CB->getType();
|
|
1034
|
+
}
|
|
1035
|
+
u32_t arg_size() const
|
|
1036
|
+
{
|
|
1037
|
+
return CB->arg_size();
|
|
1038
|
+
}
|
|
1039
|
+
bool arg_empty() const
|
|
1040
|
+
{
|
|
1041
|
+
return CB->arg_empty();
|
|
1042
|
+
}
|
|
1043
|
+
const SVFValue* getArgOperand(u32_t i) const
|
|
1044
|
+
{
|
|
1045
|
+
return CB->getArgOperand(i);
|
|
1046
|
+
}
|
|
1047
|
+
u32_t getNumArgOperands() const
|
|
1048
|
+
{
|
|
1049
|
+
return CB->arg_size();
|
|
1050
|
+
}
|
|
1051
|
+
const SVFFunction* getCalledFunction() const
|
|
1052
|
+
{
|
|
1053
|
+
return CB->getCalledFunction();
|
|
1054
|
+
}
|
|
1055
|
+
const SVFValue* getCalledValue() const
|
|
1056
|
+
{
|
|
1057
|
+
return CB->getCalledOperand();
|
|
1058
|
+
}
|
|
1059
|
+
const SVFFunction* getCaller() const
|
|
1060
|
+
{
|
|
1061
|
+
return CB->getCaller();
|
|
1062
|
+
}
|
|
1063
|
+
bool isVarArg() const
|
|
1064
|
+
{
|
|
1065
|
+
return CB->isVarArg();
|
|
1066
|
+
}
|
|
1067
|
+
bool isVirtualCall() const
|
|
1068
|
+
{
|
|
1069
|
+
return SVFUtil::isa<SVFVirtualCallInst>(CB);
|
|
1070
|
+
}
|
|
1071
|
+
const SVFValue* getVtablePtr() const
|
|
1072
|
+
{
|
|
1073
|
+
assert(isVirtualCall() && "not a virtual call?");
|
|
1074
|
+
return SVFUtil::cast<SVFVirtualCallInst>(CB)->getVtablePtr();
|
|
1075
|
+
}
|
|
1076
|
+
s32_t getFunIdxInVtable() const
|
|
1077
|
+
{
|
|
1078
|
+
assert(isVirtualCall() && "not a virtual call?");
|
|
1079
|
+
return SVFUtil::cast<SVFVirtualCallInst>(CB)->getFunIdxInVtable();
|
|
1080
|
+
}
|
|
1081
|
+
const std::string& getFunNameOfVirtualCall() const
|
|
1082
|
+
{
|
|
1083
|
+
assert(isVirtualCall() && "not a virtual call?");
|
|
1084
|
+
return SVFUtil::cast<SVFVirtualCallInst>(CB)->getFunNameOfVirtualCall();
|
|
1085
|
+
}
|
|
1086
|
+
bool operator==(const CallSite &CS) const
|
|
1087
|
+
{
|
|
1088
|
+
return CB == CS.CB;
|
|
1089
|
+
}
|
|
1090
|
+
bool operator!=(const CallSite &CS) const
|
|
1091
|
+
{
|
|
1092
|
+
return CB != CS.CB;
|
|
1093
|
+
}
|
|
1094
|
+
bool operator<(const CallSite &CS) const
|
|
1095
|
+
{
|
|
1096
|
+
return getInstruction() < CS.getInstruction();
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
template <typename F, typename S>
|
|
1102
|
+
OutStream& operator<< (OutStream &o, const std::pair<F, S> &var)
|
|
1103
|
+
{
|
|
1104
|
+
o << "<" << var.first << ", " << var.second << ">";
|
|
1105
|
+
return o;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
} // End namespace SVF
|
|
1109
|
+
|
|
1110
|
+
/// Specialise hash for CallSites.
|
|
1111
|
+
template <> struct std::hash<SVF::CallSite>
|
|
1112
|
+
{
|
|
1113
|
+
size_t operator()(const SVF::CallSite &cs) const
|
|
1114
|
+
{
|
|
1115
|
+
std::hash<const SVF::SVFInstruction *> h;
|
|
1116
|
+
return h(cs.getInstruction());
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
#endif /* INCLUDE_SVFIR_SVFVALUE_H_ */
|