Static Value-Flow Analysis
Loading...
Searching...
No Matches
ObjTypeInference.h
Go to the documentation of this file.
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
38namespace SVF
39{
41{
42
43public:
49 typedef std::pair<const Value *, bool> ValueBoolPair;
52
53
54private:
55 ValueToInferSites _valueToInferSites; // value inference site cache
56 ValueToType _valueToType; // value type cache
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 ObjToClsNameSources _objToClsNameSources; // alloc clsname sources cache
61
62
63public:
64
65 explicit ObjTypeInference() = default;
66
67 ~ObjTypeInference() = default;
68
69
71 const Type *inferObjType(const Value *var);
72
74 void validateTypeCheck(const CallBase *cs);
75
76 void typeSizeDiffTest(const PointerType *oPTy, const Type *iTy, const Value *val);
77
79 const Type *defaultType(const Value *val);
80
82 inline const Type *ptrType()
83 {
84 return PointerType::getUnqual(getLLVMCtx());
85 }
86
88 inline const IntegerType *int8Type()
89 {
90 return Type::getInt8Ty(getLLVMCtx());
91 }
92
94
95private:
96
98 const Type *fwInferObjType(const Value *var);
99
102
104 bool isAlloc(const SVF::Value *val);
105
106public:
109
111
113
114public:
117
118protected:
119
123
126};
127}
128#endif //SVF_OBJTYPEINFERENCE_H
Map< const Value *, ValueSet > ValueToValueSet
ValueToInferSites _valueToInferSites
~ObjTypeInference()=default
Map< const Value *, Set< const CallBase * > > ObjToClsNameSources
ValueToValueSet ValueToInferSites
ValueToSources _valueToAllocs
const Type * selectLargestSizedType(Set< const Type * > &objTys)
select the largest (conservative) type from all types
ValueToValueSet ValueToSources
Set< const Value * > & bwfindAllocOfVar(const Value *var)
backward collect all possible allocation sites (stack, static, heap) of var
Set< const Value * > ValueSet
u32_t objTyToNumFields(const Type *objTy)
bool isAlloc(const SVF::Value *val)
is allocation (stack, static, heap)
u32_t getArgPosInCall(const CallBase *callBase, const Value *arg)
Set< const Value * > & bwFindAllocOrClsNameSources(const Value *startValue)
ValueToClassNames _thisPtrClassNames
Set< std::string > & inferThisPtrClsName(const Value *thisPtr)
get or infer the class names of thisptr
void typeSizeDiffTest(const PointerType *oPTy, const Type *iTy, const Value *val)
const Type * fwInferObjType(const Value *var)
forward infer the type of the object pointed by var
Map< const Value *, const Type * > ValueToType
Map< const Value *, Set< std::string > > ValueToClassNames
const IntegerType * int8Type()
int8 type
const Type * ptrType()
pointer type
ObjTypeInference()=default
const Type * inferObjType(const Value *var)
get or infer the type of the object pointed by the value
const Type * defaultType(const Value *val)
default type
ObjToClsNameSources _objToClsNameSources
Set< const CallBase * > & fwFindClsNameSources(const Value *startValue)
forward find class name sources starting from an allocation
std::pair< const Value *, bool > ValueBoolPair
void validateTypeCheck(const CallBase *cs)
validate type inference
ValueToSources _valueToAllocOrClsNameSources
for isBitcode
Definition BasicTypes.h:68
llvm::Type Type
Definition BasicTypes.h:83
llvm::CallBase CallBase
Definition BasicTypes.h:146
llvm::IntegerType IntegerType
Definition BasicTypes.h:97
llvm::Value Value
LLVM Basic classes.
Definition BasicTypes.h:82
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
llvm::PointerType PointerType
Definition BasicTypes.h:96
unsigned u32_t
Definition GeneralType.h:46
llvm::LLVMContext LLVMContext
Definition BasicTypes.h:70