Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVFModule.h
Go to the documentation of this file.
1//===- SVFModule.h -- SVFModule* class----------------------------------------//
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 Affero 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 Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23/*
24 * SVFModule.h
25 *
26 * Created on: Aug 4, 2017
27 * Author: Xiaokang Fan
28 */
29
30#ifndef INCLUDE_SVFMODULE_H_
31#define INCLUDE_SVFMODULE_H_
32
33#include "SVFIR/SVFValue.h"
35#include "Util/ThreadAPI.h"
36
37namespace SVF
38{
39
41{
42 friend class SVFIRWriter;
43 friend class SVFIRReader;
44
45public:
46 typedef std::vector<const SVFFunction*> FunctionSetType;
47 typedef std::vector<SVFGlobalValue*> GlobalSetType;
48 typedef std::vector<SVFGlobalValue*> AliasSetType;
49 typedef std::vector<SVFConstant*> ConstantType;
50 typedef std::vector<SVFOtherValue*> OtherValueType;
51
53 typedef FunctionSetType::iterator iterator;
54 typedef FunctionSetType::const_iterator const_iterator;
55 typedef GlobalSetType::iterator global_iterator;
56 typedef GlobalSetType::const_iterator const_global_iterator;
57 typedef AliasSetType::iterator alias_iterator;
58 typedef AliasSetType::const_iterator const_alias_iterator;
59 typedef ConstantType::iterator cdata_iterator;
60 typedef ConstantType::const_iterator const_cdata_iterator;
61 typedef OtherValueType::iterator ovalue_iterator;
62 typedef OtherValueType::const_iterator const_ovalue_iterator;
63
64private:
66 static std::string pagReadFromTxt;
67 std::string moduleIdentifier;
73
75 SVFModule() = default;
76
77public:
78 static SVFModule* getSVFModule();
79 static void releaseSVFModule();
80
81 ~SVFModule();
82
83 static inline void setPagFromTXT(const std::string& txt)
84 {
86 }
87
88 inline void setModuleIdentifier(const std::string& moduleIdentifier)
89 {
90 this->moduleIdentifier = moduleIdentifier;
91 }
92
93 static inline std::string pagFileName()
94 {
95 return pagReadFromTxt;
96 }
97
98 static inline bool pagReadFromTXT()
99 {
100 return !pagReadFromTxt.empty();
101 }
102
103 const SVFFunction* getSVFFunction(const std::string& name);
104
107 {
108 FunctionSet.push_back(svfFunc);
109 }
111 {
112 GlobalSet.push_back(glob);
114 }
115 inline void addAliasSet(SVFGlobalValue* alias)
116 {
117 AliasSet.push_back(alias);
118 addConstant(alias);
119 }
121 {
122 ConstantSet.push_back(cd);
123 }
125 {
126 OtherValueSet.push_back(ov);
127 }
128
130
134 {
135 return GlobalSet.begin();
136 }
138 {
139 return GlobalSet.begin();
140 }
142 {
143 return GlobalSet.end();
144 }
146 {
147 return GlobalSet.end();
148 }
149
151 {
152 return AliasSet.begin();
153 }
155 {
156 return AliasSet.begin();
157 }
159 {
160 return AliasSet.end();
161 }
163 {
164 return AliasSet.end();
165 }
166
168 {
169 return ConstantSet.begin();
170 }
172 {
173 return ConstantSet.begin();
174 }
176 {
177 return ConstantSet.end();
178 }
180 {
181 return ConstantSet.end();
182 }
184
185 const std::string& getModuleIdentifier() const
186 {
187 if (pagReadFromTxt.empty())
188 {
189 assert(!moduleIdentifier.empty() &&
190 "No module found! Reading from a file other than LLVM-IR?");
191 return moduleIdentifier;
192 }
193 else
194 {
195 return pagReadFromTxt;
196 }
197 }
198
199 inline const FunctionSetType& getFunctionSet() const
200 {
201 return FunctionSet;
202 }
203 inline const ConstantType& getConstantSet() const
204 {
205 return ConstantSet;
206 }
207 inline const GlobalSetType& getGlobalSet() const
208 {
209 return GlobalSet;
210 }
211 inline const AliasSetType& getAliasSet() const
212 {
213 return AliasSet;
214 }
215 inline const OtherValueType& getOtherValueSet() const
216 {
217 return OtherValueSet;
218 }
219};
220
221} // End namespace SVF
222
223#endif /* INCLUDE_SVFMODULE_H_ */
const char *const name
Definition cJSON.h:264
SVFModule()=default
Constructors.
void addGlobalSet(SVFGlobalValue *glob)
Definition SVFModule.h:110
const_alias_iterator alias_begin() const
Definition SVFModule.h:154
static bool pagReadFromTXT()
Definition SVFModule.h:98
const_alias_iterator alias_end() const
Definition SVFModule.h:162
const_cdata_iterator constant_begin() const
Definition SVFModule.h:171
static std::string pagReadFromTxt
Definition SVFModule.h:66
std::vector< SVFOtherValue * > OtherValueType
Definition SVFModule.h:50
OtherValueType::const_iterator const_ovalue_iterator
Definition SVFModule.h:62
alias_iterator alias_end()
Definition SVFModule.h:158
void addOtherValue(SVFOtherValue *ov)
Definition SVFModule.h:124
GlobalSetType::iterator global_iterator
Definition SVFModule.h:55
global_iterator global_begin()
Definition SVFModule.h:133
GlobalSetType GlobalSet
The Global Variables in the module.
Definition SVFModule.h:69
static void releaseSVFModule()
Definition SVFModule.cpp:69
static std::string pagFileName()
Definition SVFModule.h:93
GlobalSetType::const_iterator const_global_iterator
Definition SVFModule.h:56
AliasSetType::const_iterator const_alias_iterator
Definition SVFModule.h:58
AliasSetType AliasSet
The Aliases in the module.
Definition SVFModule.h:70
const std::string & getModuleIdentifier() const
Definition SVFModule.h:185
ConstantType ConstantSet
The ConstantData in the module.
Definition SVFModule.h:71
FunctionSetType::iterator iterator
Iterators type def.
Definition SVFModule.h:53
static void setPagFromTXT(const std::string &txt)
Definition SVFModule.h:83
OtherValueType::iterator ovalue_iterator
Definition SVFModule.h:61
const OtherValueType & getOtherValueSet() const
Definition SVFModule.h:215
alias_iterator alias_begin()
Definition SVFModule.h:150
void addFunctionSet(SVFFunction *svfFunc)
Definition SVFModule.h:106
global_iterator global_end()
Definition SVFModule.h:141
std::vector< SVFConstant * > ConstantType
Definition SVFModule.h:49
OtherValueType OtherValueSet
All other values in the module.
Definition SVFModule.h:72
const GlobalSetType & getGlobalSet() const
Definition SVFModule.h:207
std::vector< SVFGlobalValue * > AliasSetType
Definition SVFModule.h:48
void addAliasSet(SVFGlobalValue *alias)
Definition SVFModule.h:115
const FunctionSetType & getFunctionSet() const
Definition SVFModule.h:199
std::vector< SVFGlobalValue * > GlobalSetType
Definition SVFModule.h:47
ConstantType::const_iterator const_cdata_iterator
Definition SVFModule.h:60
const AliasSetType & getAliasSet() const
Definition SVFModule.h:211
static SVFModule * getSVFModule()
Definition SVFModule.cpp:60
const_cdata_iterator constant_end() const
Definition SVFModule.h:179
AliasSetType::iterator alias_iterator
Definition SVFModule.h:57
cdata_iterator constant_begin()
Definition SVFModule.h:167
std::string moduleIdentifier
Definition SVFModule.h:67
void setModuleIdentifier(const std::string &moduleIdentifier)
Definition SVFModule.h:88
ConstantType::iterator cdata_iterator
Definition SVFModule.h:59
std::vector< const SVFFunction * > FunctionSetType
Definition SVFModule.h:46
cdata_iterator constant_end()
Definition SVFModule.h:175
static SVFModule * svfModule
Definition SVFModule.h:65
void addConstant(SVFConstant *cd)
Definition SVFModule.h:120
FunctionSetType FunctionSet
The Functions in the module.
Definition SVFModule.h:68
const_global_iterator global_begin() const
Definition SVFModule.h:137
const ConstantType & getConstantSet() const
Definition SVFModule.h:203
const_global_iterator global_end() const
Definition SVFModule.h:145
FunctionSetType::const_iterator const_iterator
Definition SVFModule.h:54
const SVFFunction * getSVFFunction(const std::string &name)
Definition SVFModule.cpp:48
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74