svf-lib 1.0.1834 → 1.0.1835
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-llvm/libSvfLLVM.a +0 -0
- package/SVF-linux/svf-llvm/include/SVF-LLVM/BasicTypes.h +1 -0
- package/SVF-linux/svf-llvm/include/SVF-LLVM/CppUtil.h +31 -1
- package/SVF-linux/svf-llvm/include/SVF-LLVM/LLVMUtil.h +3 -1
- package/SVF-linux/svf-llvm/include/SVF-LLVM/ObjTypeInference.h +30 -12
- package/package.json +1 -1
|
Binary file
|
|
@@ -113,7 +113,7 @@ const Value* getVCallVtblPtr(const CallBase* cs);
|
|
|
113
113
|
s32_t getVCallIdx(const CallBase* cs);
|
|
114
114
|
bool classTyHasVTable(const StructType* ty);
|
|
115
115
|
std::string getClassNameFromType(const StructType* ty);
|
|
116
|
-
std::string getClassNameOfThisPtr(const CallBase* cs);
|
|
116
|
+
Set<std::string> getClassNameOfThisPtr(const CallBase* cs);
|
|
117
117
|
std::string getFunNameOfVCallSite(const CallBase* cs);
|
|
118
118
|
bool VCallInCtorOrDtor(const CallBase* cs);
|
|
119
119
|
|
|
@@ -129,6 +129,36 @@ bool VCallInCtorOrDtor(const CallBase* cs);
|
|
|
129
129
|
bool isSameThisPtrInConstructor(const Argument* thisPtr1,
|
|
130
130
|
const Value* thisPtr2);
|
|
131
131
|
|
|
132
|
+
/// extract class name from the c++ function name, e.g., constructor/destructors
|
|
133
|
+
Set<std::string> extractClsNamesFromFunc(const Function *foo);
|
|
134
|
+
|
|
135
|
+
/// extract class names from template functions
|
|
136
|
+
Set<std::string> extractClsNamesFromTemplate(const std::string &oname);
|
|
137
|
+
|
|
138
|
+
/// class sources can be heap allocation
|
|
139
|
+
/// or functions where we can extract the class name (constructors/destructors or template functions)
|
|
140
|
+
bool isClsNameSource(const Value *val);
|
|
141
|
+
|
|
142
|
+
/// whether foo matches the mangler label
|
|
143
|
+
bool matchesLabel(const std::string &foo, const std::string &label);
|
|
144
|
+
|
|
145
|
+
/// whether foo is a cpp template function
|
|
146
|
+
bool isTemplateFunc(const Function *foo);
|
|
147
|
+
|
|
148
|
+
/// whether foo is a cpp dyncast function
|
|
149
|
+
bool isDynCast(const Function *foo);
|
|
150
|
+
|
|
151
|
+
/// whether foo is a cpp heap allocation (new)
|
|
152
|
+
bool isNewAlloc(const Function *foo);
|
|
153
|
+
|
|
154
|
+
/// extract class name from cpp dyncast function
|
|
155
|
+
std::string extractClsNameFromDynCast(const CallBase* callBase);
|
|
156
|
+
|
|
157
|
+
const Type *cppClsNameToType(const std::string &className);
|
|
158
|
+
|
|
159
|
+
std::string typeToClsName(const Type *ty);
|
|
160
|
+
|
|
161
|
+
|
|
132
162
|
/// Constants pertaining to CTir, for C and C++.
|
|
133
163
|
/// TODO: move helper functions here too?
|
|
134
164
|
namespace ctir
|
|
@@ -100,9 +100,11 @@ static inline Type* getPtrElementType(const PointerType* pty)
|
|
|
100
100
|
{
|
|
101
101
|
#if (LLVM_VERSION_MAJOR < 14)
|
|
102
102
|
return pty->getPointerElementType();
|
|
103
|
-
#
|
|
103
|
+
#elif (LLVM_VERSION_MAJOR < 17)
|
|
104
104
|
assert(!pty->isOpaque() && "Opaque Pointer is used, please recompile the source adding '-Xclang -no-opaque-pointers'");
|
|
105
105
|
return pty->getNonOpaquePointerElementType();
|
|
106
|
+
#else
|
|
107
|
+
assert(false && "llvm version 17+ only support opaque pointers!");
|
|
106
108
|
#endif
|
|
107
109
|
}
|
|
108
110
|
|
|
@@ -47,12 +47,17 @@ public:
|
|
|
47
47
|
typedef ValueToValueSet ValueToSources;
|
|
48
48
|
typedef Map<const Value *, const Type *> ValueToType;
|
|
49
49
|
typedef std::pair<const Value *, bool> ValueBoolPair;
|
|
50
|
+
typedef Map<const Value *, Set<std::string>> ValueToClassNames;
|
|
51
|
+
typedef Map<const CallBase *, Set<const Function *>> AllocToClsNameSources;
|
|
50
52
|
|
|
51
53
|
|
|
52
54
|
private:
|
|
53
55
|
ValueToInferSites _valueToInferSites; // value inference site cache
|
|
54
56
|
ValueToType _valueToType; // value type cache
|
|
55
57
|
ValueToSources _valueToAllocs; // value allocations (stack, static, heap) cache
|
|
58
|
+
ValueToClassNames _thisPtrClassNames; // thisptr class name cache
|
|
59
|
+
ValueToSources _valueToAllocOrClsNameSources; // value alloc/clsname sources cache
|
|
60
|
+
AllocToClsNameSources _allocToClsNameSources; // alloc clsname sources cache
|
|
56
61
|
|
|
57
62
|
|
|
58
63
|
public:
|
|
@@ -62,24 +67,24 @@ public:
|
|
|
62
67
|
~ObjTypeInference() = default;
|
|
63
68
|
|
|
64
69
|
|
|
65
|
-
/// get or infer the type of
|
|
66
|
-
const Type *inferObjType(const Value *
|
|
70
|
+
/// get or infer the type of the object pointed by the value
|
|
71
|
+
const Type *inferObjType(const Value *var);
|
|
67
72
|
|
|
68
|
-
///
|
|
73
|
+
/// validate type inference
|
|
69
74
|
void validateTypeCheck(const CallBase *cs);
|
|
70
75
|
|
|
71
76
|
void typeSizeDiffTest(const PointerType *oPTy, const Type *iTy, const Value *val);
|
|
72
77
|
|
|
73
|
-
///
|
|
78
|
+
/// default type
|
|
74
79
|
const Type *defaultType(const Value *val);
|
|
75
80
|
|
|
76
|
-
///
|
|
81
|
+
/// pointer type
|
|
77
82
|
inline const Type *ptrType()
|
|
78
83
|
{
|
|
79
84
|
return PointerType::getUnqual(getLLVMCtx());
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
///
|
|
87
|
+
/// int8 type
|
|
83
88
|
inline const IntegerType *int8Type()
|
|
84
89
|
{
|
|
85
90
|
return Type::getInt8Ty(getLLVMCtx());
|
|
@@ -89,22 +94,35 @@ public:
|
|
|
89
94
|
|
|
90
95
|
private:
|
|
91
96
|
|
|
92
|
-
///
|
|
93
|
-
const Type *fwInferObjType(const Value *
|
|
97
|
+
/// forward infer the type of the object pointed by var
|
|
98
|
+
const Type *fwInferObjType(const Value *var);
|
|
94
99
|
|
|
95
|
-
///
|
|
96
|
-
Set<const Value
|
|
100
|
+
/// backward collect all possible allocation sites (stack, static, heap) of var
|
|
101
|
+
Set<const Value *>& bwfindAllocOfVar(const Value *var);
|
|
97
102
|
|
|
98
|
-
|
|
103
|
+
/// is allocation (stack, static, heap)
|
|
104
|
+
bool isAlloc(const SVF::Value *val);
|
|
99
105
|
|
|
100
106
|
public:
|
|
101
|
-
///
|
|
107
|
+
/// select the largest (conservative) type from all types
|
|
102
108
|
const Type *selectLargestSizedType(Set<const Type *> &objTys);
|
|
103
109
|
|
|
104
110
|
u32_t objTyToNumFields(const Type *objTy);
|
|
105
111
|
|
|
106
112
|
u32_t getArgPosInCall(const CallBase *callBase, const Value *arg);
|
|
107
113
|
|
|
114
|
+
public:
|
|
115
|
+
/// get or infer the class names of thisptr
|
|
116
|
+
Set<std::string> &inferThisPtrClsName(const Value *thisPtr);
|
|
117
|
+
|
|
118
|
+
protected:
|
|
119
|
+
|
|
120
|
+
/// find all possible allocations or
|
|
121
|
+
/// class name sources (e.g., constructors/destructors or template functions) starting from a value
|
|
122
|
+
Set<const Value *> &bwFindAllocOrClsNameSources(const Value *startValue);
|
|
123
|
+
|
|
124
|
+
/// forward find class name sources starting from an allocation
|
|
125
|
+
Set<const Function *> &fwFindClsNameSources(const CallBase *alloc);
|
|
108
126
|
};
|
|
109
127
|
}
|
|
110
128
|
#endif //SVF_OBJTYPEINFERENCE_H
|