svf-lib 1.0.1827 → 1.0.1829
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-linux/Release-build/svf/libSvfCore.a +0 -0
- package/SVF-linux/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/SVF-linux/svf/include/SVFIR/SVFType.h +10 -36
- package/SVF-linux/svf/include/Util/Options.h +1 -0
- package/SVF-linux/svf-llvm/include/SVF-LLVM/LLVMModule.h +5 -1
- package/SVF-linux/svf-llvm/include/SVF-LLVM/LLVMUtil.h +4 -4
- package/SVF-linux/svf-llvm/include/SVF-LLVM/ObjTypeInference.h +110 -0
- package/SVF-linux/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +1 -1
- package/SVF-linux/svf-llvm/include/SVF-LLVM/SymbolTableBuilder.h +14 -0
- package/SVF-osx/Release-build/svf/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/svf-llvm/extapi.bc +2434 -0
- package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
- package/package.json +1 -1
- /package/SVF-osx/svf-llvm/include/SVF-LLVM/{CPPUtil.h → CppUtil.h} +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -261,27 +261,25 @@ public:
|
|
|
261
261
|
|
|
262
262
|
public:
|
|
263
263
|
|
|
264
|
-
inline static SVFType*
|
|
264
|
+
inline static SVFType* getSVFPtrType()
|
|
265
265
|
{
|
|
266
|
-
assert(
|
|
267
|
-
return
|
|
266
|
+
assert(svfPtrTy && "ptr type not set?");
|
|
267
|
+
return svfPtrTy;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
inline static SVFType*
|
|
270
|
+
inline static SVFType* getSVFInt8Type()
|
|
271
271
|
{
|
|
272
|
-
assert(
|
|
273
|
-
return
|
|
272
|
+
assert(svfI8Ty && "int8 type not set?");
|
|
273
|
+
return svfI8Ty;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
private:
|
|
277
277
|
|
|
278
|
-
static SVFType*
|
|
279
|
-
static SVFType*
|
|
278
|
+
static SVFType* svfPtrTy; ///< ptr type
|
|
279
|
+
static SVFType* svfI8Ty; ///< 8-bit int type
|
|
280
280
|
|
|
281
281
|
private:
|
|
282
282
|
GNodeK kind; ///< used for classof
|
|
283
|
-
const SVFPointerType*
|
|
284
|
-
getPointerToTy; /// Return a pointer to the current type
|
|
285
283
|
StInfo* typeinfo; ///< SVF's TypeInfo
|
|
286
284
|
bool isSingleValTy; ///< The type represents a single value, not struct or
|
|
287
285
|
u32_t byteSize; ///< LLVM Byte Size
|
|
@@ -289,7 +287,7 @@ private:
|
|
|
289
287
|
|
|
290
288
|
protected:
|
|
291
289
|
SVFType(bool svt, SVFTyKind k, u32_t Sz = 1)
|
|
292
|
-
: kind(k),
|
|
290
|
+
: kind(k), typeinfo(nullptr),
|
|
293
291
|
isSingleValTy(svt), byteSize(Sz)
|
|
294
292
|
{
|
|
295
293
|
}
|
|
@@ -309,17 +307,6 @@ public:
|
|
|
309
307
|
|
|
310
308
|
virtual void print(std::ostream& os) const = 0;
|
|
311
309
|
|
|
312
|
-
inline void setPointerTo(const SVFPointerType* ty)
|
|
313
|
-
{
|
|
314
|
-
getPointerToTy = ty;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
inline const SVFPointerType* getPointerTo() const
|
|
318
|
-
{
|
|
319
|
-
assert(getPointerToTy && "set the getPointerToTy first");
|
|
320
|
-
return getPointerToTy;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
310
|
|
|
324
311
|
inline void setTypeInfo(StInfo* ti)
|
|
325
312
|
{
|
|
@@ -373,12 +360,9 @@ class SVFPointerType : public SVFType
|
|
|
373
360
|
friend class SVFIRWriter;
|
|
374
361
|
friend class SVFIRReader;
|
|
375
362
|
|
|
376
|
-
private:
|
|
377
|
-
const SVFType* ptrElementType;
|
|
378
|
-
|
|
379
363
|
public:
|
|
380
364
|
SVFPointerType(u32_t byteSize = 1)
|
|
381
|
-
: SVFType(true, SVFPointerTy, byteSize)
|
|
365
|
+
: SVFType(true, SVFPointerTy, byteSize)
|
|
382
366
|
{
|
|
383
367
|
}
|
|
384
368
|
|
|
@@ -386,16 +370,6 @@ public:
|
|
|
386
370
|
{
|
|
387
371
|
return node->getKind() == SVFPointerTy;
|
|
388
372
|
}
|
|
389
|
-
inline const SVFType* getPtrElementType() const
|
|
390
|
-
{
|
|
391
|
-
assert(ptrElementType && "ptrElementType is nullptr");
|
|
392
|
-
return ptrElementType;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
inline void setPtrElementType(SVFType* _ptrElementType)
|
|
396
|
-
{
|
|
397
|
-
ptrElementType = _ptrElementType;
|
|
398
|
-
}
|
|
399
373
|
|
|
400
374
|
void print(std::ostream& os) const override;
|
|
401
375
|
};
|
|
@@ -128,6 +128,7 @@ public:
|
|
|
128
128
|
static const Option<u32_t> IndirectCallLimit;
|
|
129
129
|
static const Option<bool> UsePreCompFieldSensitive;
|
|
130
130
|
static const Option<bool> EnableAliasCheck;
|
|
131
|
+
static const Option<bool> EnableTypeCheck;
|
|
131
132
|
static const Option<bool> EnableThreadCallGraph;
|
|
132
133
|
static const Option<bool> ConnectVCallOnCHA;
|
|
133
134
|
|
|
@@ -39,6 +39,7 @@ namespace SVF
|
|
|
39
39
|
{
|
|
40
40
|
|
|
41
41
|
class SymbolTableInfo;
|
|
42
|
+
class ObjTypeInference;
|
|
42
43
|
|
|
43
44
|
class LLVMModuleSet
|
|
44
45
|
{
|
|
@@ -88,6 +89,7 @@ private:
|
|
|
88
89
|
SVFValue2LLVMValueMap SVFValue2LLVMValue;
|
|
89
90
|
LLVMType2SVFTypeMap LLVMType2SVFType;
|
|
90
91
|
Type2TypeInfoMap Type2TypeInfo;
|
|
92
|
+
ObjTypeInference* typeInference;
|
|
91
93
|
|
|
92
94
|
/// Constructor
|
|
93
95
|
LLVMModuleSet();
|
|
@@ -95,7 +97,7 @@ private:
|
|
|
95
97
|
void build();
|
|
96
98
|
|
|
97
99
|
public:
|
|
98
|
-
~LLVMModuleSet()
|
|
100
|
+
~LLVMModuleSet();
|
|
99
101
|
|
|
100
102
|
static inline LLVMModuleSet* getLLVMModuleSet()
|
|
101
103
|
{
|
|
@@ -343,6 +345,8 @@ public:
|
|
|
343
345
|
/// Get LLVM Type
|
|
344
346
|
const Type* getLLVMType(const SVFType* T) const;
|
|
345
347
|
|
|
348
|
+
ObjTypeInference* getTypeInference();
|
|
349
|
+
|
|
346
350
|
private:
|
|
347
351
|
/// Create SVFTypes
|
|
348
352
|
SVFType* addSVFTypeInfo(const Type* t);
|
|
@@ -106,10 +106,9 @@ static inline Type* getPtrElementType(const PointerType* pty)
|
|
|
106
106
|
#endif
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
///
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//@}
|
|
109
|
+
/// Return size of this object based on LLVM value
|
|
110
|
+
u32_t getNumOfElements(const Type* ety);
|
|
111
|
+
|
|
113
112
|
|
|
114
113
|
/// Return true if this value refers to a object
|
|
115
114
|
bool isObject(const Value* ref);
|
|
@@ -362,6 +361,7 @@ std::string dumpValue(const Value* val);
|
|
|
362
361
|
|
|
363
362
|
std::string dumpType(const Type* type);
|
|
364
363
|
|
|
364
|
+
std::string dumpValueAndDbgInfo(const Value* val);
|
|
365
365
|
|
|
366
366
|
/**
|
|
367
367
|
* See more: https://github.com/SVF-tools/SVF/pull/1191
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//===- ObjTypeInference.h -- Type inference----------------------------//
|
|
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 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
|
+
* ObjTypeInference.h
|
|
25
|
+
*
|
|
26
|
+
* Created by Xiao Cheng on 10/01/24.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef SVF_OBJTYPEINFERENCE_H
|
|
31
|
+
#define SVF_OBJTYPEINFERENCE_H
|
|
32
|
+
|
|
33
|
+
#include "Util/SVFUtil.h"
|
|
34
|
+
#include "SVF-LLVM/BasicTypes.h"
|
|
35
|
+
#include "SVFIR/SVFValue.h"
|
|
36
|
+
#include "Util/ThreadAPI.h"
|
|
37
|
+
|
|
38
|
+
namespace SVF
|
|
39
|
+
{
|
|
40
|
+
class ObjTypeInference
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
public:
|
|
44
|
+
typedef Set<const Value *> ValueSet;
|
|
45
|
+
typedef Map<const Value *, ValueSet> ValueToValueSet;
|
|
46
|
+
typedef ValueToValueSet ValueToInferSites;
|
|
47
|
+
typedef ValueToValueSet ValueToSources;
|
|
48
|
+
typedef Map<const Value *, const Type *> ValueToType;
|
|
49
|
+
typedef std::pair<const Value *, bool> ValueBoolPair;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
private:
|
|
53
|
+
ValueToInferSites _valueToInferSites; // value inference site cache
|
|
54
|
+
ValueToType _valueToType; // value type cache
|
|
55
|
+
ValueToSources _valueToAllocs; // value allocations (stack, static, heap) cache
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
|
|
60
|
+
explicit ObjTypeInference() = default;
|
|
61
|
+
|
|
62
|
+
~ObjTypeInference() = default;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/// get or infer the type of a value
|
|
66
|
+
const Type *inferObjType(const Value *startValue);
|
|
67
|
+
|
|
68
|
+
/// Validate type inference
|
|
69
|
+
void validateTypeCheck(const CallBase *cs);
|
|
70
|
+
|
|
71
|
+
void typeSizeDiffTest(const PointerType *oPTy, const Type *iTy, const Value *val);
|
|
72
|
+
|
|
73
|
+
/// Default type
|
|
74
|
+
const Type *defaultType(const Value *val);
|
|
75
|
+
|
|
76
|
+
/// Pointer type
|
|
77
|
+
inline const Type *ptrType()
|
|
78
|
+
{
|
|
79
|
+
return PointerType::getUnqual(getLLVMCtx());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Int8 type
|
|
83
|
+
inline const IntegerType *int8Type()
|
|
84
|
+
{
|
|
85
|
+
return Type::getInt8Ty(getLLVMCtx());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
LLVMContext &getLLVMCtx();
|
|
89
|
+
|
|
90
|
+
private:
|
|
91
|
+
|
|
92
|
+
/// Forward collect all possible infer sites starting from a value
|
|
93
|
+
const Type *fwInferObjType(const Value *startValue);
|
|
94
|
+
|
|
95
|
+
/// Backward collect all possible allocation sites (stack, static, heap) starting from a value
|
|
96
|
+
Set<const Value *> bwfindAllocations(const Value *startValue);
|
|
97
|
+
|
|
98
|
+
bool isAllocation(const Value *val);
|
|
99
|
+
|
|
100
|
+
public:
|
|
101
|
+
/// Select the largest (conservative) type from all types
|
|
102
|
+
const Type *selectLargestType(Set<const Type *> &objTys);
|
|
103
|
+
|
|
104
|
+
u32_t objTyToNumFields(const Type *objTy);
|
|
105
|
+
|
|
106
|
+
u32_t getArgPosInCall(const CallBase *callBase, const Value *arg);
|
|
107
|
+
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
#endif //SVF_OBJTYPEINFERENCE_H
|
|
@@ -271,7 +271,7 @@ protected:
|
|
|
271
271
|
inline NodeID addNullPtrNode()
|
|
272
272
|
{
|
|
273
273
|
LLVMContext& cxt = LLVMModuleSet::getLLVMModuleSet()->getContext();
|
|
274
|
-
ConstantPointerNull* constNull = ConstantPointerNull::get(
|
|
274
|
+
ConstantPointerNull* constNull = ConstantPointerNull::get(PointerType::getUnqual(cxt));
|
|
275
275
|
NodeID nullPtr = pag->addValNode(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(constNull),pag->getNullPtr());
|
|
276
276
|
setCurrentLocation(constNull, nullptr);
|
|
277
277
|
addBlackHoleAddrEdge(pag->getBlkPtr());
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
namespace SVF
|
|
40
40
|
{
|
|
41
41
|
|
|
42
|
+
class ObjTypeInference;
|
|
43
|
+
|
|
42
44
|
class SymbolTableBuilder
|
|
43
45
|
{
|
|
44
46
|
friend class SVFIRBuilder;
|
|
@@ -82,6 +84,18 @@ protected:
|
|
|
82
84
|
void handleCE(const Value* val);
|
|
83
85
|
// @}
|
|
84
86
|
|
|
87
|
+
|
|
88
|
+
ObjTypeInference* getTypeInference();
|
|
89
|
+
|
|
90
|
+
/// Forward collect all possible infer sites starting from a value
|
|
91
|
+
const Type* inferObjType(const Value *startValue);
|
|
92
|
+
|
|
93
|
+
/// Get the reference type of heap/static object from an allocation site.
|
|
94
|
+
//@{
|
|
95
|
+
const Type *inferTypeOfHeapObjOrStaticObj(const Instruction* inst);
|
|
96
|
+
//@}
|
|
97
|
+
|
|
98
|
+
|
|
85
99
|
/// Create an objectInfo based on LLVM value
|
|
86
100
|
ObjTypeInfo* createObjTypeInfo(const Value* val);
|
|
87
101
|
|
|
Binary file
|