svf-tools 1.0.665 → 1.0.667
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/SVFModule.h +9 -7
- package/svf/include/SVFIR/SVFModuleRW.h +178 -0
- package/svf/include/SVFIR/SVFType.h +15 -5
- package/svf/include/SVFIR/SVFValue.h +38 -3
- package/svf/lib/Graphs/CFBasicBlockG.cpp +2 -0
- package/svf/lib/SVFIR/SVFModule.cpp +10 -2
- package/svf/lib/SVFIR/SVFModuleRW.cpp +1206 -0
- package/svf-llvm/lib/LLVMModule.cpp +7 -0
- package/svf-llvm/tools/WPA/wpa.cpp +8 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.667",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,6 +40,8 @@ namespace SVF
|
|
|
40
40
|
|
|
41
41
|
class SVFModule
|
|
42
42
|
{
|
|
43
|
+
friend class SVFModuleWrite;
|
|
44
|
+
friend class SVFModuleRead;
|
|
43
45
|
public:
|
|
44
46
|
typedef std::vector<const SVFFunction*> FunctionSetType;
|
|
45
47
|
typedef std::vector<SVFGlobalValue*> GlobalSetType;
|
|
@@ -76,7 +78,9 @@ public:
|
|
|
76
78
|
|
|
77
79
|
~SVFModule();
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
void writeToJson(const std::string& filePath);
|
|
82
|
+
|
|
83
|
+
static inline void setPagFromTXT(const std::string& txt)
|
|
80
84
|
{
|
|
81
85
|
pagReadFromTxt = txt;
|
|
82
86
|
}
|
|
@@ -88,13 +92,10 @@ public:
|
|
|
88
92
|
|
|
89
93
|
static inline bool pagReadFromTXT()
|
|
90
94
|
{
|
|
91
|
-
|
|
92
|
-
return false;
|
|
93
|
-
else
|
|
94
|
-
return true;
|
|
95
|
+
return !pagReadFromTxt.empty();
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
const SVFFunction* getSVFFunction(const std::string name);
|
|
98
|
+
const SVFFunction* getSVFFunction(const std::string& name);
|
|
98
99
|
|
|
99
100
|
///@{
|
|
100
101
|
inline void addFunctionSet(SVFFunction* svfFunc)
|
|
@@ -197,7 +198,8 @@ public:
|
|
|
197
198
|
{
|
|
198
199
|
if (pagReadFromTxt.empty())
|
|
199
200
|
{
|
|
200
|
-
assert(moduleIdentifier.empty()
|
|
201
|
+
assert(!moduleIdentifier.empty() &&
|
|
202
|
+
"No module found! Reading from a file other than LLVM-IR?");
|
|
201
203
|
return moduleIdentifier;
|
|
202
204
|
}
|
|
203
205
|
else
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SVFModuleRW.h
|
|
3
|
+
*
|
|
4
|
+
* Created on: 27 Jan 2023
|
|
5
|
+
* Author: Xudong Wang
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifndef INCLUDE_SVFMODULE_JSON_DUMPER_H_
|
|
9
|
+
#define INCLUDE_SVFMODULE_JSON_DUMPER_H_
|
|
10
|
+
|
|
11
|
+
#include <string>
|
|
12
|
+
#include <vector>
|
|
13
|
+
#include <unordered_map>
|
|
14
|
+
#include <ostream>
|
|
15
|
+
#include <memory>
|
|
16
|
+
|
|
17
|
+
struct cJSON;
|
|
18
|
+
|
|
19
|
+
namespace SVF
|
|
20
|
+
{
|
|
21
|
+
class SVFModule;
|
|
22
|
+
|
|
23
|
+
class StInfo;
|
|
24
|
+
class SVFType;
|
|
25
|
+
class SVFPointerType;
|
|
26
|
+
class SVFIntegerType;
|
|
27
|
+
class SVFFunctionType;
|
|
28
|
+
class SVFStructType;
|
|
29
|
+
class SVFArrayType;
|
|
30
|
+
class SVFOtherType;
|
|
31
|
+
|
|
32
|
+
class SVFLoopAndDomInfo;
|
|
33
|
+
class SVFValue;
|
|
34
|
+
class SVFFunction;
|
|
35
|
+
class SVFBasicBlock;
|
|
36
|
+
class SVFInstruction;
|
|
37
|
+
class SVFCallInst;
|
|
38
|
+
class SVFVirtualCallInst;
|
|
39
|
+
class SVFConstant;
|
|
40
|
+
class SVFGlobalValue;
|
|
41
|
+
class SVFArgument;
|
|
42
|
+
class SVFConstantData;
|
|
43
|
+
class SVFConstantInt;
|
|
44
|
+
class SVFConstantFP;
|
|
45
|
+
class SVFConstantNullPtr;
|
|
46
|
+
class SVFBlackHoleValue;
|
|
47
|
+
class SVFOtherValue;
|
|
48
|
+
class SVFMetadataAsValue;
|
|
49
|
+
|
|
50
|
+
using TypeIndex = std::size_t;
|
|
51
|
+
using ValueIndex = std::size_t;
|
|
52
|
+
|
|
53
|
+
class SVFModuleWrite
|
|
54
|
+
{
|
|
55
|
+
private:
|
|
56
|
+
const SVFModule* module; ///< Borrowed pointer to the SVFModule.
|
|
57
|
+
const char* jsonStr; ///< Json string of the SVFModule. It gets freed by
|
|
58
|
+
/// `cJSON_free()` in destructor.
|
|
59
|
+
|
|
60
|
+
std::unordered_map<const SVFType*, TypeIndex> typeToIndex;
|
|
61
|
+
std::vector<const SVFType*>
|
|
62
|
+
typePool; ///< A pool of all SVFTypes in the SVFModule
|
|
63
|
+
TypeIndex getTypeIndex(const SVFType* type);
|
|
64
|
+
const char* getStrTypeIndex(const SVFType* type);
|
|
65
|
+
|
|
66
|
+
std::unordered_map<const SVFValue*, ValueIndex> valueToIndex;
|
|
67
|
+
std::vector<const SVFValue*>
|
|
68
|
+
valuePool; ///< A pool of all SVFValues in the SVFModule
|
|
69
|
+
ValueIndex getValueIndex(const SVFValue* value);
|
|
70
|
+
const char* getStrValueIndex(const SVFValue* value);
|
|
71
|
+
|
|
72
|
+
std::vector<std::unique_ptr<std::string>> allIndices;
|
|
73
|
+
const char* getStrOfIndex(std::size_t index);
|
|
74
|
+
|
|
75
|
+
public:
|
|
76
|
+
SVFModuleWrite(const SVFModule* module);
|
|
77
|
+
/// @brief Dump the SVFModule to a file in JSON format at the given path.
|
|
78
|
+
SVFModuleWrite(const SVFModule* module, const std::string& path);
|
|
79
|
+
void dumpJsonToPath(const std::string& path);
|
|
80
|
+
void dumpJsonToOstream(std::ostream& os);
|
|
81
|
+
~SVFModuleWrite();
|
|
82
|
+
|
|
83
|
+
private:
|
|
84
|
+
cJSON* moduleToJson(const SVFModule* module);
|
|
85
|
+
|
|
86
|
+
cJSON* typeToJson(const SVFType* type);
|
|
87
|
+
cJSON* toJson(const StInfo* stInfo);
|
|
88
|
+
// SVFType and all its descendants/subclasses.
|
|
89
|
+
cJSON* toJson(const SVFType* type);
|
|
90
|
+
cJSON* toJson(const SVFPointerType* type);
|
|
91
|
+
cJSON* toJson(const SVFIntegerType* type);
|
|
92
|
+
cJSON* toJson(const SVFFunctionType* type);
|
|
93
|
+
cJSON* toJson(const SVFStructType* type);
|
|
94
|
+
cJSON* toJson(const SVFArrayType* type);
|
|
95
|
+
cJSON* toJson(const SVFOtherType* type);
|
|
96
|
+
|
|
97
|
+
cJSON* valueToJson(const SVFValue* value);
|
|
98
|
+
cJSON* toJson(const SVFLoopAndDomInfo* ldInfo);
|
|
99
|
+
// SVFValue and all its descendants/subclasses.
|
|
100
|
+
cJSON* toJson(const SVFValue* value);
|
|
101
|
+
cJSON* toJson(const SVFFunction* value);
|
|
102
|
+
cJSON* toJson(const SVFBasicBlock* value);
|
|
103
|
+
cJSON* toJson(const SVFInstruction* value);
|
|
104
|
+
cJSON* toJson(const SVFCallInst* value);
|
|
105
|
+
cJSON* toJson(const SVFVirtualCallInst* value);
|
|
106
|
+
cJSON* toJson(const SVFConstant* value);
|
|
107
|
+
cJSON* toJson(const SVFGlobalValue* value);
|
|
108
|
+
cJSON* toJson(const SVFArgument* value);
|
|
109
|
+
cJSON* toJson(const SVFConstantData* value);
|
|
110
|
+
cJSON* toJson(const SVFConstantInt* value);
|
|
111
|
+
cJSON* toJson(const SVFConstantFP* value);
|
|
112
|
+
cJSON* toJson(const SVFConstantNullPtr* value);
|
|
113
|
+
cJSON* toJson(const SVFBlackHoleValue* value);
|
|
114
|
+
cJSON* toJson(const SVFOtherValue* value);
|
|
115
|
+
cJSON* toJson(const SVFMetadataAsValue* value);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
class SVFModuleRead
|
|
119
|
+
{
|
|
120
|
+
private:
|
|
121
|
+
cJSON* moduleJson; ///< Owned pointer to the root object of the SVFModule. Be
|
|
122
|
+
///< sure to delete it with `cJSON_Delete()` it in
|
|
123
|
+
///< destructor.
|
|
124
|
+
|
|
125
|
+
SVFModule* svfModule;
|
|
126
|
+
|
|
127
|
+
std::vector<SVFType*> typePool; ///< A pool of all SVFTypes in the SVFModule
|
|
128
|
+
std::vector<cJSON*> typeArray;
|
|
129
|
+
|
|
130
|
+
std::vector<SVFValue*>
|
|
131
|
+
valuePool; ///< A pool of all SVFValues in the SVFModule
|
|
132
|
+
std::vector<cJSON*> valueArray;
|
|
133
|
+
|
|
134
|
+
public:
|
|
135
|
+
SVFModule* get();
|
|
136
|
+
SVFModuleRead(const std::string& path);
|
|
137
|
+
~SVFModuleRead();
|
|
138
|
+
|
|
139
|
+
private:
|
|
140
|
+
SVFModule* readSvfModule(cJSON* iter);
|
|
141
|
+
|
|
142
|
+
SVFType* indexToType(TypeIndex i);
|
|
143
|
+
SVFValue* indexToValue(ValueIndex i);
|
|
144
|
+
|
|
145
|
+
void fillSvfTypeAt(size_t i);
|
|
146
|
+
void fillSvfValueAt(size_t i);
|
|
147
|
+
|
|
148
|
+
StInfo* readStInfo(cJSON* iter);
|
|
149
|
+
cJSON* readJson(cJSON* iter, SVFType* type);
|
|
150
|
+
cJSON* readJson(cJSON* iter, SVFPointerType* type);
|
|
151
|
+
cJSON* readJson(cJSON* iter, SVFIntegerType* type);
|
|
152
|
+
cJSON* readJson(cJSON* iter, SVFFunctionType* type);
|
|
153
|
+
cJSON* readJson(cJSON* iter, SVFStructType* type);
|
|
154
|
+
cJSON* readJson(cJSON* iter, SVFArrayType* type);
|
|
155
|
+
cJSON* readJson(cJSON* iter, SVFOtherType* type);
|
|
156
|
+
|
|
157
|
+
SVFLoopAndDomInfo* readSvfLoopAndDomInfo(cJSON* iter);
|
|
158
|
+
cJSON* readJson(cJSON* iter, SVFValue* value);
|
|
159
|
+
cJSON* readJson(cJSON* iter, SVFFunction* value);
|
|
160
|
+
cJSON* readJson(cJSON* iter, SVFBasicBlock* value);
|
|
161
|
+
cJSON* readJson(cJSON* iter, SVFInstruction* value);
|
|
162
|
+
cJSON* readJson(cJSON* iter, SVFCallInst* value);
|
|
163
|
+
cJSON* readJson(cJSON* iter, SVFVirtualCallInst* value);
|
|
164
|
+
cJSON* readJson(cJSON* iter, SVFConstant* value);
|
|
165
|
+
cJSON* readJson(cJSON* iter, SVFGlobalValue* value);
|
|
166
|
+
cJSON* readJson(cJSON* iter, SVFArgument* value);
|
|
167
|
+
cJSON* readJson(cJSON* iter, SVFConstantData* value);
|
|
168
|
+
cJSON* readJson(cJSON* iter, SVFConstantInt* value);
|
|
169
|
+
cJSON* readJson(cJSON* iter, SVFConstantFP* value);
|
|
170
|
+
cJSON* readJson(cJSON* iter, SVFConstantNullPtr* value);
|
|
171
|
+
cJSON* readJson(cJSON* iter, SVFBlackHoleValue* value);
|
|
172
|
+
cJSON* readJson(cJSON* iter, SVFOtherValue* value);
|
|
173
|
+
cJSON* readJson(cJSON* iter, SVFMetadataAsValue* value);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
} // namespace SVF
|
|
177
|
+
|
|
178
|
+
#endif // !INCLUDE_SVFMODULE_JSON_DUMPER_H_
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
|
|
45
45
|
namespace SVF
|
|
46
46
|
{
|
|
47
|
+
class SVFType;
|
|
48
|
+
class SVFPointerType;
|
|
47
49
|
|
|
48
50
|
typedef std::ostream OutStream;
|
|
49
51
|
typedef unsigned u32_t;
|
|
@@ -123,14 +125,15 @@ template <typename Key, typename Value, typename Hash = Hash<Key>,
|
|
|
123
125
|
typedef std::pair<NodeID, Version> VersionedVar;
|
|
124
126
|
typedef Set<VersionedVar> VersionedVarSet;
|
|
125
127
|
|
|
126
|
-
class SVFType;
|
|
127
|
-
class SVFPointerType;
|
|
128
|
-
|
|
129
128
|
/*!
|
|
130
|
-
* Flatterned type information of StructType, ArrayType and
|
|
129
|
+
* Flatterned type information of StructType, ArrayType and
|
|
130
|
+
* SingleValueType
|
|
131
131
|
*/
|
|
132
132
|
class StInfo
|
|
133
133
|
{
|
|
134
|
+
friend class SVFModuleWrite;
|
|
135
|
+
friend class SVFModuleRead;
|
|
136
|
+
|
|
134
137
|
private:
|
|
135
138
|
/// flattened field indices of a struct (ignoring arrays)
|
|
136
139
|
std::vector<u32_t> fldIdxVec;
|
|
@@ -235,6 +238,8 @@ public:
|
|
|
235
238
|
|
|
236
239
|
class SVFType
|
|
237
240
|
{
|
|
241
|
+
friend class SVFModuleWrite;
|
|
242
|
+
friend class SVFModuleRead;
|
|
238
243
|
|
|
239
244
|
public:
|
|
240
245
|
typedef s64_t GNodeK;
|
|
@@ -254,7 +259,7 @@ private:
|
|
|
254
259
|
GNodeK kind; ///< used for classof
|
|
255
260
|
const SVFPointerType*
|
|
256
261
|
getPointerToTy; /// Return a pointer to the current type
|
|
257
|
-
StInfo* typeinfo;
|
|
262
|
+
StInfo* typeinfo; ///< SVF's TypeInfo
|
|
258
263
|
bool isSingleValTy; ///< The type represents a single value, not struct or
|
|
259
264
|
///< array
|
|
260
265
|
protected:
|
|
@@ -318,6 +323,8 @@ public:
|
|
|
318
323
|
|
|
319
324
|
class SVFPointerType : public SVFType
|
|
320
325
|
{
|
|
326
|
+
friend class SVFModuleWrite;
|
|
327
|
+
friend class SVFModuleRead;
|
|
321
328
|
|
|
322
329
|
private:
|
|
323
330
|
const SVFType* ptrElementType;
|
|
@@ -349,6 +356,9 @@ public:
|
|
|
349
356
|
|
|
350
357
|
class SVFFunctionType : public SVFType
|
|
351
358
|
{
|
|
359
|
+
friend class SVFModuleWrite;
|
|
360
|
+
friend class SVFModuleRead;
|
|
361
|
+
|
|
352
362
|
private:
|
|
353
363
|
const SVFType* retTy;
|
|
354
364
|
|
|
@@ -49,6 +49,8 @@ class SVFType;
|
|
|
49
49
|
|
|
50
50
|
class SVFLoopAndDomInfo
|
|
51
51
|
{
|
|
52
|
+
friend class SVFModuleWrite;
|
|
53
|
+
friend class SVFModuleRead;
|
|
52
54
|
public:
|
|
53
55
|
typedef Set<const SVFBasicBlock*> BBSet;
|
|
54
56
|
typedef std::vector<const SVFBasicBlock*> BBList;
|
|
@@ -79,7 +81,7 @@ public:
|
|
|
79
81
|
|
|
80
82
|
inline bool hasLoopInfo(const SVFBasicBlock* bb) const
|
|
81
83
|
{
|
|
82
|
-
return bb2LoopMap.find(bb)!=bb2LoopMap.end();
|
|
84
|
+
return bb2LoopMap.find(bb) != bb2LoopMap.end();
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const;
|
|
@@ -92,7 +94,7 @@ public:
|
|
|
92
94
|
|
|
93
95
|
inline bool loopContainsBB(const LoopBBs& lp, const SVFBasicBlock* bb) const
|
|
94
96
|
{
|
|
95
|
-
return std::find(lp.begin(), lp.end(), bb)!=lp.end();
|
|
97
|
+
return std::find(lp.begin(), lp.end(), bb) != lp.end();
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
inline void addToBB2LoopMap(const SVFBasicBlock* bb, const SVFBasicBlock* loopBB)
|
|
@@ -122,7 +124,8 @@ public:
|
|
|
122
124
|
|
|
123
125
|
inline bool isUnreachable(const SVFBasicBlock* bb) const
|
|
124
126
|
{
|
|
125
|
-
return std::find(reachableBBs.begin(), reachableBBs.end(), bb)==
|
|
127
|
+
return std::find(reachableBBs.begin(), reachableBBs.end(), bb) ==
|
|
128
|
+
reachableBBs.end();
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
inline const BBList& getReachableBBs() const
|
|
@@ -146,6 +149,8 @@ public:
|
|
|
146
149
|
|
|
147
150
|
class SVFValue
|
|
148
151
|
{
|
|
152
|
+
friend class SVFModuleWrite;
|
|
153
|
+
friend class SVFModuleRead;
|
|
149
154
|
friend class LLVMModuleSet;
|
|
150
155
|
|
|
151
156
|
public:
|
|
@@ -257,6 +262,8 @@ public:
|
|
|
257
262
|
class SVFFunction : public SVFValue
|
|
258
263
|
{
|
|
259
264
|
friend class LLVMModuleSet;
|
|
265
|
+
friend class SVFModuleWrite;
|
|
266
|
+
friend class SVFModuleRead;
|
|
260
267
|
|
|
261
268
|
public:
|
|
262
269
|
typedef std::vector<const SVFBasicBlock*>::const_iterator const_iterator;
|
|
@@ -471,6 +478,8 @@ public:
|
|
|
471
478
|
class SVFBasicBlock : public SVFValue
|
|
472
479
|
{
|
|
473
480
|
friend class LLVMModuleSet;
|
|
481
|
+
friend class SVFModuleWrite;
|
|
482
|
+
friend class SVFModuleRead;
|
|
474
483
|
|
|
475
484
|
public:
|
|
476
485
|
typedef std::vector<const SVFInstruction*>::const_iterator const_iterator;
|
|
@@ -569,6 +578,8 @@ public:
|
|
|
569
578
|
|
|
570
579
|
class SVFInstruction : public SVFValue
|
|
571
580
|
{
|
|
581
|
+
friend class SVFModuleWrite;
|
|
582
|
+
friend class SVFModuleRead;
|
|
572
583
|
public:
|
|
573
584
|
typedef std::vector<const SVFInstruction*> InstVec;
|
|
574
585
|
|
|
@@ -634,6 +645,8 @@ public:
|
|
|
634
645
|
|
|
635
646
|
class SVFCallInst : public SVFInstruction
|
|
636
647
|
{
|
|
648
|
+
friend class SVFModuleWrite;
|
|
649
|
+
friend class SVFModuleRead;
|
|
637
650
|
friend class LLVMModuleSet;
|
|
638
651
|
|
|
639
652
|
private:
|
|
@@ -706,6 +719,8 @@ public:
|
|
|
706
719
|
|
|
707
720
|
class SVFVirtualCallInst : public SVFCallInst
|
|
708
721
|
{
|
|
722
|
+
friend class SVFModuleWrite;
|
|
723
|
+
friend class SVFModuleRead;
|
|
709
724
|
friend class LLVMModuleSet;
|
|
710
725
|
|
|
711
726
|
private:
|
|
@@ -762,6 +777,8 @@ public:
|
|
|
762
777
|
|
|
763
778
|
class SVFConstant : public SVFValue
|
|
764
779
|
{
|
|
780
|
+
friend class SVFModuleWrite;
|
|
781
|
+
friend class SVFModuleRead;
|
|
765
782
|
public:
|
|
766
783
|
SVFConstant(const std::string& _const, const SVFType* ty, SVFValKind k = SVFConst): SVFValue(_const, ty, k)
|
|
767
784
|
{
|
|
@@ -782,6 +799,8 @@ public:
|
|
|
782
799
|
|
|
783
800
|
class SVFGlobalValue : public SVFConstant
|
|
784
801
|
{
|
|
802
|
+
friend class SVFModuleWrite;
|
|
803
|
+
friend class SVFModuleRead;
|
|
785
804
|
friend class LLVMModuleSet;
|
|
786
805
|
|
|
787
806
|
private:
|
|
@@ -818,6 +837,8 @@ public:
|
|
|
818
837
|
|
|
819
838
|
class SVFArgument : public SVFValue
|
|
820
839
|
{
|
|
840
|
+
friend class SVFModuleWrite;
|
|
841
|
+
friend class SVFModuleRead;
|
|
821
842
|
private:
|
|
822
843
|
const SVFFunction* fun;
|
|
823
844
|
u32_t argNo;
|
|
@@ -855,6 +876,8 @@ public:
|
|
|
855
876
|
|
|
856
877
|
class SVFConstantData : public SVFConstant
|
|
857
878
|
{
|
|
879
|
+
friend class SVFModuleWrite;
|
|
880
|
+
friend class SVFModuleRead;
|
|
858
881
|
public:
|
|
859
882
|
SVFConstantData(const std::string& _const, const SVFType* ty, SVFValKind k = SVFConstData): SVFConstant(_const, ty, k)
|
|
860
883
|
{
|
|
@@ -882,6 +905,8 @@ public:
|
|
|
882
905
|
|
|
883
906
|
class SVFConstantInt : public SVFConstantData
|
|
884
907
|
{
|
|
908
|
+
friend class SVFModuleWrite;
|
|
909
|
+
friend class SVFModuleRead;
|
|
885
910
|
private:
|
|
886
911
|
u64_t zval;
|
|
887
912
|
s64_t sval;
|
|
@@ -914,6 +939,8 @@ public:
|
|
|
914
939
|
|
|
915
940
|
class SVFConstantFP : public SVFConstantData
|
|
916
941
|
{
|
|
942
|
+
friend class SVFModuleWrite;
|
|
943
|
+
friend class SVFModuleRead;
|
|
917
944
|
private:
|
|
918
945
|
float dval;
|
|
919
946
|
public:
|
|
@@ -939,6 +966,8 @@ public:
|
|
|
939
966
|
|
|
940
967
|
class SVFConstantNullPtr : public SVFConstantData
|
|
941
968
|
{
|
|
969
|
+
friend class SVFModuleWrite;
|
|
970
|
+
friend class SVFModuleRead;
|
|
942
971
|
|
|
943
972
|
public:
|
|
944
973
|
SVFConstantNullPtr(const std::string& _const, const SVFType* ty): SVFConstantData(_const, ty, SVFValue::SVFNullPtr)
|
|
@@ -958,6 +987,8 @@ public:
|
|
|
958
987
|
|
|
959
988
|
class SVFBlackHoleValue : public SVFConstantData
|
|
960
989
|
{
|
|
990
|
+
friend class SVFModuleWrite;
|
|
991
|
+
friend class SVFModuleRead;
|
|
961
992
|
|
|
962
993
|
public:
|
|
963
994
|
SVFBlackHoleValue(const std::string& _const, const SVFType* ty): SVFConstantData(_const, ty, SVFValue::SVFBlackHole)
|
|
@@ -977,6 +1008,8 @@ public:
|
|
|
977
1008
|
|
|
978
1009
|
class SVFOtherValue : public SVFValue
|
|
979
1010
|
{
|
|
1011
|
+
friend class SVFModuleWrite;
|
|
1012
|
+
friend class SVFModuleRead;
|
|
980
1013
|
public:
|
|
981
1014
|
SVFOtherValue(const std::string& other, const SVFType* ty, SVFValKind k = SVFValue::SVFOther): SVFValue(other, ty, k)
|
|
982
1015
|
{
|
|
@@ -994,6 +1027,8 @@ public:
|
|
|
994
1027
|
*/
|
|
995
1028
|
class SVFMetadataAsValue : public SVFOtherValue
|
|
996
1029
|
{
|
|
1030
|
+
friend class SVFModuleWrite;
|
|
1031
|
+
friend class SVFModuleRead;
|
|
997
1032
|
public:
|
|
998
1033
|
SVFMetadataAsValue(const std::string& other, const SVFType* ty): SVFOtherValue(other, ty, SVFValue::SVFMetaAsValue)
|
|
999
1034
|
{
|
|
@@ -93,6 +93,8 @@ const CFBasicBlockEdge* CFBasicBlockGraph::getOrAddCFBasicBlockEdge(CFBasicBlock
|
|
|
93
93
|
CFBasicBlockEdge *edge = new CFBasicBlockEdge(src, dst);
|
|
94
94
|
bool added1 = edge->getDstNode()->addIncomingEdge(edge);
|
|
95
95
|
bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
|
|
96
|
+
(void) added1;
|
|
97
|
+
(void) added2;
|
|
96
98
|
assert(added1 && added2 && "edge not added??");
|
|
97
99
|
_totalCFBasicBlockEdge++;
|
|
98
100
|
return edge;
|
|
@@ -22,9 +22,11 @@
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
#include "SVFIR/SVFModule.h"
|
|
25
|
+
#include "SVFIR/SVFModuleRW.h"
|
|
25
26
|
#include "SVFIR/SymbolTableInfo.h"
|
|
26
27
|
#include "Util/SVFUtil.h"
|
|
27
28
|
#include "Util/SVFStat.h"
|
|
29
|
+
#include "Util/Options.h"
|
|
28
30
|
|
|
29
31
|
using namespace SVF;
|
|
30
32
|
|
|
@@ -41,7 +43,7 @@ SVFModule::~SVFModule()
|
|
|
41
43
|
ExtAPI::destory();
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
const SVFFunction* SVFModule::getSVFFunction(std::string name)
|
|
46
|
+
const SVFFunction* SVFModule::getSVFFunction(const std::string& name)
|
|
45
47
|
{
|
|
46
48
|
for (const SVFFunction* fun : getFunctionSet())
|
|
47
49
|
{
|
|
@@ -51,4 +53,10 @@ const SVFFunction* SVFModule::getSVFFunction(std::string name)
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
return nullptr;
|
|
54
|
-
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void SVFModule::writeToJson(const std::string& filePath)
|
|
59
|
+
{
|
|
60
|
+
if (!filePath.empty())
|
|
61
|
+
SVFModuleWrite(this, filePath);
|
|
62
|
+
}
|