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 friend class GraphDBClient;
46
47public:
48 typedef enum
49 {
50 FUNCTION_OBJ = 0x1, // object is a function
51 GLOBVAR_OBJ = 0x2, // object is a global variable
52 STATIC_OBJ = 0x4, // object is a static variable allocated before main
53 STACK_OBJ = 0x8, // object is a stack variable
54 HEAP_OBJ = 0x10, // object is a heap variable
55 VAR_STRUCT_OBJ = 0x20, // object contains struct
56 VAR_ARRAY_OBJ = 0x40, // object contains array
57 CONST_STRUCT_OBJ = 0x80, // constant struct
58 CONST_ARRAY_OBJ = 0x100, // constant array
59 CONST_GLOBAL_OBJ = 0x200, // global constant object
60 CONST_DATA = 0x400, // constant object str e.g. 5, 10, 1.0
61 } MEMTYPE;
62
63private:
65 const SVFType* type;
74
77
78 inline void resetTypeForHeapStaticObj(const SVFType* t)
79 {
80 assert((isStaticObj() || isHeap()) && "can only reset the inferred type for heap and static objects!");
81 type = t;
82 }
83public:
84
86 ObjTypeInfo(const SVFType* t, u32_t max) : type(t), flags(0), maxOffsetLimit(max), elemNum(max)
87 {
88 assert(t && "no type information for this object?");
89 }
90
92 virtual ~ObjTypeInfo()
93 {
94 }
95
97 inline const SVFType* getType() const
98 {
99 return type;
100 }
101
104 {
105 return maxOffsetLimit;
106 }
107
110 {
112 }
113
116 {
117 elemNum = num;
119 }
120
122 inline u32_t getNumOfElements() const
123 {
124 return elemNum;
125 }
126
128 inline u32_t getByteSizeOfObj() const
129 {
130 assert(isConstantByteSize() && "This Obj's byte size is not constant.");
131 return byteSize;
132 }
133
135 inline void setByteSizeOfObj(u32_t size)
136 {
137 byteSize = size;
138 }
139
141 inline bool isConstantByteSize() const
142 {
143 return byteSize != 0;
144 }
145
147
148 inline void setFlag(MEMTYPE mask)
149 {
150 flags |= mask;
151 }
152 inline u32_t getFlag() const
153 {
154 return flags;
155 }
156 inline bool hasFlag(MEMTYPE mask)
157 {
158 return (flags & mask) == mask;
159 }
161
163
164 inline bool isFunction()
165 {
166 return hasFlag(FUNCTION_OBJ);
167 }
168 inline bool isGlobalObj()
169 {
170 return hasFlag(GLOBVAR_OBJ);
171 }
172 inline bool isStaticObj()
173 {
174 return hasFlag(STATIC_OBJ);
175 }
176 inline bool isStack()
177 {
178 return hasFlag(STACK_OBJ);
179 }
180 inline bool isHeap()
181 {
182 return hasFlag(HEAP_OBJ);
183 }
185
188
189 inline bool isVarStruct()
190 {
191 return hasFlag(VAR_STRUCT_OBJ);
192 }
193 inline bool isConstantStruct()
194 {
196 }
197 inline bool isStruct()
198 {
200 }
201 inline bool isVarArray()
202 {
203 return hasFlag(VAR_ARRAY_OBJ);
204 }
205 inline bool isConstantArray()
206 {
207 return hasFlag(CONST_ARRAY_OBJ);
208 }
209 inline bool isArray()
210 {
212 }
214 {
216 }
218 {
219 return hasFlag(CONST_DATA);
220 }
222};
223
224
225} // End namespace SVF
226
227#endif /* INCLUDE_SVFIR_OBJTYPEINFO_H_ */
const SVFType * type
SVF type.
Definition ObjTypeInfo.h:65
bool isConstantStruct()
u32_t elemNum
Size of the object or number of elements.
Definition ObjTypeInfo.h:73
void resetTypeForHeapStaticObj(const SVFType *t)
Definition ObjTypeInfo.h:78
bool isConstDataOrAggData()
u32_t getMaxFieldOffsetLimit()
Get max field offset limit.
u32_t getFlag() const
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:97
bool isConstantByteSize() const
Check if byte size is a const value.
void setMaxFieldOffsetLimit(u32_t limit)
Get max field offset limit.
friend class GraphDBClient
Definition ObjTypeInfo.h:45
u32_t byteSize
Byte size of object.
Definition ObjTypeInfo.h:76
u32_t flags
Type flags.
Definition ObjTypeInfo.h:67
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:86
virtual ~ObjTypeInfo()
Destructor.
Definition ObjTypeInfo.h:92
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