Static Value-Flow Analysis
SymbolTableBuilder.h
Go to the documentation of this file.
1 //===- SymbolTableBuilder.h -- Symbol Table builder-----------------------//
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  * SymbolTableBuilder.h
25  *
26  * Created on: Apr 28, 2014
27  * Author: Yulei
28  */
29 
30 #ifndef SymbolTableBuilder_H_
31 #define SymbolTableBuilder_H_
32 
33 #include "SVF-LLVM/LLVMModule.h"
34 #include "SVFIR/SymbolTableInfo.h"
35 
36 /*
37 * This class is to build SymbolTableInfo, MemObjs and ObjTypeInfo
38 */
39 namespace SVF
40 {
41 
42 class ObjTypeInference;
43 
45 {
46  friend class SVFIRBuilder;
47 private:
49 
50 public:
53  {
54  }
55 
57  void buildMemModel(SVFModule* svfModule);
58 
60  u32_t getNumOfElements(const Type* ety);
61 
62 
63 protected:
64 
66 
67  void collectSVFTypeInfo(const Value* val);
68 
69  void collectSym(const Value* val);
70 
71  void collectVal(const Value* val);
72 
73  void collectObj(const Value* val);
74 
75  void collectRet(const Function* val);
76 
77  void collectVararg(const Function* val);
79 
81  // @{
82  void handleGlobalCE(const GlobalVariable *G);
83  void handleGlobalInitializerCE(const Constant *C);
84  void handleCE(const Value* val);
85  // @}
86 
87 
89 
91  const Type* inferObjType(const Value *startValue);
92 
94 
97 
98 
100  ObjTypeInfo* createObjTypeInfo(const Value* val);
101 
103  void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value, const Type* ty);
105  void analyzeObjType(ObjTypeInfo* typeinfo, const Value* val);
107  u32_t analyzeHeapObjType(ObjTypeInfo* typeinfo, const Value* val);
109  void analyzeStaticObjType(ObjTypeInfo* typeinfo, const Value* val);
110 
113 
117 
119  StInfo* getOrAddSVFTypeInfo(const Type* T);
120 
121  MemObj* createBlkObj(SymID symId);
122 
124 };
125 
126 } // End namespace SVF
127 
128 #endif /* SymbolTableBuilder_H_ */
const Type * inferTypeOfHeapObjOrStaticObj(const Instruction *inst)
Get the reference type of heap/static object from an allocation site.
void handleGlobalInitializerCE(const Constant *C)
void collectRet(const Function *val)
SymbolTableInfo * symInfo
ObjTypeInfo * createObjTypeInfo(const Value *val)
Create an objectInfo based on LLVM value.
const Type * inferObjType(const Value *startValue)
Forward collect all possible infer sites starting from a value.
void collectSVFTypeInfo(const Value *val)
collect the syms
ObjTypeInference * getTypeInference()
MemObj * createBlkObj(SymID symId)
u32_t getNumOfFlattenElements(const Type *T)
Number of flattened elements of an array or struct.
u32_t getNumOfElements(const Type *ety)
Return size of this object based on LLVM value.
void handleGlobalCE(const GlobalVariable *G)
Handle constant expression.
MemObj * createConstantObj(SymID symId)
u32_t analyzeHeapObjType(ObjTypeInfo *typeinfo, const Value *val)
Analyse types of heap and static objects.
u32_t analyzeHeapAllocByteSize(const Value *val)
Analyze byte size of heap alloc function (e.g. malloc/calloc/...)
void collectObj(const Value *val)
void collectVal(const Value *val)
void handleCE(const Value *val)
void collectSym(const Value *val)
SymbolTableBuilder(SymbolTableInfo *si)
Constructor.
void collectVararg(const Function *val)
void initTypeInfo(ObjTypeInfo *typeinfo, const Value *value, const Type *ty)
Initialize TypeInfo based on LLVM Value.
void buildMemModel(SVFModule *svfModule)
Start building memory model.
void analyzeObjType(ObjTypeInfo *typeinfo, const Value *val)
Analyse types of all flattened fields of this object.
StInfo * getOrAddSVFTypeInfo(const Type *T)
Get a reference to StructInfo.
void analyzeStaticObjType(ObjTypeInfo *typeinfo, const Value *val)
Analyse types of heap and static objects.
for isBitcode
Definition: BasicTypes.h:68
llvm::GlobalVariable GlobalVariable
Definition: BasicTypes.h:130
llvm::Type Type
Definition: BasicTypes.h:83
llvm::Function Function
Definition: BasicTypes.h:85
llvm::Instruction Instruction
Definition: BasicTypes.h:87
llvm::Constant Constant
Definition: BasicTypes.h:124
llvm::Value Value
LLVM Basic classes.
Definition: BasicTypes.h:82
unsigned SymID
Definition: GeneralType.h:57
unsigned u32_t
Definition: GeneralType.h:46