svf-lib 1.0.1375 → 1.0.1376

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 (147) hide show
  1. package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
  2. package/SVF-osx/svf/include/include/AbstractExecution/AbstractValue.h +79 -0
  3. package/SVF-osx/svf/include/include/AbstractExecution/AddressValue.h +210 -0
  4. package/SVF-osx/svf/include/include/AbstractExecution/ExeState.h +223 -0
  5. package/SVF-osx/svf/include/include/AbstractExecution/IntervalExeState.h +425 -0
  6. package/SVF-osx/svf/include/include/AbstractExecution/IntervalValue.h +868 -0
  7. package/SVF-osx/svf/include/include/AbstractExecution/NumericLiteral.h +406 -0
  8. package/SVF-osx/svf/include/include/AbstractExecution/RelExeState.h +225 -0
  9. package/SVF-osx/svf/include/include/AbstractExecution/RelationSolver.h +68 -0
  10. package/SVF-osx/svf/include/include/AbstractExecution/SVFIR2ItvExeState.h +186 -0
  11. package/SVF-osx/svf/include/include/AbstractExecution/WTO.h +845 -0
  12. package/SVF-osx/svf/include/include/CFL/CFGNormalizer.h +84 -0
  13. package/SVF-osx/svf/include/include/CFL/CFLAlias.h +176 -0
  14. package/SVF-osx/svf/include/include/CFL/CFLBase.h +115 -0
  15. package/SVF-osx/svf/include/include/CFL/CFLData.h +316 -0
  16. package/SVF-osx/svf/include/include/CFL/CFLDataBuilder.h +91 -0
  17. package/SVF-osx/svf/include/include/CFL/CFLGramGraphChecker.h +74 -0
  18. package/SVF-osx/svf/include/include/CFL/CFLGrammar.h +468 -0
  19. package/SVF-osx/svf/include/include/CFL/CFLGrammar.txt +15 -0
  20. package/SVF-osx/svf/include/include/CFL/CFLGraphBuilder.h +193 -0
  21. package/SVF-osx/svf/include/include/CFL/CFLSolver.h +136 -0
  22. package/SVF-osx/svf/include/include/CFL/CFLStat.h +67 -0
  23. package/SVF-osx/svf/include/include/CFL/CFLVF.h +65 -0
  24. package/SVF-osx/svf/include/include/CFL/GrammarBuilder.h +100 -0
  25. package/SVF-osx/svf/include/include/CFL/PEGGrammar.txt +11 -0
  26. package/SVF-osx/svf/include/include/CFL/VFG.txt +7 -0
  27. package/SVF-osx/svf/include/include/DDA/ContextDDA.h +230 -0
  28. package/SVF-osx/svf/include/include/DDA/DDAClient.h +168 -0
  29. package/SVF-osx/svf/include/include/DDA/DDAPass.h +99 -0
  30. package/SVF-osx/svf/include/include/DDA/DDAStat.h +138 -0
  31. package/SVF-osx/svf/include/include/DDA/DDAVFSolver.h +789 -0
  32. package/SVF-osx/svf/include/include/DDA/FlowDDA.h +178 -0
  33. package/SVF-osx/svf/include/include/FastCluster/LICENSE.TXT +13 -0
  34. package/SVF-osx/svf/include/include/FastCluster/fastcluster.h +80 -0
  35. package/SVF-osx/svf/include/include/Graphs/CFLGraph.h +215 -0
  36. package/SVF-osx/svf/include/include/Graphs/CHG.h +351 -0
  37. package/SVF-osx/svf/include/include/Graphs/ConsG.h +408 -0
  38. package/SVF-osx/svf/include/include/Graphs/ConsGEdge.h +353 -0
  39. package/SVF-osx/svf/include/include/Graphs/ConsGNode.h +391 -0
  40. package/SVF-osx/svf/include/include/Graphs/DOTGraphTraits.h +188 -0
  41. package/SVF-osx/svf/include/include/Graphs/GenericGraph.h +620 -0
  42. package/SVF-osx/svf/include/include/Graphs/GraphPrinter.h +111 -0
  43. package/SVF-osx/svf/include/include/Graphs/GraphTraits.h +150 -0
  44. package/SVF-osx/svf/include/include/Graphs/GraphWriter.h +380 -0
  45. package/SVF-osx/svf/include/include/Graphs/ICFG.h +331 -0
  46. package/SVF-osx/svf/include/include/Graphs/ICFGEdge.h +264 -0
  47. package/SVF-osx/svf/include/include/Graphs/ICFGNode.h +523 -0
  48. package/SVF-osx/svf/include/include/Graphs/ICFGStat.h +164 -0
  49. package/SVF-osx/svf/include/include/Graphs/IRGraph.h +243 -0
  50. package/SVF-osx/svf/include/include/Graphs/PTACallGraph.h +471 -0
  51. package/SVF-osx/svf/include/include/Graphs/SVFG.h +490 -0
  52. package/SVF-osx/svf/include/include/Graphs/SVFGEdge.h +237 -0
  53. package/SVF-osx/svf/include/include/Graphs/SVFGNode.h +513 -0
  54. package/SVF-osx/svf/include/include/Graphs/SVFGOPT.h +362 -0
  55. package/SVF-osx/svf/include/include/Graphs/SVFGStat.h +273 -0
  56. package/SVF-osx/svf/include/include/Graphs/ThreadCallGraph.h +422 -0
  57. package/SVF-osx/svf/include/include/Graphs/VFG.h +664 -0
  58. package/SVF-osx/svf/include/include/Graphs/VFGEdge.h +295 -0
  59. package/SVF-osx/svf/include/include/Graphs/VFGNode.h +1197 -0
  60. package/SVF-osx/svf/include/include/MSSA/MSSAMuChi.h +722 -0
  61. package/SVF-osx/svf/include/include/MSSA/MemPartition.h +169 -0
  62. package/SVF-osx/svf/include/include/MSSA/MemRegion.h +491 -0
  63. package/SVF-osx/svf/include/include/MSSA/MemSSA.h +452 -0
  64. package/SVF-osx/svf/include/include/MSSA/SVFGBuilder.h +98 -0
  65. package/SVF-osx/svf/include/include/MTA/FSMPTA.h +270 -0
  66. package/SVF-osx/svf/include/include/MTA/LockAnalysis.h +517 -0
  67. package/SVF-osx/svf/include/include/MTA/MHP.h +565 -0
  68. package/SVF-osx/svf/include/include/MTA/MTA.h +101 -0
  69. package/SVF-osx/svf/include/include/MTA/MTAResultValidator.h +448 -0
  70. package/SVF-osx/svf/include/include/MTA/MTAStat.h +74 -0
  71. package/SVF-osx/svf/include/include/MTA/PCG.h +229 -0
  72. package/SVF-osx/svf/include/include/MTA/TCT.h +599 -0
  73. package/SVF-osx/svf/include/include/MemoryModel/AbstractPointsToDS.h +316 -0
  74. package/SVF-osx/svf/include/include/MemoryModel/ConditionalPT.h +878 -0
  75. package/SVF-osx/svf/include/include/MemoryModel/LocationSet.h +148 -0
  76. package/SVF-osx/svf/include/include/MemoryModel/MutablePointsToDS.h +1025 -0
  77. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToCache.h +463 -0
  78. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToDS.h +955 -0
  79. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysis.h +452 -0
  80. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysisImpl.h +590 -0
  81. package/SVF-osx/svf/include/include/MemoryModel/PointsTo.h +255 -0
  82. package/SVF-osx/svf/include/include/MemoryModel/SVFLoop.h +164 -0
  83. package/SVF-osx/svf/include/include/SABER/DoubleFreeChecker.h +76 -0
  84. package/SVF-osx/svf/include/include/SABER/FileChecker.h +82 -0
  85. package/SVF-osx/svf/include/include/SABER/LeakChecker.h +124 -0
  86. package/SVF-osx/svf/include/include/SABER/ProgSlice.h +313 -0
  87. package/SVF-osx/svf/include/include/SABER/SaberCheckerAPI.h +166 -0
  88. package/SVF-osx/svf/include/include/SABER/SaberCondAllocator.h +310 -0
  89. package/SVF-osx/svf/include/include/SABER/SaberSVFGBuilder.h +104 -0
  90. package/SVF-osx/svf/include/include/SABER/SrcSnkDDA.h +321 -0
  91. package/SVF-osx/svf/include/include/SABER/SrcSnkSolver.h +186 -0
  92. package/SVF-osx/svf/include/include/SVFIR/PAGBuilderFromFile.h +80 -0
  93. package/SVF-osx/svf/include/include/SVFIR/SVFIR.h +659 -0
  94. package/SVF-osx/svf/include/include/SVFIR/SVFModule.h +233 -0
  95. package/SVF-osx/svf/include/include/SVFIR/SVFStatements.h +1136 -0
  96. package/SVF-osx/svf/include/include/SVFIR/SVFType.h +527 -0
  97. package/SVF-osx/svf/include/include/SVFIR/SVFValue.h +1120 -0
  98. package/SVF-osx/svf/include/include/SVFIR/SVFVariables.h +721 -0
  99. package/SVF-osx/svf/include/include/SVFIR/SymbolTableInfo.h +597 -0
  100. package/SVF-osx/svf/include/include/Util/Annotator.h +180 -0
  101. package/SVF-osx/svf/include/include/Util/BitVector.h +55 -0
  102. package/SVF-osx/svf/include/include/Util/CallGraphBuilder.h +74 -0
  103. package/SVF-osx/svf/include/include/Util/Casting.h +426 -0
  104. package/SVF-osx/svf/include/include/Util/CommandLine.h +530 -0
  105. package/SVF-osx/svf/include/include/Util/CoreBitVector.h +214 -0
  106. package/SVF-osx/svf/include/include/Util/CppUtil.h +81 -0
  107. package/SVF-osx/svf/include/include/Util/CxtStmt.h +501 -0
  108. package/SVF-osx/svf/include/include/Util/DPItem.h +618 -0
  109. package/SVF-osx/svf/include/include/Util/ExtAPI.h +339 -0
  110. package/SVF-osx/svf/include/include/Util/ExtAPI.json +5707 -0
  111. package/SVF-osx/svf/include/include/Util/GraphReachSolver.h +186 -0
  112. package/SVF-osx/svf/include/include/Util/NodeIDAllocator.h +194 -0
  113. package/SVF-osx/svf/include/include/Util/Options.h +266 -0
  114. package/SVF-osx/svf/include/include/Util/PTAStat.h +65 -0
  115. package/SVF-osx/svf/include/include/Util/SCC.h +354 -0
  116. package/SVF-osx/svf/include/include/Util/SVFStat.h +100 -0
  117. package/SVF-osx/svf/include/include/Util/SVFUtil.h +660 -0
  118. package/SVF-osx/svf/include/include/Util/SparseBitVector.h +1202 -0
  119. package/SVF-osx/svf/include/include/Util/ThreadAPI.h +330 -0
  120. package/SVF-osx/svf/include/include/Util/WorkList.h +317 -0
  121. package/SVF-osx/svf/include/include/Util/Z3Expr.h +318 -0
  122. package/SVF-osx/svf/include/include/Util/cJSON.h +300 -0
  123. package/SVF-osx/svf/include/include/Util/iterator.h +407 -0
  124. package/SVF-osx/svf/include/include/Util/iterator_range.h +76 -0
  125. package/SVF-osx/svf/include/include/WPA/Andersen.h +416 -0
  126. package/SVF-osx/svf/include/include/WPA/AndersenPWC.h +160 -0
  127. package/SVF-osx/svf/include/include/WPA/CSC.h +95 -0
  128. package/SVF-osx/svf/include/include/WPA/FlowSensitive.h +317 -0
  129. package/SVF-osx/svf/include/include/WPA/Steensgaard.h +126 -0
  130. package/SVF-osx/svf/include/include/WPA/TypeAnalysis.h +83 -0
  131. package/SVF-osx/svf/include/include/WPA/VersionedFlowSensitive.h +287 -0
  132. package/SVF-osx/svf/include/include/WPA/WPAFSSolver.h +254 -0
  133. package/SVF-osx/svf/include/include/WPA/WPAPass.h +119 -0
  134. package/SVF-osx/svf/include/include/WPA/WPASolver.h +205 -0
  135. package/SVF-osx/svf/include/include/WPA/WPAStat.h +222 -0
  136. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BasicTypes.h +250 -0
  137. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BreakConstantExpr.h +94 -0
  138. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/CHGBuilder.h +73 -0
  139. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/DCHG.h +484 -0
  140. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
  141. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/ICFGBuilder.h +106 -0
  142. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMLoopAnalysis.h +61 -0
  143. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMModule.h +360 -0
  144. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMUtil.h +466 -0
  145. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SVFIRBuilder.h +417 -0
  146. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SymbolTableBuilder.h +110 -0
  147. package/package.json +1 -1
@@ -0,0 +1,417 @@
1
+ //===- SVFIRBuilder.h -- Building SVFIR-------------------------------------------//
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
+ * SVFIRBuilder.h
25
+ *
26
+ * Created on: Nov 1, 2013
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef PAGBUILDER_H_
31
+ #define PAGBUILDER_H_
32
+
33
+ #include "SVFIR/SVFIR.h"
34
+ #include "Util/ExtAPI.h"
35
+ #include "SVF-LLVM/BasicTypes.h"
36
+ #include "SVF-LLVM/ICFGBuilder.h"
37
+ #include "SVF-LLVM/LLVMModule.h"
38
+
39
+ namespace SVF
40
+ {
41
+
42
+ class SVFModule;
43
+ /*!
44
+ * SVFIR Builder to create SVF variables and statements and PAG
45
+ */
46
+ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
47
+ {
48
+
49
+ private:
50
+ SVFIR* pag;
51
+ SVFModule* svfModule;
52
+ const SVFBasicBlock* curBB; ///< Current basic block during SVFIR construction when visiting the module
53
+ const SVFValue* curVal; ///< Current Value during SVFIR construction when visiting the module
54
+
55
+ public:
56
+ /// Constructor
57
+ SVFIRBuilder(SVFModule* mod): pag(SVFIR::getPAG()), svfModule(mod), curBB(nullptr),curVal(nullptr)
58
+ {
59
+ }
60
+ /// Destructor
61
+ virtual ~SVFIRBuilder()
62
+ {
63
+ }
64
+
65
+ /// Start building SVFIR here
66
+ virtual SVFIR* build();
67
+
68
+ /// Return SVFIR
69
+ SVFIR* getPAG() const
70
+ {
71
+ return pag;
72
+ }
73
+
74
+ /// Initialize nodes and edges
75
+ //@{
76
+ void initialiseNodes();
77
+ void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
78
+ s32_t offset = 0, Instruction* cs = nullptr);
79
+ // @}
80
+
81
+ /// Sanity check for SVFIR
82
+ void sanityCheck();
83
+
84
+ /// Get different kinds of node
85
+ //@{
86
+ // GetValNode - Return the value node according to a LLVM Value.
87
+ NodeID getValueNode(const Value* V)
88
+ {
89
+ // first handle gep edge if val if a constant expression
90
+ processCE(V);
91
+
92
+ // strip off the constant cast and return the value node
93
+ SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(V);
94
+ return pag->getValueNode(svfVal);
95
+ }
96
+
97
+ /// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
98
+ inline NodeID getObjectNode(const Value* V)
99
+ {
100
+ SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(V);
101
+ return pag->getObjectNode(svfVal);
102
+ }
103
+
104
+ /// getReturnNode - Return the node representing the unique return value of a function.
105
+ inline NodeID getReturnNode(const SVFFunction *func)
106
+ {
107
+ return pag->getReturnNode(func);
108
+ }
109
+
110
+ /// getVarargNode - Return the node representing the unique variadic argument of a function.
111
+ inline NodeID getVarargNode(const SVFFunction *func)
112
+ {
113
+ return pag->getVarargNode(func);
114
+ }
115
+ //@}
116
+
117
+
118
+ /// Our visit overrides.
119
+ //@{
120
+ // Instructions that cannot be folded away.
121
+ virtual void visitAllocaInst(AllocaInst &AI);
122
+ void visitPHINode(PHINode &I);
123
+ void visitStoreInst(StoreInst &I);
124
+ void visitLoadInst(LoadInst &I);
125
+ void visitGetElementPtrInst(GetElementPtrInst &I);
126
+ void visitCallInst(CallInst &I);
127
+ void visitInvokeInst(InvokeInst &II);
128
+ void visitCallBrInst(CallBrInst &I);
129
+ void visitCallSite(CallBase* cs);
130
+ void visitReturnInst(ReturnInst &I);
131
+ void visitCastInst(CastInst &I);
132
+ void visitSelectInst(SelectInst &I);
133
+ void visitExtractValueInst(ExtractValueInst &EVI);
134
+ void visitBranchInst(BranchInst &I);
135
+ void visitSwitchInst(SwitchInst &I);
136
+ void visitInsertValueInst(InsertValueInst &I)
137
+ {
138
+ addBlackHoleAddrEdge(getValueNode(&I));
139
+ }
140
+ // TerminatorInst and UnwindInst have been removed since llvm-8.0.0
141
+ // void visitTerminatorInst(TerminatorInst &TI) {}
142
+ // void visitUnwindInst(UnwindInst &I) { /*returns void*/}
143
+
144
+ void visitBinaryOperator(BinaryOperator &I);
145
+ void visitUnaryOperator(UnaryOperator &I);
146
+ void visitCmpInst(CmpInst &I);
147
+
148
+ /// TODO: var arguments need to be handled.
149
+ /// https://llvm.org/docs/LangRef.html#id1911
150
+ void visitVAArgInst(VAArgInst&);
151
+ void visitVACopyInst(VACopyInst&) {}
152
+ void visitVAEndInst(VAEndInst&) {}
153
+ void visitVAStartInst(VAStartInst&) {}
154
+
155
+ /// <result> = freeze ty <val>
156
+ /// If <val> is undef or poison, ‘freeze’ returns an arbitrary, but fixed value of type `ty`
157
+ /// Otherwise, this instruction is a no-op and returns the input <val>
158
+ void visitFreezeInst(FreezeInst& I);
159
+
160
+ void visitExtractElementInst(ExtractElementInst &I);
161
+
162
+ void visitInsertElementInst(InsertElementInst &I)
163
+ {
164
+ addBlackHoleAddrEdge(getValueNode(&I));
165
+ }
166
+ void visitShuffleVectorInst(ShuffleVectorInst &I)
167
+ {
168
+ addBlackHoleAddrEdge(getValueNode(&I));
169
+ }
170
+ void visitLandingPadInst(LandingPadInst &I)
171
+ {
172
+ addBlackHoleAddrEdge(getValueNode(&I));
173
+ }
174
+
175
+ /// Instruction not that often
176
+ void visitResumeInst(ResumeInst&) /*returns void*/
177
+ {
178
+ }
179
+ void visitUnreachableInst(UnreachableInst&) /*returns void*/
180
+ {
181
+ }
182
+ void visitFenceInst(FenceInst &I) /*returns void*/
183
+ {
184
+ addBlackHoleAddrEdge(getValueNode(&I));
185
+ }
186
+ void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
187
+ {
188
+ addBlackHoleAddrEdge(getValueNode(&I));
189
+ }
190
+ void visitAtomicRMWInst(AtomicRMWInst &I)
191
+ {
192
+ addBlackHoleAddrEdge(getValueNode(&I));
193
+ }
194
+
195
+ /// Provide base case for our instruction visit.
196
+ inline void visitInstruction(Instruction&)
197
+ {
198
+ // If a new instruction is added to LLVM that we don't handle.
199
+ // TODO: ignore here:
200
+ }
201
+ //}@
202
+
203
+ /// connect PAG edges based on callgraph
204
+ void updateCallGraph(PTACallGraph* callgraph);
205
+
206
+ protected:
207
+ /// Handle globals including (global variable and functions)
208
+ //@{
209
+ void visitGlobal(SVFModule* svfModule);
210
+ void InitialGlobal(const GlobalVariable *gvar, Constant *C,
211
+ u32_t offset);
212
+ NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset, SVFType* tpy);
213
+ //@}
214
+
215
+ /// Process constant expression
216
+ void processCE(const Value* val);
217
+
218
+ /// Infer field index from byteoffset.
219
+ u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s32_t idx);
220
+
221
+ /// Compute offset of a gep instruction or gep constant expression
222
+ bool computeGepOffset(const User *V, LocationSet& ls);
223
+
224
+ /// Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst, i8* src, int size))
225
+ const Value* getBaseValueForExtArg(const Value* V);
226
+
227
+ /// Get the base type and max offset
228
+ const Type* getBaseTypeAndFlattenedFields(const Value* V, std::vector<LocationSet> &fields, const Value* sz);
229
+
230
+ /// Handle direct call
231
+ void handleDirectCall(CallBase* cs, const Function *F);
232
+
233
+ /// Handle indirect call
234
+ void handleIndCall(CallBase* cs);
235
+
236
+ /// Handle external call
237
+ //@{
238
+ virtual void parseOperations(std::vector<ExtAPI::Operation> &operations, CallBase* cs);
239
+ virtual void handleExtCall(CallBase* cs, const Function *F);
240
+ void addComplexConsForExt(const Value* D, const Value* S, const Value* sz);
241
+ //@}
242
+
243
+ /// Set current basic block in order to keep track of control flow information
244
+ inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
245
+ {
246
+ curBB = (bb == nullptr? nullptr : LLVMModuleSet::getLLVMModuleSet()->getSVFBasicBlock(bb));
247
+ curVal = (val == nullptr ? nullptr: LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val));
248
+ }
249
+ inline void setCurrentLocation(const SVFValue* val, const SVFBasicBlock* bb)
250
+ {
251
+ curBB = bb;
252
+ curVal = val;
253
+ }
254
+ inline const SVFValue* getCurrentValue() const
255
+ {
256
+ return curVal;
257
+ }
258
+ inline const SVFBasicBlock* getCurrentBB() const
259
+ {
260
+ return curBB;
261
+ }
262
+
263
+ /// Add global black hole Address edge
264
+ void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
265
+ {
266
+ const SVFValue* cval = getCurrentValue();
267
+ const SVFBasicBlock* cbb = getCurrentBB();
268
+ setCurrentLocation(int2Ptrce,nullptr);
269
+ addBlackHoleAddrEdge(node);
270
+ setCurrentLocation(cval,cbb);
271
+ }
272
+
273
+ /// Add NullPtr PAGNode
274
+ inline NodeID addNullPtrNode()
275
+ {
276
+ LLVMContext& cxt = LLVMModuleSet::getLLVMModuleSet()->getContext();
277
+ ConstantPointerNull* constNull = ConstantPointerNull::get(Type::getInt8PtrTy(cxt));
278
+ NodeID nullPtr = pag->addValNode(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(constNull),pag->getNullPtr());
279
+ setCurrentLocation(constNull, nullptr);
280
+ addBlackHoleAddrEdge(pag->getBlkPtr());
281
+ return nullPtr;
282
+ }
283
+
284
+ NodeID getGepValVar(const Value* val, const LocationSet& ls, const SVFType* baseType);
285
+
286
+ void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
287
+
288
+ inline void addBlackHoleAddrEdge(NodeID node)
289
+ {
290
+ if(PAGEdge *edge = pag->addBlackHoleAddrStmt(node))
291
+ setCurrentBBAndValueForPAGEdge(edge);
292
+ }
293
+
294
+ /// Add Address edge
295
+ inline AddrStmt* addAddrEdge(NodeID src, NodeID dst)
296
+ {
297
+ if(AddrStmt *edge = pag->addAddrStmt(src, dst))
298
+ {
299
+ setCurrentBBAndValueForPAGEdge(edge);
300
+ return edge;
301
+ }
302
+ return nullptr;
303
+ }
304
+ /// Add Copy edge
305
+ inline CopyStmt* addCopyEdge(NodeID src, NodeID dst)
306
+ {
307
+ if(CopyStmt *edge = pag->addCopyStmt(src, dst))
308
+ {
309
+ setCurrentBBAndValueForPAGEdge(edge);
310
+ return edge;
311
+ }
312
+ return nullptr;
313
+ }
314
+ /// Add Copy edge
315
+ inline void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
316
+ {
317
+ /// If we already added this phi node, then skip this adding
318
+ if(PhiStmt *edge = pag->addPhiStmt(res,opnd,pred))
319
+ setCurrentBBAndValueForPAGEdge(edge);
320
+ }
321
+ /// Add SelectStmt
322
+ inline void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
323
+ {
324
+ if(SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond))
325
+ setCurrentBBAndValueForPAGEdge(edge);
326
+ }
327
+ /// Add Copy edge
328
+ inline void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
329
+ {
330
+ if(CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict))
331
+ setCurrentBBAndValueForPAGEdge(edge);
332
+ }
333
+ /// Add Copy edge
334
+ inline void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
335
+ {
336
+ if(BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode))
337
+ setCurrentBBAndValueForPAGEdge(edge);
338
+ }
339
+ /// Add Unary edge
340
+ inline void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
341
+ {
342
+ if(UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode))
343
+ setCurrentBBAndValueForPAGEdge(edge);
344
+ }
345
+ /// Add Branch statement
346
+ inline void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs)
347
+ {
348
+ if(BranchStmt *edge = pag->addBranchStmt(br, cond, succs))
349
+ setCurrentBBAndValueForPAGEdge(edge);
350
+ }
351
+ /// Add Load edge
352
+ inline void addLoadEdge(NodeID src, NodeID dst)
353
+ {
354
+ if(LoadStmt *edge = pag->addLoadStmt(src, dst))
355
+ setCurrentBBAndValueForPAGEdge(edge);
356
+ }
357
+ /// Add Store edge
358
+ inline void addStoreEdge(NodeID src, NodeID dst)
359
+ {
360
+ IntraICFGNode* node;
361
+ if(const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
362
+ node = pag->getICFG()->getIntraICFGNode(inst);
363
+ else
364
+ node = nullptr;
365
+ if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
366
+ setCurrentBBAndValueForPAGEdge(edge);
367
+ }
368
+ /// Add Call edge
369
+ inline void addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
370
+ {
371
+ if(CallPE *edge = pag->addCallPE(src, dst, cs, entry))
372
+ setCurrentBBAndValueForPAGEdge(edge);
373
+ }
374
+ /// Add Return edge
375
+ inline void addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
376
+ {
377
+ if(RetPE *edge = pag->addRetPE(src, dst, cs, exit))
378
+ setCurrentBBAndValueForPAGEdge(edge);
379
+ }
380
+ /// Add Gep edge
381
+ inline void addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
382
+ {
383
+ if(GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep))
384
+ setCurrentBBAndValueForPAGEdge(edge);
385
+ }
386
+ /// Add Offset(Gep) edge
387
+ inline void addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
388
+ {
389
+ if(GepStmt *edge = pag->addNormalGepStmt(src, dst, ls))
390
+ setCurrentBBAndValueForPAGEdge(edge);
391
+ }
392
+ /// Add Variant(Gep) edge
393
+ inline void addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
394
+ {
395
+ if(GepStmt *edge = pag->addVariantGepStmt(src, dst, ls))
396
+ setCurrentBBAndValueForPAGEdge(edge);
397
+ }
398
+ /// Add Thread fork edge for parameter passing
399
+ inline void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
400
+ {
401
+ if(TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry))
402
+ setCurrentBBAndValueForPAGEdge(edge);
403
+ }
404
+ /// Add Thread join edge for parameter passing
405
+ inline void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
406
+ {
407
+ if(TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit))
408
+ setCurrentBBAndValueForPAGEdge(edge);
409
+ }
410
+ //@}
411
+
412
+ LocationSet getLocationSetFromBaseNode(NodeID nodeId);
413
+ };
414
+
415
+ } // End namespace SVF
416
+
417
+ #endif /* PAGBUILDER_H_ */
@@ -0,0 +1,110 @@
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 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
+ * 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 SymbolTableBuilder
43
+ {
44
+
45
+ private:
46
+ SymbolTableInfo* symInfo;
47
+
48
+ public:
49
+ /// Constructor
50
+ SymbolTableBuilder(SymbolTableInfo* si): symInfo(si)
51
+ {
52
+ }
53
+
54
+ /// Start building memory model
55
+ void buildMemModel(SVFModule* svfModule);
56
+
57
+ /// Return size of this object based on LLVM value
58
+ u32_t getObjSize(const Type* type);
59
+
60
+ protected:
61
+
62
+ /// collect the syms
63
+ //@{
64
+ void collectSVFTypeInfo(const Value* val);
65
+
66
+ void collectSym(const Value* val);
67
+
68
+ void collectVal(const Value* val);
69
+
70
+ void collectObj(const Value* val);
71
+
72
+ void collectRet(const Function* val);
73
+
74
+ void collectVararg(const Function* val);
75
+ //@}
76
+
77
+ /// Handle constant expression
78
+ // @{
79
+ void handleGlobalCE(const GlobalVariable *G);
80
+ void handleGlobalInitializerCE(const Constant *C);
81
+ void handleCE(const Value* val);
82
+ // @}
83
+
84
+ /// Create an objectInfo based on LLVM value
85
+ ObjTypeInfo* createObjTypeInfo(const Value* val);
86
+
87
+ /// Initialize TypeInfo based on LLVM Value
88
+ void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value, const Type* ty);
89
+ /// Analyse types of all flattened fields of this object
90
+ void analyzeObjType(ObjTypeInfo* typeinfo, const Value* val);
91
+ /// Analyse types of heap and static objects
92
+ void analyzeHeapObjType(ObjTypeInfo* typeinfo, const Value* val);
93
+ /// Analyse types of heap and static objects
94
+ void analyzeStaticObjType(ObjTypeInfo* typeinfo, const Value* val);
95
+
96
+ ///Get a reference to the components of struct_info.
97
+ /// Number of flattenned elements of an array or struct
98
+ u32_t getNumOfFlattenElements(const Type* T);
99
+
100
+ ///Get a reference to StructInfo.
101
+ StInfo* getOrAddSVFTypeInfo(const Type* T);
102
+
103
+ MemObj* createBlkObj(SymID symId);
104
+
105
+ MemObj* createConstantObj(SymID symId);
106
+ };
107
+
108
+ } // End namespace SVF
109
+
110
+ #endif /* SymbolTableBuilder_H_ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1375",
3
+ "version": "1.0.1376",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {