svf-tools 1.0.703 → 1.0.705
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/include/SVFIR/{SVFIRRW.h → SVFFileSystem.h} +43 -12
- package/svf/include/SVFIR/SVFModule.h +0 -4
- package/svf/include/SVFIR/SVFType.h +0 -8
- package/svf/include/SVFIR/SVFValue.h +0 -34
- package/svf/include/Util/ExtAPI.h +8 -3
- package/svf/include/Util/NodeIDAllocator.h +3 -0
- package/svf/lib/SVFIR/{SVFIRRW.cpp → SVFFileSystem.cpp} +54 -8
- package/svf/lib/SVFIR/SVFModule.cpp +0 -7
- package/svf/lib/Util/ExtAPI.cpp +37 -5
- package/svf-llvm/lib/LLVMModule.cpp +0 -1
- package/svf-llvm/lib/SVFIRBuilder.cpp +1 -1
- package/svf-llvm/tools/LLVM2SVF/llvm2svf.cpp +1 -1
- package/svf-llvm/tools/WPA/wpa.cpp +1 -1
- package/svf/include/SVFIR/SVFModuleRW.h +0 -197
- package/svf/lib/SVFIR/SVFModuleRW.cpp +0 -1206
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
//===- SVFModuleRW.h -- SVFModuleReader* 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
|
-
* SVFModuleRW.h
|
|
25
|
-
*
|
|
26
|
-
* Created on: 27 Jan 2023
|
|
27
|
-
* Author: Xudong Wang
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef INCLUDE_SVFMODULE_JSON_DUMPER_H_
|
|
31
|
-
#define INCLUDE_SVFMODULE_JSON_DUMPER_H_
|
|
32
|
-
|
|
33
|
-
#include <string>
|
|
34
|
-
#include <vector>
|
|
35
|
-
#include <unordered_map>
|
|
36
|
-
#include <ostream>
|
|
37
|
-
#include <memory>
|
|
38
|
-
|
|
39
|
-
struct cJSON;
|
|
40
|
-
|
|
41
|
-
namespace SVF
|
|
42
|
-
{
|
|
43
|
-
class SVFModule;
|
|
44
|
-
|
|
45
|
-
class StInfo;
|
|
46
|
-
class SVFType;
|
|
47
|
-
class SVFPointerType;
|
|
48
|
-
class SVFIntegerType;
|
|
49
|
-
class SVFFunctionType;
|
|
50
|
-
class SVFStructType;
|
|
51
|
-
class SVFArrayType;
|
|
52
|
-
class SVFOtherType;
|
|
53
|
-
|
|
54
|
-
class SVFLoopAndDomInfo;
|
|
55
|
-
class SVFValue;
|
|
56
|
-
class SVFFunction;
|
|
57
|
-
class SVFBasicBlock;
|
|
58
|
-
class SVFInstruction;
|
|
59
|
-
class SVFCallInst;
|
|
60
|
-
class SVFVirtualCallInst;
|
|
61
|
-
class SVFConstant;
|
|
62
|
-
class SVFGlobalValue;
|
|
63
|
-
class SVFArgument;
|
|
64
|
-
class SVFConstantData;
|
|
65
|
-
class SVFConstantInt;
|
|
66
|
-
class SVFConstantFP;
|
|
67
|
-
class SVFConstantNullPtr;
|
|
68
|
-
class SVFBlackHoleValue;
|
|
69
|
-
class SVFOtherValue;
|
|
70
|
-
class SVFMetadataAsValue;
|
|
71
|
-
|
|
72
|
-
using TypeIndex = std::size_t;
|
|
73
|
-
using ValueIndex = std::size_t;
|
|
74
|
-
|
|
75
|
-
class SVFModuleWrite
|
|
76
|
-
{
|
|
77
|
-
private:
|
|
78
|
-
const SVFModule* module; ///< Borrowed pointer to the SVFModule.
|
|
79
|
-
const char* jsonStr; ///< Json string of the SVFModule. It gets freed by `cJSON_free()` in destructor.
|
|
80
|
-
|
|
81
|
-
std::unordered_map<const SVFType*, TypeIndex> typeToIndex;
|
|
82
|
-
std::vector<const SVFType*> typePool; ///< A pool of all SVFTypes in the SVFModule
|
|
83
|
-
TypeIndex getTypeIndex(const SVFType* type);
|
|
84
|
-
const char* getStrTypeIndex(const SVFType* type);
|
|
85
|
-
|
|
86
|
-
std::unordered_map<const SVFValue*, ValueIndex> valueToIndex;
|
|
87
|
-
std::vector<const SVFValue*> valuePool; ///< A pool of all SVFValues in the SVFModule
|
|
88
|
-
ValueIndex getValueIndex(const SVFValue* value);
|
|
89
|
-
const char* getStrValueIndex(const SVFValue* value);
|
|
90
|
-
|
|
91
|
-
std::vector<std::unique_ptr<std::string>> allIndices;
|
|
92
|
-
const char* getStrOfIndex(std::size_t index);
|
|
93
|
-
|
|
94
|
-
public:
|
|
95
|
-
SVFModuleWrite(const SVFModule* module);
|
|
96
|
-
/// @brief Dump the SVFModule to a file in JSON format at the given path.
|
|
97
|
-
SVFModuleWrite(const SVFModule* module, const std::string& path);
|
|
98
|
-
void dumpJsonToPath(const std::string& path);
|
|
99
|
-
void dumpJsonToOstream(std::ostream& os);
|
|
100
|
-
~SVFModuleWrite();
|
|
101
|
-
|
|
102
|
-
private:
|
|
103
|
-
cJSON* moduleToJson(const SVFModule* module);
|
|
104
|
-
|
|
105
|
-
cJSON* typeToJson(const SVFType* type);
|
|
106
|
-
cJSON* toJson(const StInfo* stInfo);
|
|
107
|
-
// SVFType and all its descendants/subclasses.
|
|
108
|
-
cJSON* toJson(const SVFType* type);
|
|
109
|
-
cJSON* toJson(const SVFPointerType* type);
|
|
110
|
-
cJSON* toJson(const SVFIntegerType* type);
|
|
111
|
-
cJSON* toJson(const SVFFunctionType* type);
|
|
112
|
-
cJSON* toJson(const SVFStructType* type);
|
|
113
|
-
cJSON* toJson(const SVFArrayType* type);
|
|
114
|
-
cJSON* toJson(const SVFOtherType* type);
|
|
115
|
-
|
|
116
|
-
cJSON* valueToJson(const SVFValue* value);
|
|
117
|
-
cJSON* toJson(const SVFLoopAndDomInfo* ldInfo);
|
|
118
|
-
// SVFValue and all its descendants/subclasses.
|
|
119
|
-
cJSON* toJson(const SVFValue* value);
|
|
120
|
-
cJSON* toJson(const SVFFunction* value);
|
|
121
|
-
cJSON* toJson(const SVFBasicBlock* value);
|
|
122
|
-
cJSON* toJson(const SVFInstruction* value);
|
|
123
|
-
cJSON* toJson(const SVFCallInst* value);
|
|
124
|
-
cJSON* toJson(const SVFVirtualCallInst* value);
|
|
125
|
-
cJSON* toJson(const SVFConstant* value);
|
|
126
|
-
cJSON* toJson(const SVFGlobalValue* value);
|
|
127
|
-
cJSON* toJson(const SVFArgument* value);
|
|
128
|
-
cJSON* toJson(const SVFConstantData* value);
|
|
129
|
-
cJSON* toJson(const SVFConstantInt* value);
|
|
130
|
-
cJSON* toJson(const SVFConstantFP* value);
|
|
131
|
-
cJSON* toJson(const SVFConstantNullPtr* value);
|
|
132
|
-
cJSON* toJson(const SVFBlackHoleValue* value);
|
|
133
|
-
cJSON* toJson(const SVFOtherValue* value);
|
|
134
|
-
cJSON* toJson(const SVFMetadataAsValue* value);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
class SVFModuleRead
|
|
138
|
-
{
|
|
139
|
-
private:
|
|
140
|
-
cJSON* moduleJson; ///< Owned pointer to the root object of the SVFModule. Be
|
|
141
|
-
///< sure to delete it with `cJSON_Delete()` it in
|
|
142
|
-
///< destructor.
|
|
143
|
-
|
|
144
|
-
SVFModule* svfModule;
|
|
145
|
-
|
|
146
|
-
std::vector<SVFType*> typePool; ///< A pool of all SVFTypes in the SVFModule
|
|
147
|
-
std::vector<cJSON*> typeArray;
|
|
148
|
-
|
|
149
|
-
std::vector<SVFValue*>
|
|
150
|
-
valuePool; ///< A pool of all SVFValues in the SVFModule
|
|
151
|
-
std::vector<cJSON*> valueArray;
|
|
152
|
-
|
|
153
|
-
public:
|
|
154
|
-
SVFModule* get();
|
|
155
|
-
SVFModuleRead(const std::string& path);
|
|
156
|
-
~SVFModuleRead();
|
|
157
|
-
|
|
158
|
-
private:
|
|
159
|
-
SVFModule* readSvfModule(cJSON* iter);
|
|
160
|
-
|
|
161
|
-
SVFType* indexToType(TypeIndex i);
|
|
162
|
-
SVFValue* indexToValue(ValueIndex i);
|
|
163
|
-
|
|
164
|
-
void fillSVFTypeAt(size_t i);
|
|
165
|
-
void fillSVFValueAt(size_t i);
|
|
166
|
-
|
|
167
|
-
StInfo* readStInfo(cJSON* iter);
|
|
168
|
-
cJSON* readJson(cJSON* iter, SVFType* type);
|
|
169
|
-
cJSON* readJson(cJSON* iter, SVFPointerType* type);
|
|
170
|
-
cJSON* readJson(cJSON* iter, SVFIntegerType* type);
|
|
171
|
-
cJSON* readJson(cJSON* iter, SVFFunctionType* type);
|
|
172
|
-
cJSON* readJson(cJSON* iter, SVFStructType* type);
|
|
173
|
-
cJSON* readJson(cJSON* iter, SVFArrayType* type);
|
|
174
|
-
cJSON* readJson(cJSON* iter, SVFOtherType* type);
|
|
175
|
-
|
|
176
|
-
SVFLoopAndDomInfo* readSvfLoopAndDomInfo(cJSON* iter);
|
|
177
|
-
cJSON* readJson(cJSON* iter, SVFValue* value);
|
|
178
|
-
cJSON* readJson(cJSON* iter, SVFFunction* value);
|
|
179
|
-
cJSON* readJson(cJSON* iter, SVFBasicBlock* value);
|
|
180
|
-
cJSON* readJson(cJSON* iter, SVFInstruction* value);
|
|
181
|
-
cJSON* readJson(cJSON* iter, SVFCallInst* value);
|
|
182
|
-
cJSON* readJson(cJSON* iter, SVFVirtualCallInst* value);
|
|
183
|
-
cJSON* readJson(cJSON* iter, SVFConstant* value);
|
|
184
|
-
cJSON* readJson(cJSON* iter, SVFGlobalValue* value);
|
|
185
|
-
cJSON* readJson(cJSON* iter, SVFArgument* value);
|
|
186
|
-
cJSON* readJson(cJSON* iter, SVFConstantData* value);
|
|
187
|
-
cJSON* readJson(cJSON* iter, SVFConstantInt* value);
|
|
188
|
-
cJSON* readJson(cJSON* iter, SVFConstantFP* value);
|
|
189
|
-
cJSON* readJson(cJSON* iter, SVFConstantNullPtr* value);
|
|
190
|
-
cJSON* readJson(cJSON* iter, SVFBlackHoleValue* value);
|
|
191
|
-
cJSON* readJson(cJSON* iter, SVFOtherValue* value);
|
|
192
|
-
cJSON* readJson(cJSON* iter, SVFMetadataAsValue* value);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
} // namespace SVF
|
|
196
|
-
|
|
197
|
-
#endif // !INCLUDE_SVFMODULE_JSON_DUMPER_H_
|