svf-lib 1.0.1300 → 1.0.1302

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.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/SVF-linux/include/SVF-FE/BasicTypes.h +0 -219
  3. package/SVF-linux/include/SVF-FE/BreakConstantExpr.h +0 -94
  4. package/SVF-linux/include/SVF-FE/CHG.h +0 -334
  5. package/SVF-linux/include/SVF-FE/CHGBuilder.h +0 -73
  6. package/SVF-linux/include/SVF-FE/CPPUtil.h +0 -130
  7. package/SVF-linux/include/SVF-FE/CallGraphBuilder.h +0 -74
  8. package/SVF-linux/include/SVF-FE/CommonCHG.h +0 -49
  9. package/SVF-linux/include/SVF-FE/DCHG.h +0 -470
  10. package/SVF-linux/include/SVF-FE/DataFlowUtil.h +0 -190
  11. package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
  12. package/SVF-linux/include/SVF-FE/Graph2Json.h +0 -30
  13. package/SVF-linux/include/SVF-FE/ICFGBuilder.h +0 -106
  14. package/SVF-linux/include/SVF-FE/IRAnnotator.h +0 -323
  15. package/SVF-linux/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
  16. package/SVF-linux/include/SVF-FE/LLVMModule.h +0 -319
  17. package/SVF-linux/include/SVF-FE/LLVMUtil.h +0 -303
  18. package/SVF-linux/include/SVF-FE/LocMemModel.h +0 -35
  19. package/SVF-linux/include/SVF-FE/MemModelBuilder.h +0 -102
  20. package/SVF-linux/include/SVF-FE/PAGBuilder.h +0 -390
  21. package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +0 -412
  22. package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +0 -99
  23. package/SVF-linux/include/SVF-FE/SymbolTableInfo.h +0 -439
  24. package/SVF-osx/include/SVF-FE/BasicTypes.h +0 -219
  25. package/SVF-osx/include/SVF-FE/BreakConstantExpr.h +0 -94
  26. package/SVF-osx/include/SVF-FE/CHG.h +0 -334
  27. package/SVF-osx/include/SVF-FE/CHGBuilder.h +0 -73
  28. package/SVF-osx/include/SVF-FE/CPPUtil.h +0 -130
  29. package/SVF-osx/include/SVF-FE/CallGraphBuilder.h +0 -74
  30. package/SVF-osx/include/SVF-FE/CommonCHG.h +0 -49
  31. package/SVF-osx/include/SVF-FE/DCHG.h +0 -470
  32. package/SVF-osx/include/SVF-FE/DataFlowUtil.h +0 -190
  33. package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
  34. package/SVF-osx/include/SVF-FE/Graph2Json.h +0 -30
  35. package/SVF-osx/include/SVF-FE/ICFGBuilder.h +0 -106
  36. package/SVF-osx/include/SVF-FE/IRAnnotator.h +0 -323
  37. package/SVF-osx/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
  38. package/SVF-osx/include/SVF-FE/LLVMModule.h +0 -319
  39. package/SVF-osx/include/SVF-FE/LLVMUtil.h +0 -303
  40. package/SVF-osx/include/SVF-FE/LocMemModel.h +0 -35
  41. package/SVF-osx/include/SVF-FE/MemModelBuilder.h +0 -102
  42. package/SVF-osx/include/SVF-FE/PAGBuilder.h +0 -390
  43. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +0 -412
  44. package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +0 -99
  45. package/SVF-osx/include/SVF-FE/SymbolTableInfo.h +0 -439
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1300",
3
+ "version": "1.0.1302",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,219 +0,0 @@
1
- #ifndef SVF_FE_BASIC_TYPES_H
2
- #define SVF_FE_BASIC_TYPES_H
3
-
4
- #include "SVF-FE/GEPTypeBridgeIterator.h"
5
-
6
- #include <llvm/Pass.h>
7
-
8
- #include <llvm/IR/Instructions.h>
9
- #include <llvm/IR/IntrinsicInst.h>
10
- #include <llvm/IR/LLVMContext.h>
11
- #include <llvm/IR/Metadata.h>
12
- #include <llvm/IR/DataLayout.h>
13
- #include <llvm/IR/IRBuilder.h>
14
- #include <llvm/IR/DebugInfo.h>
15
- #include <llvm/IR/InstIterator.h>
16
- #include <llvm/IR/GetElementPtrTypeIterator.h>
17
- #include <llvm/IR/DerivedTypes.h>
18
- #include <llvm/IR/Statepoint.h>
19
-
20
- #include <llvm/Analysis/MemoryLocation.h>
21
- #include <llvm/Analysis/DominanceFrontier.h>
22
- #include <llvm/Analysis/PostDominators.h>
23
- #include <llvm/Analysis/ScalarEvolution.h>
24
- #include <llvm/Analysis/ScalarEvolutionExpressions.h>
25
-
26
- #include <llvm/Transforms/Utils/UnifyFunctionExitNodes.h>
27
-
28
- #include <llvm/Support/SourceMgr.h>
29
-
30
- #include <llvm/Bitcode/BitcodeWriter.h> // for WriteBitcodeToFile
31
- #include <llvm/Bitcode/BitcodeReader.h> /// for isBitcode
32
- #include <llvm/IRReader/IRReader.h> // IR reader for bit file
33
- #include <llvm/IR/InstVisitor.h> // for instruction visitor
34
- #include <llvm/IR/InstIterator.h> // for inst iteration
35
-
36
- #include <llvm/Analysis/LoopInfo.h>
37
-
38
- namespace SVF
39
- {
40
-
41
- typedef llvm::LLVMContext LLVMContext;
42
- typedef llvm::GlobalObject GlobalObject;
43
- typedef llvm::Use Use;
44
- typedef llvm::ModulePass ModulePass;
45
- typedef llvm::IRBuilder<> IRBuilder;
46
- #if LLVM_VERSION_MAJOR >= 12
47
- typedef llvm::UnifyFunctionExitNodesLegacyPass UnifyFunctionExitNodes;
48
- #else
49
- typedef llvm::UnifyFunctionExitNodes UnifyFunctionExitNodes;
50
- #endif
51
-
52
- typedef llvm::Module Module;
53
-
54
- typedef llvm::SMDiagnostic SMDiagnostic;
55
-
56
- typedef llvm::BlockAddress BlockAddress;
57
-
58
- // LLVM Metadata
59
- typedef llvm::MDString MDString;
60
- typedef llvm::MetadataAsValue MetadataAsValue;
61
-
62
- // LLVM data layout
63
- typedef llvm::StructLayout StructLayout;
64
- typedef llvm::ConstantStruct ConstantStruct;
65
- typedef llvm::MemoryLocation MemoryLocation;
66
- typedef llvm::DataLayout DataLayout;
67
-
68
- // LLVM Aliases and constants
69
- typedef llvm::ConstantAggregate ConstantAggregate;
70
- typedef llvm::ConstantAggregateZero ConstantAggregateZero;
71
- typedef llvm::ConstantDataSequential ConstantDataSequential;
72
- typedef llvm::ConstantExpr ConstantExpr;
73
- typedef llvm::ConstantDataArray ConstantDataArray;
74
- typedef llvm::ConstantData ConstantData;
75
- typedef llvm::ConstantArray ConstantArray;
76
- typedef llvm::Constant Constant;
77
-
78
- /// LLVM Dominators
79
- typedef llvm::DominatorTree DominatorTree;
80
- typedef llvm::DomTreeNode DomTreeNode;
81
- typedef llvm::DominanceFrontier DominanceFrontier;
82
- typedef llvm::PostDominatorTree PostDominatorTree;
83
- typedef llvm::DominanceFrontierBase<llvm::BasicBlock, false> DominanceFrontierBase;
84
-
85
- /// LLVM Loop
86
- typedef llvm::Loop Loop;
87
- typedef llvm::LoopInfo LoopInfo;
88
- typedef llvm::User User;
89
-
90
- // LLVM Instructions
91
- typedef llvm::CallInst CallInst;
92
- typedef llvm::StoreInst StoreInst;
93
- typedef llvm::LoadInst LoadInst;
94
- typedef llvm::AllocaInst AllocaInst;
95
- typedef llvm::AtomicCmpXchgInst AtomicCmpXchgInst;
96
- typedef llvm::AtomicRMWInst AtomicRMWInst;
97
- typedef llvm::BitCastInst BitCastInst;
98
- typedef llvm::BranchInst BranchInst;
99
- typedef llvm::SwitchInst SwitchInst;
100
- typedef llvm::CallBrInst CallBrInst;
101
- typedef llvm::ReturnInst ReturnInst;
102
- typedef llvm::CastInst CastInst;
103
- typedef llvm::CmpInst CmpInst;
104
- typedef llvm::ExtractValueInst ExtractValueInst;
105
- typedef llvm::ExtractElementInst ExtractElementInst;
106
- typedef llvm::GetElementPtrInst GetElementPtrInst;
107
- typedef llvm::InvokeInst InvokeInst;
108
- typedef llvm::ShuffleVectorInst ShuffleVectorInst;
109
- typedef llvm::PHINode PHINode;
110
- typedef llvm::IntToPtrInst IntToPtrInst;
111
- typedef llvm::InsertValueInst InsertValueInst;
112
- typedef llvm::FenceInst FenceInst;
113
- typedef llvm::FreezeInst FreezeInst;
114
- typedef llvm::UnreachableInst UnreachableInst;
115
- typedef llvm::InsertElementInst InsertElementInst;
116
- typedef llvm::LandingPadInst LandingPadInst;
117
- typedef llvm::ResumeInst ResumeInst;
118
- typedef llvm::SelectInst SelectInst;
119
- typedef llvm::VAArgInst VAArgInst;
120
- typedef llvm::VACopyInst VACopyInst;
121
- typedef llvm::VAEndInst VAEndInst;
122
- typedef llvm::VAStartInst VAStartInst;
123
- typedef llvm::BinaryOperator BinaryOperator;
124
- typedef llvm::UnaryOperator UnaryOperator;
125
- typedef llvm::UndefValue UndefValue;
126
-
127
- // LLVM Intrinsic Instructions
128
- #if LLVM_VERSION_MAJOR >= 13
129
- typedef llvm::IntrinsicInst IntrinsicInst;
130
- typedef llvm::DbgInfoIntrinsic DbgInfoIntrinsic;
131
- typedef llvm::DbgVariableIntrinsic DbgVariableIntrinsic;
132
- typedef llvm::DbgDeclareInst DbgDeclareInst;
133
- typedef llvm::DbgAddrIntrinsic DbgAddrIntrinsic;
134
- typedef llvm::DbgValueInst DbgValueInst;
135
- typedef llvm::DbgLabelInst DbgLabelInst;
136
- typedef llvm::VPIntrinsic VPIntrinsic;
137
- typedef llvm::ConstrainedFPIntrinsic ConstrainedFPIntrinsic;
138
- typedef llvm::ConstrainedFPCmpIntrinsic ConstrainedFPCmpIntrinsic;
139
- typedef llvm::MinMaxIntrinsic MinMaxIntrinsic;
140
- typedef llvm::BinaryOpIntrinsic BinaryOpIntrinsic;
141
- typedef llvm::WithOverflowInst WithOverflowInst;
142
- typedef llvm::SaturatingInst SaturatingInst;
143
- typedef llvm::AtomicMemIntrinsic AtomicMemIntrinsic;
144
- typedef llvm::AtomicMemSetInst AtomicMemSetInst;
145
- typedef llvm::AtomicMemTransferInst AtomicMemTransferInst;
146
- typedef llvm::AtomicMemCpyInst AtomicMemCpyInst;
147
- typedef llvm::AtomicMemMoveInst AtomicMemMoveInst;
148
- typedef llvm::MemIntrinsic MemIntrinsic;
149
- typedef llvm::MemSetInst MemSetInst;
150
- typedef llvm::MemTransferInst MemTransferInst;
151
- typedef llvm::MemCpyInst MemCpyInst;
152
- typedef llvm::MemMoveInst MemMoveInst;
153
- typedef llvm::MemCpyInlineInst MemCpyInlineInst;
154
- typedef llvm::AnyMemIntrinsic AnyMemIntrinsic;
155
- typedef llvm::AnyMemSetInst AnyMemSetInst;
156
- typedef llvm::AnyMemTransferInst AnyMemTransferInst;
157
- typedef llvm::AnyMemCpyInst AnyMemCpyInst;
158
- typedef llvm::AnyMemMoveInst AnyMemMoveInst;
159
- typedef llvm::VAStartInst VAStartInst;
160
- typedef llvm::VAEndInst VAEndInst;
161
- typedef llvm::VACopyInst VACopyInst;
162
- typedef llvm::InstrProfIncrementInst InstrProfIncrementInst;
163
- typedef llvm::InstrProfIncrementInstStep InstrProfIncrementInstStep;
164
- typedef llvm::InstrProfValueProfileInst InstrProfValueProfileInst;
165
- typedef llvm::PseudoProbeInst PseudoProbeInst;
166
- typedef llvm::NoAliasScopeDeclInst NoAliasScopeDeclInst;
167
- typedef llvm::GCStatepointInst GCStatepointInst;
168
- typedef llvm::GCProjectionInst GCProjectionInst;
169
- typedef llvm::GCRelocateInst GCRelocateInst;
170
- typedef llvm::GCResultInst GCResultInst;
171
- typedef llvm::AssumeInst AssumeInst;
172
- #endif
173
-
174
- // LLVM Debug Information
175
- typedef llvm::DIType DIType;
176
- typedef llvm::DICompositeType DICompositeType;
177
- typedef llvm::DIDerivedType DIDerivedType;
178
- typedef llvm::DebugInfoFinder DebugInfoFinder;
179
- typedef llvm::DISubroutineType DISubroutineType;
180
- typedef llvm::DIBasicType DIBasicType;
181
- typedef llvm::DISubrange DISubrange;
182
- typedef llvm::DINode DINode;
183
- typedef llvm::DINodeArray DINodeArray;
184
- typedef llvm::DITypeRefArray DITypeRefArray;
185
- namespace dwarf = llvm::dwarf;
186
-
187
- // Iterators.
188
- typedef llvm::inst_iterator inst_iterator;
189
- typedef llvm::const_inst_iterator const_inst_iterator;
190
- typedef llvm::gep_type_iterator gep_type_iterator;
191
- typedef llvm::bridge_gep_iterator bridge_gep_iterator;
192
- typedef llvm::const_inst_iterator const_inst_iterator;
193
- typedef llvm::const_pred_iterator const_pred_iterator;
194
-
195
- // LLVM Scalar Evolution.
196
- typedef llvm::ScalarEvolutionWrapperPass ScalarEvolutionWrapperPass;
197
- typedef llvm::SCEVAddRecExpr SCEVAddRecExpr;
198
- typedef llvm::SCEVConstant SCEVConstant;
199
- typedef llvm::ScalarEvolution ScalarEvolution;
200
- typedef llvm::SCEV SCEV;
201
-
202
- /// LLVM outputs
203
- typedef llvm::raw_fd_ostream raw_fd_ostream;
204
-
205
- // LLVM Types.
206
- typedef llvm::VectorType VectorType;
207
- #if (LLVM_VERSION_MAJOR >= 9)
208
- typedef llvm::FunctionCallee FunctionCallee;
209
- #endif
210
-
211
- /// LLVM Iterators
212
- #if LLVM_VERSION_MAJOR >= 11
213
- typedef llvm::const_succ_iterator succ_const_iterator;
214
- #else
215
- typedef llvm::succ_const_iterator succ_const_iterator;
216
- #endif
217
- } // End namespace SVF
218
-
219
- #endif // SVF_FE_BASIC_TYPES_H
@@ -1,94 +0,0 @@
1
- //===- BreakConstantGEPs.h - Change constant GEPs into GEP instructions --- --//
2
- //
3
- // The SAFECode Compiler
4
- //
5
- // This file was developed by the LLVM research group and is distributed under
6
- // the University of Illinois Open Source License. See LICENSE.TXT for details.
7
- //
8
- //===----------------------------------------------------------------------===//
9
- //
10
- // This pass changes all GEP constant expressions into GEP instructions. This
11
- // permits the rest of SAFECode to put run-time checks on them if necessary.
12
- //
13
- //===----------------------------------------------------------------------===//
14
-
15
- #ifndef BREAKCONSTANTGEPS_H
16
- #define BREAKCONSTANTGEPS_H
17
-
18
- #include "Util/BasicTypes.h"
19
-
20
- namespace SVF
21
- {
22
-
23
- //
24
- // Pass: BreakConstantGEPs
25
- //
26
- // Description:
27
- // This pass modifies a function so that it uses GEP instructions instead of
28
- // GEP constant expressions.
29
- //
30
- class BreakConstantGEPs : public ModulePass
31
- {
32
- private:
33
- // Private methods
34
-
35
- // Private variables
36
-
37
- public:
38
- static char ID;
39
- BreakConstantGEPs() : ModulePass(ID) {}
40
- llvm::StringRef getPassName() const
41
- {
42
- return "Remove Constant GEP Expressions";
43
- }
44
- virtual bool runOnModule (Module & M);
45
- };
46
-
47
-
48
- //
49
- // Pass: MergeFunctionRets
50
- //
51
- // Description:
52
- // This pass modifies a function so that each function only have one unified exit basic block
53
- //
54
- class MergeFunctionRets : public ModulePass
55
- {
56
- private:
57
- // Private methods
58
-
59
- // Private variables
60
-
61
- public:
62
- static char ID;
63
- MergeFunctionRets() : ModulePass(ID) {}
64
- llvm::StringRef getPassName() const
65
- {
66
- return "unify function exit into one dummy exit basic block";
67
- }
68
- virtual bool runOnModule (Module & M)
69
- {
70
- UnifyFunctionExit(M);
71
- return true;
72
- }
73
- inline void UnifyFunctionExit(Module& module)
74
- {
75
- for (Module::const_iterator iter = module.begin(), eiter = module.end();
76
- iter != eiter; ++iter)
77
- {
78
- const Function& fun = *iter;
79
- if(fun.isDeclaration())
80
- continue;
81
- getUnifyExit(fun)->runOnFunction(const_cast<Function&>(fun));
82
- }
83
- }
84
- /// Get Unified Exit basic block node
85
- inline UnifyFunctionExitNodes* getUnifyExit(const Function& fn)
86
- {
87
- assert(!fn.isDeclaration() && "external function does not have DF");
88
- return &getAnalysis<UnifyFunctionExitNodes>(const_cast<Function&>(fn));
89
- }
90
- };
91
-
92
- } // End namespace SVF
93
-
94
- #endif
@@ -1,334 +0,0 @@
1
- //===----- CHG.h -- Base class of pointer analyses ---------------------------//
2
- //
3
- // SVF: Static Value-Flow Analysis
4
- //
5
- // Copyright (C) <2013-2017> <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 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 General Public License for more details.
17
-
18
- // You should have received a copy of the GNU General Public License
19
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
- //
21
- //===----------------------------------------------------------------------===//
22
-
23
- /*
24
- * CHG.h (previously CHA.h)
25
- *
26
- * Created on: Apr 13, 2016
27
- * Author: Xiaokang Fan
28
- */
29
-
30
- #ifndef CHA_H_
31
- #define CHA_H_
32
-
33
- #include "Util/SVFModule.h"
34
- #include "SVF-FE/CommonCHG.h"
35
- #include "Graphs/GenericGraph.h"
36
- #include "Util/WorkList.h"
37
-
38
- namespace SVF
39
- {
40
-
41
- class SVFModule;
42
- class CHNode;
43
-
44
- typedef GenericEdge<CHNode> GenericCHEdgeTy;
45
- class CHEdge: public GenericCHEdgeTy
46
- {
47
- public:
48
- typedef enum
49
- {
50
- INHERITANCE = 0x1, // inheritance relation
51
- INSTANTCE = 0x2 // template-instance relation
52
- } CHEDGETYPE;
53
-
54
- typedef GenericNode<CHNode,CHEdge>::GEdgeSetTy CHEdgeSetTy;
55
-
56
- CHEdge(CHNode *s, CHNode *d, CHEDGETYPE et, GEdgeFlag k = 0):
57
- GenericCHEdgeTy(s,d,k)
58
- {
59
- edgeType = et;
60
- }
61
-
62
- CHEDGETYPE getEdgeType() const
63
- {
64
- return edgeType;
65
- }
66
-
67
- private:
68
- CHEDGETYPE edgeType;
69
- };
70
-
71
- typedef GenericNode<CHNode,CHEdge> GenericCHNodeTy;
72
- class CHNode: public GenericCHNodeTy
73
- {
74
- public:
75
- typedef enum
76
- {
77
- PURE_ABSTRACT = 0x1, // pure virtual abstract class
78
- MULTI_INHERITANCE = 0x2, // multi inheritance class
79
- TEMPLATE = 0x04 // template class
80
- } CLASSATTR;
81
-
82
- typedef std::vector<const SVFFunction*> FuncVector;
83
-
84
- CHNode (const std::string name, NodeID i = 0, GNodeK k = 0):
85
- GenericCHNodeTy(i, k), vtable(nullptr), className(name), flags(0)
86
- {
87
- }
88
- ~CHNode()
89
- {
90
- }
91
- std::string getName() const
92
- {
93
- return className;
94
- }
95
- /// Flags
96
- //@{
97
- inline void setFlag(CLASSATTR mask)
98
- {
99
- flags |= mask;
100
- }
101
- inline bool hasFlag(CLASSATTR mask) const
102
- {
103
- return (flags & mask) == mask;
104
- }
105
- //@}
106
-
107
- /// Attribute
108
- //@{
109
- inline void setPureAbstract()
110
- {
111
- setFlag(PURE_ABSTRACT);
112
- }
113
- inline void setMultiInheritance()
114
- {
115
- setFlag(MULTI_INHERITANCE);
116
- }
117
- inline void setTemplate()
118
- {
119
- setFlag(TEMPLATE);
120
- }
121
- inline bool isPureAbstract() const
122
- {
123
- return hasFlag(PURE_ABSTRACT);
124
- }
125
- inline bool isMultiInheritance() const
126
- {
127
- return hasFlag(MULTI_INHERITANCE);
128
- }
129
- inline bool isTemplate() const
130
- {
131
- return hasFlag(TEMPLATE);
132
- }
133
- //@}
134
-
135
- void addVirtualFunctionVector(FuncVector vfuncvec)
136
- {
137
- virtualFunctionVectors.push_back(vfuncvec);
138
- }
139
- const std::vector<FuncVector> &getVirtualFunctionVectors() const
140
- {
141
- return virtualFunctionVectors;
142
- }
143
- void getVirtualFunctions(u32_t idx, FuncVector &virtualFunctions) const;
144
-
145
- const GlobalValue *getVTable() const
146
- {
147
- return vtable;
148
- }
149
-
150
- void setVTable(const GlobalValue *vtbl)
151
- {
152
- vtable = vtbl;
153
- }
154
-
155
- private:
156
- const GlobalValue* vtable;
157
- std::string className;
158
- size_t flags;
159
- /*
160
- * virtual functions inherited from different classes are separately stored
161
- * to model different vtables inherited from different fathers.
162
- *
163
- * Example:
164
- * class C: public A, public B
165
- * vtableC = {Af1, Af2, ..., inttoptr, Bg1, Bg2, ...} ("inttoptr"
166
- * instruction works as the delimiter for separating virtual functions
167
- * inherited from different classes)
168
- *
169
- * virtualFunctionVectors = {{Af1, Af2, ...}, {Bg1, Bg2, ...}}
170
- */
171
- std::vector<FuncVector> virtualFunctionVectors;
172
- };
173
-
174
- /// class hierarchy graph
175
- typedef GenericGraph<CHNode,CHEdge> GenericCHGraphTy;
176
- class CHGraph: public CommonCHGraph, public GenericCHGraphTy
177
- {
178
- public:
179
- typedef Set<const CHNode*> CHNodeSetTy;
180
- typedef FIFOWorkList<const CHNode*> WorkList;
181
- typedef Map<std::string, CHNodeSetTy> NameToCHNodesMap;
182
- typedef Map<CallSite, CHNodeSetTy> CallSiteToCHNodesMap;
183
- typedef Map<CallSite, VTableSet> CallSiteToVTableSetMap;
184
- typedef Map<CallSite, VFunSet> CallSiteToVFunSetMap;
185
-
186
- typedef enum
187
- {
188
- CONSTRUCTOR = 0x1, // connect node based on constructor
189
- DESTRUCTOR = 0x2 // connect node based on destructor
190
- } RELATIONTYPE;
191
-
192
- CHGraph(SVFModule* svfModule): svfMod(svfModule), classNum(0), vfID(0), buildingCHGTime(0)
193
- {
194
- this->kind = Standard;
195
- }
196
- ~CHGraph() override = default;
197
-
198
- void buildCHG();
199
- void buildInternalMaps();
200
- void buildCHGNodes(const GlobalValue *V);
201
- void buildCHGNodes(const SVFFunction* F);
202
- void buildCHGEdges(const SVFFunction* F);
203
- void connectInheritEdgeViaCall(const SVFFunction* caller, CallSite cs);
204
- void connectInheritEdgeViaStore(const SVFFunction* caller, const StoreInst* store);
205
- void addEdge(const std::string className,
206
- const std::string baseClassName,
207
- CHEdge::CHEDGETYPE edgeType);
208
- CHNode *getNode(const std::string name) const;
209
- CHNode *createNode(const std::string name);
210
- void buildClassNameToAncestorsDescendantsMap();
211
- void buildVirtualFunctionToIDMap();
212
- void buildCSToCHAVtblsAndVfnsMap();
213
- void readInheritanceMetadataFromModule(const Module &M);
214
- void analyzeVTables(const Module &M);
215
- const CHGraph::CHNodeSetTy& getInstancesAndDescendants(const std::string className);
216
- const CHNodeSetTy& getCSClasses(CallSite cs);
217
- void getVFnsFromVtbls(CallSite cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
218
- void dump(const std::string& filename);
219
- void view();
220
- void printCH();
221
-
222
- inline s32_t getVirtualFunctionID(const SVFFunction* vfn) const
223
- {
224
- Map<const SVFFunction*, s32_t>::const_iterator it =
225
- virtualFunctionToIDMap.find(vfn);
226
- if (it != virtualFunctionToIDMap.end())
227
- return it->second;
228
- else
229
- return -1;
230
- }
231
- inline const SVFFunction* getVirtualFunctionBasedonID(s32_t id) const
232
- {
233
- Map<const SVFFunction*, s32_t>::const_iterator it, eit;
234
- for (it = virtualFunctionToIDMap.begin(), eit =
235
- virtualFunctionToIDMap.end(); it != eit; ++it)
236
- {
237
- if (it->second == id)
238
- return it->first;
239
- }
240
- return nullptr;
241
- }
242
-
243
- inline void addInstances(const std::string templateName, CHNode* node)
244
- {
245
- NameToCHNodesMap::iterator it = templateNameToInstancesMap.find(
246
- templateName);
247
- if (it != templateNameToInstancesMap.end())
248
- it->second.insert(node);
249
- else
250
- templateNameToInstancesMap[templateName].insert(node);
251
- }
252
- inline const CHNodeSetTy &getDescendants(const std::string className)
253
- {
254
- return classNameToDescendantsMap[className];
255
- }
256
- inline const CHNodeSetTy &getInstances(const std::string className)
257
- {
258
- return templateNameToInstancesMap[className];
259
- }
260
-
261
- inline bool csHasVtblsBasedonCHA(CallSite cs) override
262
- {
263
- CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
264
- return it != csToCHAVtblsMap.end();
265
- }
266
- inline bool csHasVFnsBasedonCHA(CallSite cs) override
267
- {
268
- CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
269
- return it != csToCHAVFnsMap.end();
270
- }
271
- inline const VTableSet &getCSVtblsBasedonCHA(CallSite cs) override
272
- {
273
- CallSiteToVTableSetMap::const_iterator it = csToCHAVtblsMap.find(cs);
274
- assert(it != csToCHAVtblsMap.end() && "cs does not have vtabls based on CHA.");
275
- return it->second;
276
- }
277
- inline const VFunSet &getCSVFsBasedonCHA(CallSite cs) override
278
- {
279
- CallSiteToVFunSetMap::const_iterator it = csToCHAVFnsMap.find(cs);
280
- assert(it != csToCHAVFnsMap.end() && "cs does not have vfns based on CHA.");
281
- return it->second;
282
- }
283
-
284
- static inline bool classof(const CommonCHGraph *chg)
285
- {
286
- return chg->getKind() == Standard;
287
- }
288
-
289
- protected:
290
- void addFuncToFuncVector(CHNode::FuncVector &v, const SVFFunction *f);
291
-
292
- private:
293
- SVFModule* svfMod;
294
- u32_t classNum;
295
- s32_t vfID;
296
- double buildingCHGTime;
297
- Map<std::string, CHNode *> classNameToNodeMap;
298
- NameToCHNodesMap classNameToDescendantsMap;
299
- NameToCHNodesMap classNameToAncestorsMap;
300
- NameToCHNodesMap classNameToInstAndDescsMap;
301
- NameToCHNodesMap templateNameToInstancesMap;
302
- CallSiteToCHNodesMap csToClassesMap;
303
-
304
- Map<const SVFFunction*, s32_t> virtualFunctionToIDMap;
305
- CallSiteToVTableSetMap csToCHAVtblsMap;
306
- CallSiteToVFunSetMap csToCHAVFnsMap;
307
- };
308
-
309
- } // End namespace SVF
310
-
311
- namespace llvm
312
- {
313
- /* !
314
- * GraphTraits specializations for generic graph algorithms.
315
- * Provide graph traits for traversing from a constraint node using standard graph traversals.
316
- */
317
- template<> struct GraphTraits<SVF::CHNode*> : public GraphTraits<SVF::GenericNode<SVF::CHNode,SVF::CHEdge>* >
318
- {
319
- };
320
-
321
- /// Inverse GraphTraits specializations for call graph node, it is used for inverse traversal.
322
- template<>
323
- struct GraphTraits<Inverse<SVF::CHNode*> > : public GraphTraits<Inverse<SVF::GenericNode<SVF::CHNode,SVF::CHEdge>* > >
324
- {
325
- };
326
-
327
- template<> struct GraphTraits<SVF::CHGraph*> : public GraphTraits<SVF::GenericGraph<SVF::CHNode,SVF::CHEdge>* >
328
- {
329
- typedef SVF::CHNode *NodeRef;
330
- };
331
-
332
- } // End namespace llvm
333
-
334
- #endif /* CHA_H_ */