Static Value-Flow Analysis
Loading...
Searching...
No Matches
ObjTypeInfo.h
Go to the documentation of this file.
1//===- ObjTypeInfo.h -- Object type information------------------------//
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 * ObjTypeInfo.h
25 *
26 * Created on: Nov 11, 2013
27 * Author: Yulei Sui
28 */
29
30#ifndef INCLUDE_SVFIR_OBJTYPEINFO_H_
31#define INCLUDE_SVFIR_OBJTYPEINFO_H_
32
33
34#include "Util/SVFUtil.h"
36namespace SVF
37{
38
43{
44 friend class SymbolTableBuilder;
45
46public:
47 typedef enum
48 {
49 FUNCTION_OBJ = 0x1, // object is a function
50 GLOBVAR_OBJ = 0x2, // object is a global variable
51 STATIC_OBJ = 0x4, // object is a static variable allocated before main
52 STACK_OBJ = 0x8, // object is a stack variable
53 HEAP_OBJ = 0x10, // object is a heap variable
54 VAR_STRUCT_OBJ = 0x20, // object contains struct
55 VAR_ARRAY_OBJ = 0x40, // object contains array
56 CONST_STRUCT_OBJ = 0x80, // constant struct
57 CONST_ARRAY_OBJ = 0x100, // constant array
58 CONST_GLOBAL_OBJ = 0x200, // global constant object
59 CONST_DATA = 0x400, // constant object str e.g. 5, 10, 1.0
60 } MEMTYPE;
61
62private:
64 const SVFType* type;
73
76
77 inline void resetTypeForHeapStaticObj(const SVFType* t)
78 {
79 assert((isStaticObj() || isHeap()) && "can only reset the inferred type for heap and static objects!");
80 type = t;
81 }
82public:
83
85 ObjTypeInfo(const SVFType* t, u32_t max) : type(t), flags(0), maxOffsetLimit(max), elemNum(max)
86 {
87 assert(t && "no type information for this object?");
88 }
89
91 virtual ~ObjTypeInfo()
92 {
93 }
94
96 inline const SVFType* getType() const
97 {
98 return type;
99 }
100
103 {
104 return maxOffsetLimit;
105 }
106
109 {
111 }
112
115 {
116 elemNum = num;
118 }
119
121 inline u32_t getNumOfElements() const
122 {
123 return elemNum;
124 }
125
127 inline u32_t getByteSizeOfObj() const
128 {
129 assert(isConstantByteSize() && "This Obj's byte size is not constant.");
130 return byteSize;
131 }
132
134 inline void setByteSizeOfObj(u32_t size)
135 {
136 byteSize = size;
137 }
138
140 inline bool isConstantByteSize() const
141 {
142 return byteSize != 0;
143 }
144
146
147 inline void setFlag(MEMTYPE mask)
148 {
149 flags |= mask;
150 }
151 inline bool hasFlag(MEMTYPE mask)
152 {
153 return (flags & mask) == mask;
154 }
156
158
159 inline bool isFunction()
160 {
161 return hasFlag(FUNCTION_OBJ);
162 }
163 inline bool isGlobalObj()
164 {
165 return hasFlag(GLOBVAR_OBJ);
166 }
167 inline bool isStaticObj()
168 {
169 return hasFlag(STATIC_OBJ);
170 }
171 inline bool isStack()
172 {
173 return hasFlag(STACK_OBJ);
174 }
175 inline bool isHeap()
176 {
177 return hasFlag(HEAP_OBJ);
178 }
180
183
184 inline bool isVarStruct()
185 {
186 return hasFlag(VAR_STRUCT_OBJ);
187 }
188 inline bool isConstantStruct()
189 {
191 }
192 inline bool isStruct()
193 {
195 }
196 inline bool isVarArray()
197 {
198 return hasFlag(VAR_ARRAY_OBJ);
199 }
200 inline bool isConstantArray()
201 {
202 return hasFlag(CONST_ARRAY_OBJ);
203 }
204 inline bool isArray()
205 {
207 }
209 {
211 }
213 {
214 return hasFlag(CONST_DATA);
215 }
217};
218
219
220} // End namespace SVF
221
222#endif /* INCLUDE_SVFIR_OBJTYPEINFO_H_ */
const SVFType * type
SVF type.
Definition ObjTypeInfo.h:64
bool isConstantStruct()
u32_t elemNum
Size of the object or number of elements.
Definition ObjTypeInfo.h:72
void resetTypeForHeapStaticObj(const SVFType *t)
Definition ObjTypeInfo.h:77
bool isConstDataOrAggData()
u32_t getMaxFieldOffsetLimit()
Get max field offset limit.
bool hasFlag(MEMTYPE mask)
bool isConstDataOrConstGlobal()
u32_t getNumOfElements() const
Get the number of elements of this object.
const SVFType * getType() const
Get LLVM type.
Definition ObjTypeInfo.h:96
bool isConstantByteSize() const
Check if byte size is a const value.
void setMaxFieldOffsetLimit(u32_t limit)
Get max field offset limit.
u32_t byteSize
Byte size of object.
Definition ObjTypeInfo.h:75
u32_t flags
Type flags.
Definition ObjTypeInfo.h:66
void setByteSizeOfObj(u32_t size)
Set the byte size of this object.
bool isFunction()
Object attributes.
ObjTypeInfo(const SVFType *t, u32_t max)
Constructors.
Definition ObjTypeInfo.h:85
virtual ~ObjTypeInfo()
Destructor.
Definition ObjTypeInfo.h:91
u32_t getByteSizeOfObj() const
Get the byte size of this object.
void setFlag(MEMTYPE mask)
Flag for this object type.
void setNumOfElements(u32_t num)
Set the number of elements of this object.
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
unsigned u32_t
Definition GeneralType.h:47