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,597 @@
|
|
|
1
|
+
//===- SymbolTableInfo.h -- Symbol information from IR------------------------//
|
|
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
|
+
* SymbolTableInfo.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Nov 11, 2013
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef INCLUDE_SVFIR_SYMBOLTABLEINFO_H_
|
|
31
|
+
#define INCLUDE_SVFIR_SYMBOLTABLEINFO_H_
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#include "Util/SVFUtil.h"
|
|
35
|
+
#include "MemoryModel/LocationSet.h"
|
|
36
|
+
#include "SVFIR/SVFModule.h"
|
|
37
|
+
namespace SVF
|
|
38
|
+
{
|
|
39
|
+
|
|
40
|
+
class MemObj;
|
|
41
|
+
class ObjTypeInfo;
|
|
42
|
+
class StInfo;
|
|
43
|
+
|
|
44
|
+
/*!
|
|
45
|
+
* Symbol table of the memory model for analysis
|
|
46
|
+
*/
|
|
47
|
+
class SymbolTableInfo
|
|
48
|
+
{
|
|
49
|
+
friend class SymbolTableBuilder;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
|
|
53
|
+
/// Symbol types
|
|
54
|
+
enum SYMTYPE
|
|
55
|
+
{
|
|
56
|
+
NullPtr,
|
|
57
|
+
BlkPtr,
|
|
58
|
+
BlackHole,
|
|
59
|
+
ConstantObj,
|
|
60
|
+
ValSymbol,
|
|
61
|
+
ObjSymbol,
|
|
62
|
+
RetSymbol,
|
|
63
|
+
VarargSymbol
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/// various maps defined
|
|
67
|
+
//{@
|
|
68
|
+
/// llvm value to sym id map
|
|
69
|
+
/// local (%) and global (@) identifiers are pointer types which have a value node id.
|
|
70
|
+
typedef OrderedMap<const SVFValue*, SymID> ValueToIDMapTy;
|
|
71
|
+
/// sym id to memory object map
|
|
72
|
+
typedef OrderedMap<SymID,MemObj*> IDToMemMapTy;
|
|
73
|
+
/// function to sym id map
|
|
74
|
+
typedef OrderedMap<const SVFFunction*, SymID> FunToIDMapTy;
|
|
75
|
+
/// struct type to struct info map
|
|
76
|
+
typedef Set<const SVFType*> SVFTypeSet;
|
|
77
|
+
//@}
|
|
78
|
+
|
|
79
|
+
private:
|
|
80
|
+
ValueToIDMapTy valSymMap; ///< map a value to its sym id
|
|
81
|
+
ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
|
|
82
|
+
FunToIDMapTy returnSymMap; ///< return map
|
|
83
|
+
FunToIDMapTy varargSymMap; ///< vararg map
|
|
84
|
+
IDToMemMapTy objMap; ///< map a memory sym id to its obj
|
|
85
|
+
|
|
86
|
+
// Singleton pattern here to enable instance of SymbolTableInfo can only be created once.
|
|
87
|
+
static SymbolTableInfo* symInfo;
|
|
88
|
+
|
|
89
|
+
/// Module
|
|
90
|
+
SVFModule* mod;
|
|
91
|
+
|
|
92
|
+
/// Clean up memory
|
|
93
|
+
void destroy();
|
|
94
|
+
|
|
95
|
+
/// Whether to model constants
|
|
96
|
+
bool modelConstants;
|
|
97
|
+
|
|
98
|
+
/// total number of symbols
|
|
99
|
+
SymID totalSymNum;
|
|
100
|
+
|
|
101
|
+
protected:
|
|
102
|
+
/// Constructor
|
|
103
|
+
SymbolTableInfo(void) :
|
|
104
|
+
mod(nullptr), modelConstants(false), totalSymNum(0), maxStruct(nullptr), maxStSize(0)
|
|
105
|
+
{
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public:
|
|
109
|
+
|
|
110
|
+
/// Singleton design here to make sure we only have one instance during any analysis
|
|
111
|
+
//@{
|
|
112
|
+
static SymbolTableInfo* SymbolInfo();
|
|
113
|
+
|
|
114
|
+
static void releaseSymbolInfo()
|
|
115
|
+
{
|
|
116
|
+
delete symInfo;
|
|
117
|
+
symInfo = nullptr;
|
|
118
|
+
}
|
|
119
|
+
virtual ~SymbolTableInfo()
|
|
120
|
+
{
|
|
121
|
+
destroy();
|
|
122
|
+
}
|
|
123
|
+
//@}
|
|
124
|
+
|
|
125
|
+
/// Set / Get modelConstants
|
|
126
|
+
//@{
|
|
127
|
+
void setModelConstants(bool _modelConstants)
|
|
128
|
+
{
|
|
129
|
+
modelConstants = _modelConstants;
|
|
130
|
+
}
|
|
131
|
+
bool getModelConstants() const
|
|
132
|
+
{
|
|
133
|
+
return modelConstants;
|
|
134
|
+
}
|
|
135
|
+
//@}
|
|
136
|
+
|
|
137
|
+
/// Module
|
|
138
|
+
inline SVFModule* getModule()
|
|
139
|
+
{
|
|
140
|
+
return mod;
|
|
141
|
+
}
|
|
142
|
+
/// Module
|
|
143
|
+
inline void setModule(SVFModule* m)
|
|
144
|
+
{
|
|
145
|
+
mod = m;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/// special value
|
|
149
|
+
// @{
|
|
150
|
+
static inline bool isBlkPtr(NodeID id)
|
|
151
|
+
{
|
|
152
|
+
return (id == BlkPtr);
|
|
153
|
+
}
|
|
154
|
+
static inline bool isNullPtr(NodeID id)
|
|
155
|
+
{
|
|
156
|
+
return (id == NullPtr);
|
|
157
|
+
}
|
|
158
|
+
static inline bool isBlkObj(NodeID id)
|
|
159
|
+
{
|
|
160
|
+
return (id == BlackHole);
|
|
161
|
+
}
|
|
162
|
+
static inline bool isConstantObj(NodeID id)
|
|
163
|
+
{
|
|
164
|
+
return (id == ConstantObj);
|
|
165
|
+
}
|
|
166
|
+
static inline bool isBlkObjOrConstantObj(NodeID id)
|
|
167
|
+
{
|
|
168
|
+
return (isBlkObj(id) || isConstantObj(id));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
inline MemObj* getBlkObj() const
|
|
172
|
+
{
|
|
173
|
+
return getObj(blackholeSymID());
|
|
174
|
+
}
|
|
175
|
+
inline MemObj* getConstantObj() const
|
|
176
|
+
{
|
|
177
|
+
return getObj(constantSymID());
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
inline SymID blkPtrSymID() const
|
|
181
|
+
{
|
|
182
|
+
return BlkPtr;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
inline SymID nullPtrSymID() const
|
|
186
|
+
{
|
|
187
|
+
return NullPtr;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
inline SymID constantSymID() const
|
|
191
|
+
{
|
|
192
|
+
return ConstantObj;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
inline SymID blackholeSymID() const
|
|
196
|
+
{
|
|
197
|
+
return BlackHole;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/// Can only be invoked by SVFIR::addDummyNode() when creaing SVFIR from file.
|
|
201
|
+
const MemObj* createDummyObj(SymID symId, const SVFType* type);
|
|
202
|
+
// @}
|
|
203
|
+
|
|
204
|
+
/// Get different kinds of syms
|
|
205
|
+
//@{
|
|
206
|
+
SymID getValSym(const SVFValue* val);
|
|
207
|
+
|
|
208
|
+
bool hasValSym(const SVFValue* val);
|
|
209
|
+
|
|
210
|
+
inline SymID getObjSym(const SVFValue* val) const
|
|
211
|
+
{
|
|
212
|
+
const SVFValue* svfVal = val;
|
|
213
|
+
if(const SVFGlobalValue* g = SVFUtil::dyn_cast<SVFGlobalValue>(val))
|
|
214
|
+
svfVal = g->getDefGlobalForMultipleModule();
|
|
215
|
+
ValueToIDMapTy::const_iterator iter = objSymMap.find(svfVal);
|
|
216
|
+
assert(iter!=objSymMap.end() && "obj sym not found");
|
|
217
|
+
return iter->second;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
inline MemObj* getObj(SymID id) const
|
|
221
|
+
{
|
|
222
|
+
IDToMemMapTy::const_iterator iter = objMap.find(id);
|
|
223
|
+
assert(iter!=objMap.end() && "obj not found");
|
|
224
|
+
return iter->second;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
inline SymID getRetSym(const SVFFunction* val) const
|
|
228
|
+
{
|
|
229
|
+
FunToIDMapTy::const_iterator iter = returnSymMap.find(val);
|
|
230
|
+
assert(iter!=returnSymMap.end() && "ret sym not found");
|
|
231
|
+
return iter->second;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
inline SymID getVarargSym(const SVFFunction* val) const
|
|
235
|
+
{
|
|
236
|
+
FunToIDMapTy::const_iterator iter = varargSymMap.find(val);
|
|
237
|
+
assert(iter!=varargSymMap.end() && "vararg sym not found");
|
|
238
|
+
return iter->second;
|
|
239
|
+
}
|
|
240
|
+
//@}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
/// Statistics
|
|
244
|
+
//@{
|
|
245
|
+
inline u32_t getTotalSymNum() const
|
|
246
|
+
{
|
|
247
|
+
return totalSymNum;
|
|
248
|
+
}
|
|
249
|
+
inline u32_t getMaxStructSize() const
|
|
250
|
+
{
|
|
251
|
+
return maxStSize;
|
|
252
|
+
}
|
|
253
|
+
//@}
|
|
254
|
+
|
|
255
|
+
/// Get different kinds of syms maps
|
|
256
|
+
//@{
|
|
257
|
+
inline ValueToIDMapTy& valSyms()
|
|
258
|
+
{
|
|
259
|
+
return valSymMap;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
inline ValueToIDMapTy& objSyms()
|
|
263
|
+
{
|
|
264
|
+
return objSymMap;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
inline IDToMemMapTy& idToObjMap()
|
|
268
|
+
{
|
|
269
|
+
return objMap;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
inline FunToIDMapTy& retSyms()
|
|
273
|
+
{
|
|
274
|
+
return returnSymMap;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
inline FunToIDMapTy& varargSyms()
|
|
278
|
+
{
|
|
279
|
+
return varargSymMap;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
//@}
|
|
283
|
+
|
|
284
|
+
/// Get struct info
|
|
285
|
+
//@{
|
|
286
|
+
///Get a reference to StructInfo.
|
|
287
|
+
const StInfo* getTypeInfo(const SVFType* T) const;
|
|
288
|
+
inline bool hasSVFTypeInfo(const SVFType* T)
|
|
289
|
+
{
|
|
290
|
+
return svfTypes.find(T) != svfTypes.end();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
///Get a reference to the components of struct_info.
|
|
294
|
+
/// Number of flattenned elements of an array or struct
|
|
295
|
+
u32_t getNumOfFlattenElements(const SVFType* T);
|
|
296
|
+
/// Flatterned element idx of an array or struct by considering stride
|
|
297
|
+
u32_t getFlattenedElemIdx(const SVFType* T, u32_t origId);
|
|
298
|
+
/// Return the type of a flattened element given a flattened index
|
|
299
|
+
const SVFType* getFlatternedElemType(const SVFType* baseType, u32_t flatten_idx);
|
|
300
|
+
/// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
|
|
301
|
+
/// OriginalElemType of b with field_idx 1 : Struct A
|
|
302
|
+
/// FlatternedElemType of b with field_idx 1 : int
|
|
303
|
+
const SVFType* getOriginalElemType(const SVFType* baseType, u32_t origId) const;
|
|
304
|
+
//@}
|
|
305
|
+
|
|
306
|
+
/// Debug method
|
|
307
|
+
void printFlattenFields(const SVFType* type);
|
|
308
|
+
|
|
309
|
+
static std::string toString(SYMTYPE symtype);
|
|
310
|
+
|
|
311
|
+
/// Another debug method
|
|
312
|
+
virtual void dump();
|
|
313
|
+
|
|
314
|
+
/// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
|
|
315
|
+
virtual LocationSet getModulusOffset(const MemObj* obj, const LocationSet& ls);
|
|
316
|
+
|
|
317
|
+
///The struct type with the most fields
|
|
318
|
+
const SVFType* maxStruct;
|
|
319
|
+
|
|
320
|
+
///The number of fields in max_struct
|
|
321
|
+
u32_t maxStSize;
|
|
322
|
+
|
|
323
|
+
inline void addTypeInfo(const SVFType* ty)
|
|
324
|
+
{
|
|
325
|
+
assert(!hasSVFTypeInfo(ty) && "this type info has been added before");
|
|
326
|
+
svfTypes.insert(ty);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
protected:
|
|
330
|
+
|
|
331
|
+
/// Return the flattened field type for struct type only
|
|
332
|
+
const std::vector<const SVFType*>& getFlattenFieldTypes(const SVFStructType *T);
|
|
333
|
+
|
|
334
|
+
/// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
|
|
335
|
+
ObjTypeInfo* createObjTypeInfo(const SVFType* type);
|
|
336
|
+
|
|
337
|
+
/// Every type T is mapped to StInfo
|
|
338
|
+
/// which contains size (fsize) , offset(foffset)
|
|
339
|
+
/// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
|
|
340
|
+
/// fsize[0] is always the size of the expanded struct.
|
|
341
|
+
SVFTypeSet svfTypes;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
/*!
|
|
346
|
+
* Memory object symbols or MemObj (address-taken variables in LLVM-based languages)
|
|
347
|
+
*/
|
|
348
|
+
class MemObj
|
|
349
|
+
{
|
|
350
|
+
|
|
351
|
+
private:
|
|
352
|
+
/// Type information of this object
|
|
353
|
+
ObjTypeInfo* typeInfo;
|
|
354
|
+
/// The unique value of this symbol/variable
|
|
355
|
+
const SVFValue* refVal;
|
|
356
|
+
/// The unique id to represent this symbol
|
|
357
|
+
SymID symId;
|
|
358
|
+
|
|
359
|
+
public:
|
|
360
|
+
/// Constructor
|
|
361
|
+
MemObj(SymID id, ObjTypeInfo* ti, const SVFValue* val = nullptr);
|
|
362
|
+
|
|
363
|
+
/// Destructor
|
|
364
|
+
virtual ~MemObj()
|
|
365
|
+
{
|
|
366
|
+
destroy();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
virtual const std::string toString() const;
|
|
370
|
+
|
|
371
|
+
/// Get the reference value to this object
|
|
372
|
+
inline const SVFValue* getValue() const
|
|
373
|
+
{
|
|
374
|
+
return refVal;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/// Get the memory object id
|
|
378
|
+
inline SymID getId() const
|
|
379
|
+
{
|
|
380
|
+
return symId;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/// Get obj type
|
|
384
|
+
const SVFType* getType() const;
|
|
385
|
+
|
|
386
|
+
/// Get the number of elements of this object
|
|
387
|
+
u32_t getNumOfElements() const;
|
|
388
|
+
|
|
389
|
+
/// Set the number of elements of this object
|
|
390
|
+
void setNumOfElements(u32_t num);
|
|
391
|
+
|
|
392
|
+
/// Get max field offset limit
|
|
393
|
+
u32_t getMaxFieldOffsetLimit() const;
|
|
394
|
+
|
|
395
|
+
/// Return true if its field limit is 0
|
|
396
|
+
bool isFieldInsensitive() const;
|
|
397
|
+
|
|
398
|
+
/// Set the memory object to be field insensitive
|
|
399
|
+
void setFieldInsensitive();
|
|
400
|
+
|
|
401
|
+
/// Set the memory object to be field sensitive (up to max field limit)
|
|
402
|
+
void setFieldSensitive();
|
|
403
|
+
|
|
404
|
+
/// Whether it is a black hole object
|
|
405
|
+
bool isBlackHoleObj() const;
|
|
406
|
+
|
|
407
|
+
/// object attributes methods
|
|
408
|
+
//@{
|
|
409
|
+
bool isFunction() const;
|
|
410
|
+
bool isGlobalObj() const;
|
|
411
|
+
bool isStaticObj() const;
|
|
412
|
+
bool isStack() const;
|
|
413
|
+
bool isHeap() const;
|
|
414
|
+
bool isStruct() const;
|
|
415
|
+
bool isArray() const;
|
|
416
|
+
bool isVarStruct() const;
|
|
417
|
+
bool isVarArray() const;
|
|
418
|
+
bool isConstantStruct() const;
|
|
419
|
+
bool isConstantArray() const;
|
|
420
|
+
bool isConstDataOrConstGlobal() const;
|
|
421
|
+
bool isConstDataOrAggData() const;
|
|
422
|
+
bool hasPtrObj() const;
|
|
423
|
+
bool isNonPtrFieldObj(const LocationSet& ls) const;
|
|
424
|
+
//@}
|
|
425
|
+
|
|
426
|
+
/// Operator overloading
|
|
427
|
+
inline bool operator==(const MemObj &mem) const
|
|
428
|
+
{
|
|
429
|
+
return getValue() == mem.getValue();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/// Clean up memory
|
|
433
|
+
void destroy();
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
/*!
|
|
439
|
+
* Type Info of an abstract memory object
|
|
440
|
+
*/
|
|
441
|
+
class ObjTypeInfo
|
|
442
|
+
{
|
|
443
|
+
friend class SymbolTableBuilder;
|
|
444
|
+
public:
|
|
445
|
+
typedef enum
|
|
446
|
+
{
|
|
447
|
+
FUNCTION_OBJ = 0x1, // object is a function
|
|
448
|
+
GLOBVAR_OBJ = 0x2, // object is a global variable
|
|
449
|
+
STATIC_OBJ = 0x4, // object is a static variable allocated before main
|
|
450
|
+
STACK_OBJ = 0x8, // object is a stack variable
|
|
451
|
+
HEAP_OBJ = 0x10, // object is a heap variable
|
|
452
|
+
VAR_STRUCT_OBJ = 0x20, // object contains struct
|
|
453
|
+
VAR_ARRAY_OBJ = 0x40, // object contains array
|
|
454
|
+
CONST_STRUCT_OBJ = 0x80, // constant struct
|
|
455
|
+
CONST_ARRAY_OBJ = 0x100, // constant array
|
|
456
|
+
CONST_GLOBAL_OBJ = 0x200, // global constant object
|
|
457
|
+
CONST_DATA = 0x400, // constant object str e.g. 5, 10, 1.0
|
|
458
|
+
HASPTR_OBJ = 0x800 // the object stores a pointer address
|
|
459
|
+
} MEMTYPE;
|
|
460
|
+
|
|
461
|
+
private:
|
|
462
|
+
/// SVF type
|
|
463
|
+
const SVFType* type;
|
|
464
|
+
/// Type flags
|
|
465
|
+
u32_t flags;
|
|
466
|
+
/// Max offset for flexible field sensitive analysis
|
|
467
|
+
/// maximum number of field object can be created
|
|
468
|
+
/// minimum number is 0 (field insensitive analysis)
|
|
469
|
+
u32_t maxOffsetLimit;
|
|
470
|
+
/// Size of the object or number of elements
|
|
471
|
+
u32_t elemNum;
|
|
472
|
+
|
|
473
|
+
void resetTypeForHeapStaticObj(const SVFType* type);
|
|
474
|
+
public:
|
|
475
|
+
|
|
476
|
+
/// Constructors
|
|
477
|
+
ObjTypeInfo(const SVFType* t, u32_t max);
|
|
478
|
+
|
|
479
|
+
/// Destructor
|
|
480
|
+
virtual ~ObjTypeInfo()
|
|
481
|
+
{
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/// Get LLVM type
|
|
485
|
+
inline const SVFType* getType() const
|
|
486
|
+
{
|
|
487
|
+
return type;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/// Get max field offset limit
|
|
491
|
+
inline u32_t getMaxFieldOffsetLimit()
|
|
492
|
+
{
|
|
493
|
+
return maxOffsetLimit;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/// Get max field offset limit
|
|
497
|
+
inline void setMaxFieldOffsetLimit(u32_t limit)
|
|
498
|
+
{
|
|
499
|
+
maxOffsetLimit = limit;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/// Set the number of elements of this object
|
|
503
|
+
inline void setNumOfElements(u32_t num)
|
|
504
|
+
{
|
|
505
|
+
elemNum = num;
|
|
506
|
+
setMaxFieldOffsetLimit(num);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/// Get the number of elements of this object
|
|
510
|
+
inline u32_t getNumOfElements() const
|
|
511
|
+
{
|
|
512
|
+
return elemNum;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/// Flag for this object type
|
|
516
|
+
//@{
|
|
517
|
+
inline void setFlag(MEMTYPE mask)
|
|
518
|
+
{
|
|
519
|
+
flags |= mask;
|
|
520
|
+
}
|
|
521
|
+
inline bool hasFlag(MEMTYPE mask)
|
|
522
|
+
{
|
|
523
|
+
return (flags & mask) == mask;
|
|
524
|
+
}
|
|
525
|
+
//@}
|
|
526
|
+
|
|
527
|
+
/// Object attributes
|
|
528
|
+
//@{
|
|
529
|
+
inline bool isFunction()
|
|
530
|
+
{
|
|
531
|
+
return hasFlag(FUNCTION_OBJ);
|
|
532
|
+
}
|
|
533
|
+
inline bool isGlobalObj()
|
|
534
|
+
{
|
|
535
|
+
return hasFlag(GLOBVAR_OBJ);
|
|
536
|
+
}
|
|
537
|
+
inline bool isStaticObj()
|
|
538
|
+
{
|
|
539
|
+
return hasFlag(STATIC_OBJ);
|
|
540
|
+
}
|
|
541
|
+
inline bool isStack()
|
|
542
|
+
{
|
|
543
|
+
return hasFlag(STACK_OBJ);
|
|
544
|
+
}
|
|
545
|
+
inline bool isHeap()
|
|
546
|
+
{
|
|
547
|
+
return hasFlag(HEAP_OBJ);
|
|
548
|
+
}
|
|
549
|
+
//@}
|
|
550
|
+
|
|
551
|
+
/// Object attributes (noted that an object can be a nested compound types)
|
|
552
|
+
/// e.g. both isStruct and isArray can return true
|
|
553
|
+
//@{
|
|
554
|
+
inline bool isVarStruct()
|
|
555
|
+
{
|
|
556
|
+
return hasFlag(VAR_STRUCT_OBJ);
|
|
557
|
+
}
|
|
558
|
+
inline bool isConstantStruct()
|
|
559
|
+
{
|
|
560
|
+
return hasFlag(CONST_STRUCT_OBJ);
|
|
561
|
+
}
|
|
562
|
+
inline bool isStruct()
|
|
563
|
+
{
|
|
564
|
+
return hasFlag(VAR_STRUCT_OBJ) || hasFlag(CONST_STRUCT_OBJ);
|
|
565
|
+
}
|
|
566
|
+
inline bool isVarArray()
|
|
567
|
+
{
|
|
568
|
+
return hasFlag(VAR_ARRAY_OBJ);
|
|
569
|
+
}
|
|
570
|
+
inline bool isConstantArray()
|
|
571
|
+
{
|
|
572
|
+
return hasFlag(CONST_ARRAY_OBJ);
|
|
573
|
+
}
|
|
574
|
+
inline bool isArray()
|
|
575
|
+
{
|
|
576
|
+
return hasFlag(VAR_ARRAY_OBJ) || hasFlag(CONST_ARRAY_OBJ);
|
|
577
|
+
}
|
|
578
|
+
inline bool isConstDataOrConstGlobal()
|
|
579
|
+
{
|
|
580
|
+
return hasFlag(CONST_GLOBAL_OBJ) || hasFlag(CONST_DATA);
|
|
581
|
+
}
|
|
582
|
+
inline bool isConstDataOrAggData()
|
|
583
|
+
{
|
|
584
|
+
return hasFlag(CONST_DATA);
|
|
585
|
+
}
|
|
586
|
+
inline bool hasPtrObj()
|
|
587
|
+
{
|
|
588
|
+
return hasFlag(HASPTR_OBJ);
|
|
589
|
+
}
|
|
590
|
+
virtual bool isNonPtrFieldObj(const LocationSet& ls);
|
|
591
|
+
//@}
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
} // End namespace SVF
|
|
596
|
+
|
|
597
|
+
#endif /* INCLUDE_SVFIR_SYMBOLTABLEINFO_H_ */
|