svf-lib 1.0.2238 → 1.0.2239

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 (165) hide show
  1. package/SVF-linux-aarch64/Release-build/bin/ae +0 -0
  2. package/SVF-linux-aarch64/Release-build/bin/cfl +0 -0
  3. package/SVF-linux-aarch64/Release-build/bin/dvf +0 -0
  4. package/SVF-linux-aarch64/Release-build/bin/llvm2svf +0 -0
  5. package/SVF-linux-aarch64/Release-build/bin/mta +0 -0
  6. package/SVF-linux-aarch64/Release-build/bin/saber +0 -0
  7. package/SVF-linux-aarch64/Release-build/bin/svf-ex +0 -0
  8. package/SVF-linux-aarch64/Release-build/bin/wpa +0 -0
  9. package/SVF-linux-aarch64/Release-build/include/AE/Core/AbstractState.h +406 -0
  10. package/SVF-linux-aarch64/Release-build/include/AE/Core/AbstractValue.h +157 -0
  11. package/SVF-linux-aarch64/Release-build/include/AE/Core/AddressValue.h +232 -0
  12. package/SVF-linux-aarch64/Release-build/include/AE/Core/ICFGWTO.h +82 -0
  13. package/SVF-linux-aarch64/Release-build/include/AE/Core/IntervalValue.h +1055 -0
  14. package/SVF-linux-aarch64/Release-build/include/AE/Core/NumericValue.h +1292 -0
  15. package/SVF-linux-aarch64/Release-build/include/AE/Core/RelExeState.h +226 -0
  16. package/SVF-linux-aarch64/Release-build/include/AE/Core/RelationSolver.h +91 -0
  17. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AEDetector.h +323 -0
  18. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AbsExtAPI.h +140 -0
  19. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AbstractInterpretation.h +350 -0
  20. package/SVF-linux-aarch64/Release-build/include/CFL/CFGNormalizer.h +84 -0
  21. package/SVF-linux-aarch64/Release-build/include/CFL/CFGrammar.h +468 -0
  22. package/SVF-linux-aarch64/Release-build/include/CFL/CFLAlias.h +168 -0
  23. package/SVF-linux-aarch64/Release-build/include/CFL/CFLBase.h +118 -0
  24. package/SVF-linux-aarch64/Release-build/include/CFL/CFLGramGraphChecker.h +74 -0
  25. package/SVF-linux-aarch64/Release-build/include/CFL/CFLGraphBuilder.h +166 -0
  26. package/SVF-linux-aarch64/Release-build/include/CFL/CFLSVFGBuilder.h +58 -0
  27. package/SVF-linux-aarch64/Release-build/include/CFL/CFLSolver.h +374 -0
  28. package/SVF-linux-aarch64/Release-build/include/CFL/CFLStat.h +67 -0
  29. package/SVF-linux-aarch64/Release-build/include/CFL/CFLVF.h +68 -0
  30. package/SVF-linux-aarch64/Release-build/include/CFL/GrammarBuilder.h +100 -0
  31. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/PAGGrammar.txt +15 -0
  32. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/PEGGrammar.txt +11 -0
  33. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/VFGGrammar.txt +7 -0
  34. package/SVF-linux-aarch64/Release-build/include/DDA/ContextDDA.h +230 -0
  35. package/SVF-linux-aarch64/Release-build/include/DDA/DDAClient.h +163 -0
  36. package/SVF-linux-aarch64/Release-build/include/DDA/DDAPass.h +102 -0
  37. package/SVF-linux-aarch64/Release-build/include/DDA/DDAStat.h +121 -0
  38. package/SVF-linux-aarch64/Release-build/include/DDA/DDAVFSolver.h +794 -0
  39. package/SVF-linux-aarch64/Release-build/include/DDA/FlowDDA.h +178 -0
  40. package/SVF-linux-aarch64/Release-build/include/FastCluster/LICENSE.TXT +13 -0
  41. package/SVF-linux-aarch64/Release-build/include/FastCluster/fastcluster.h +80 -0
  42. package/SVF-linux-aarch64/Release-build/include/Graphs/BasicBlockG.h +318 -0
  43. package/SVF-linux-aarch64/Release-build/include/Graphs/CDG.h +482 -0
  44. package/SVF-linux-aarch64/Release-build/include/Graphs/CFLGraph.h +232 -0
  45. package/SVF-linux-aarch64/Release-build/include/Graphs/CHG.h +369 -0
  46. package/SVF-linux-aarch64/Release-build/include/Graphs/CallGraph.h +498 -0
  47. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsG.h +402 -0
  48. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsGEdge.h +355 -0
  49. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsGNode.h +418 -0
  50. package/SVF-linux-aarch64/Release-build/include/Graphs/DOTGraphTraits.h +188 -0
  51. package/SVF-linux-aarch64/Release-build/include/Graphs/GenericGraph.h +628 -0
  52. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphPrinter.h +111 -0
  53. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphTraits.h +150 -0
  54. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphWriter.h +380 -0
  55. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFG.h +331 -0
  56. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGEdge.h +281 -0
  57. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGNode.h +669 -0
  58. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGStat.h +164 -0
  59. package/SVF-linux-aarch64/Release-build/include/Graphs/IRGraph.h +398 -0
  60. package/SVF-linux-aarch64/Release-build/include/Graphs/SCC.h +375 -0
  61. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFG.h +491 -0
  62. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGEdge.h +237 -0
  63. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGNode.h +501 -0
  64. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGOPT.h +363 -0
  65. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGStat.h +273 -0
  66. package/SVF-linux-aarch64/Release-build/include/Graphs/ThreadCallGraph.h +400 -0
  67. package/SVF-linux-aarch64/Release-build/include/Graphs/VFG.h +664 -0
  68. package/SVF-linux-aarch64/Release-build/include/Graphs/VFGEdge.h +295 -0
  69. package/SVF-linux-aarch64/Release-build/include/Graphs/VFGNode.h +1266 -0
  70. package/SVF-linux-aarch64/Release-build/include/Graphs/WTO.h +872 -0
  71. package/SVF-linux-aarch64/Release-build/include/MSSA/MSSAMuChi.h +722 -0
  72. package/SVF-linux-aarch64/Release-build/include/MSSA/MemPartition.h +169 -0
  73. package/SVF-linux-aarch64/Release-build/include/MSSA/MemRegion.h +489 -0
  74. package/SVF-linux-aarch64/Release-build/include/MSSA/MemSSA.h +452 -0
  75. package/SVF-linux-aarch64/Release-build/include/MSSA/SVFGBuilder.h +98 -0
  76. package/SVF-linux-aarch64/Release-build/include/MTA/LockAnalysis.h +533 -0
  77. package/SVF-linux-aarch64/Release-build/include/MTA/MHP.h +546 -0
  78. package/SVF-linux-aarch64/Release-build/include/MTA/MTA.h +98 -0
  79. package/SVF-linux-aarch64/Release-build/include/MTA/MTAStat.h +73 -0
  80. package/SVF-linux-aarch64/Release-build/include/MTA/TCT.h +620 -0
  81. package/SVF-linux-aarch64/Release-build/include/MemoryModel/AbstractPointsToDS.h +316 -0
  82. package/SVF-linux-aarch64/Release-build/include/MemoryModel/AccessPath.h +194 -0
  83. package/SVF-linux-aarch64/Release-build/include/MemoryModel/ConditionalPT.h +878 -0
  84. package/SVF-linux-aarch64/Release-build/include/MemoryModel/MutablePointsToDS.h +1025 -0
  85. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PersistentPointsToCache.h +463 -0
  86. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PersistentPointsToDS.h +955 -0
  87. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointerAnalysis.h +429 -0
  88. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointerAnalysisImpl.h +602 -0
  89. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointsTo.h +255 -0
  90. package/SVF-linux-aarch64/Release-build/include/MemoryModel/SVFLoop.h +167 -0
  91. package/SVF-linux-aarch64/Release-build/include/SABER/DoubleFreeChecker.h +76 -0
  92. package/SVF-linux-aarch64/Release-build/include/SABER/FileChecker.h +80 -0
  93. package/SVF-linux-aarch64/Release-build/include/SABER/LeakChecker.h +122 -0
  94. package/SVF-linux-aarch64/Release-build/include/SABER/ProgSlice.h +327 -0
  95. package/SVF-linux-aarch64/Release-build/include/SABER/SaberCheckerAPI.h +151 -0
  96. package/SVF-linux-aarch64/Release-build/include/SABER/SaberCondAllocator.h +317 -0
  97. package/SVF-linux-aarch64/Release-build/include/SABER/SaberSVFGBuilder.h +114 -0
  98. package/SVF-linux-aarch64/Release-build/include/SABER/SrcSnkDDA.h +327 -0
  99. package/SVF-linux-aarch64/Release-build/include/SABER/SrcSnkSolver.h +186 -0
  100. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/BasicTypes.h +280 -0
  101. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/BreakConstantExpr.h +94 -0
  102. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/CHGBuilder.h +78 -0
  103. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/CppUtil.h +184 -0
  104. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/DCHG.h +477 -0
  105. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
  106. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/ICFGBuilder.h +160 -0
  107. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMLoopAnalysis.h +60 -0
  108. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMModule.h +594 -0
  109. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMUtil.h +438 -0
  110. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/ObjTypeInference.h +130 -0
  111. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFIRBuilder.h +520 -0
  112. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFLLVMValue.h +387 -0
  113. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFModule.h +186 -0
  114. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +132 -0
  115. package/SVF-linux-aarch64/Release-build/include/SVFIR/ObjTypeInfo.h +224 -0
  116. package/SVF-linux-aarch64/Release-build/include/SVFIR/PAGBuilderFromFile.h +80 -0
  117. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFIR.h +856 -0
  118. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFStatements.h +1328 -0
  119. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFType.h +578 -0
  120. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFValue.h +338 -0
  121. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFVariables.h +2204 -0
  122. package/SVF-linux-aarch64/Release-build/include/Util/Annotator.h +180 -0
  123. package/SVF-linux-aarch64/Release-build/include/Util/BitVector.h +55 -0
  124. package/SVF-linux-aarch64/Release-build/include/Util/CDGBuilder.h +107 -0
  125. package/SVF-linux-aarch64/Release-build/include/Util/CallGraphBuilder.h +62 -0
  126. package/SVF-linux-aarch64/Release-build/include/Util/Casting.h +426 -0
  127. package/SVF-linux-aarch64/Release-build/include/Util/CommandLine.h +530 -0
  128. package/SVF-linux-aarch64/Release-build/include/Util/CoreBitVector.h +214 -0
  129. package/SVF-linux-aarch64/Release-build/include/Util/CxtStmt.h +502 -0
  130. package/SVF-linux-aarch64/Release-build/include/Util/DPItem.h +618 -0
  131. package/SVF-linux-aarch64/Release-build/include/Util/ExtAPI.h +117 -0
  132. package/SVF-linux-aarch64/Release-build/include/Util/GeneralType.h +127 -0
  133. package/SVF-linux-aarch64/Release-build/include/Util/GraphReachSolver.h +186 -0
  134. package/SVF-linux-aarch64/Release-build/include/Util/NodeIDAllocator.h +203 -0
  135. package/SVF-linux-aarch64/Release-build/include/Util/Options.h +272 -0
  136. package/SVF-linux-aarch64/Release-build/include/Util/PTAStat.h +83 -0
  137. package/SVF-linux-aarch64/Release-build/include/Util/SVFBugReport.h +427 -0
  138. package/SVF-linux-aarch64/Release-build/include/Util/SVFLoopAndDomInfo.h +169 -0
  139. package/SVF-linux-aarch64/Release-build/include/Util/SVFStat.h +103 -0
  140. package/SVF-linux-aarch64/Release-build/include/Util/SVFUtil.h +478 -0
  141. package/SVF-linux-aarch64/Release-build/include/Util/SparseBitVector.h +1252 -0
  142. package/SVF-linux-aarch64/Release-build/include/Util/ThreadAPI.h +189 -0
  143. package/SVF-linux-aarch64/Release-build/include/Util/WorkList.h +317 -0
  144. package/SVF-linux-aarch64/Release-build/include/Util/Z3Expr.h +325 -0
  145. package/SVF-linux-aarch64/Release-build/include/Util/cJSON.h +300 -0
  146. package/SVF-linux-aarch64/Release-build/include/Util/config.h +26 -0
  147. package/SVF-linux-aarch64/Release-build/include/Util/iterator.h +407 -0
  148. package/SVF-linux-aarch64/Release-build/include/Util/iterator_range.h +76 -0
  149. package/SVF-linux-aarch64/Release-build/include/WPA/Andersen.h +435 -0
  150. package/SVF-linux-aarch64/Release-build/include/WPA/AndersenPWC.h +160 -0
  151. package/SVF-linux-aarch64/Release-build/include/WPA/CSC.h +95 -0
  152. package/SVF-linux-aarch64/Release-build/include/WPA/FlowSensitive.h +323 -0
  153. package/SVF-linux-aarch64/Release-build/include/WPA/Steensgaard.h +131 -0
  154. package/SVF-linux-aarch64/Release-build/include/WPA/TypeAnalysis.h +90 -0
  155. package/SVF-linux-aarch64/Release-build/include/WPA/VersionedFlowSensitive.h +295 -0
  156. package/SVF-linux-aarch64/Release-build/include/WPA/WPAFSSolver.h +246 -0
  157. package/SVF-linux-aarch64/Release-build/include/WPA/WPAPass.h +116 -0
  158. package/SVF-linux-aarch64/Release-build/include/WPA/WPASolver.h +205 -0
  159. package/SVF-linux-aarch64/Release-build/include/WPA/WPAStat.h +222 -0
  160. package/SVF-linux-aarch64/Release-build/lib/cmake/SVF/SVFConfig.cmake +58 -0
  161. package/SVF-linux-aarch64/Release-build/lib/cmake/SVF/SVFConfigVersion.cmake +43 -0
  162. package/SVF-linux-aarch64/Release-build/lib/extapi.bc +2449 -0
  163. package/SVF-linux-aarch64/Release-build/lib/libSvfCore.so +0 -0
  164. package/SVF-linux-aarch64/Release-build/lib/libSvfLLVM.so.16 +0 -0
  165. package/package.json +1 -1
@@ -0,0 +1,578 @@
1
+ //===- SVFBasicTypes.h -- Basic types used in SVF-----------------------------//
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
+ * BasicTypes.h
25
+ *
26
+ * Created on: Apr 1, 2014
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef INCLUDE_SVFIR_SVFTYPE_H_
31
+ #define INCLUDE_SVFIR_SVFTYPE_H_
32
+
33
+ #include "Util/SparseBitVector.h"
34
+ #include "Util/GeneralType.h"
35
+
36
+
37
+ namespace SVF
38
+ {
39
+ class SVFType;
40
+ class SVFPointerType;
41
+
42
+
43
+ /*!
44
+ * Flattened type information of StructType, ArrayType and SingleValueType
45
+ */
46
+ class StInfo
47
+ {
48
+ friend class SVFIRWriter;
49
+ friend class SVFIRReader;
50
+
51
+ private:
52
+ /// flattened field indices of a struct (ignoring arrays)
53
+ std::vector<u32_t> fldIdxVec;
54
+ /// flattened element indices including structs and arrays by considering
55
+ /// strides
56
+ std::vector<u32_t> elemIdxVec;
57
+ /// Types of all fields of a struct
58
+ Map<u32_t, const SVFType*> fldIdx2TypeMap;
59
+ /// All field infos after flattening a struct
60
+ std::vector<const SVFType*> finfo;
61
+ /// stride represents the number of repetitive elements if this StInfo
62
+ /// represent an ArrayType. stride is 1 by default.
63
+ u32_t stride;
64
+ /// number of elements after flattening (including array elements)
65
+ u32_t numOfFlattenElements;
66
+ /// number of fields after flattening (ignoring array elements)
67
+ u32_t numOfFlattenFields;
68
+ /// Type vector of fields
69
+ std::vector<const SVFType*> flattenElementTypes;
70
+ /// Max field limit
71
+
72
+ public:
73
+ StInfo() = delete;
74
+ StInfo(const StInfo& st) = delete;
75
+ void operator=(const StInfo&) = delete;
76
+
77
+ /// Constructor
78
+ explicit StInfo(u32_t s)
79
+ : stride(s), numOfFlattenElements(s), numOfFlattenFields(s)
80
+ {
81
+ }
82
+ /// Destructor
83
+ ~StInfo() = default;
84
+
85
+ /// struct A { int id; int salary; };
86
+ /// struct B { char name[20]; struct A a;}
87
+ /// B b;
88
+ ///
89
+ /// OriginalFieldType of b with field_idx 1 : Struct A
90
+ /// FlatternedFieldType of b with field_idx 1 : int
91
+ //{@
92
+ const SVFType* getOriginalElemType(u32_t fldIdx) const;
93
+
94
+ inline std::vector<u32_t>& getFlattenedFieldIdxVec()
95
+ {
96
+ return fldIdxVec;
97
+ }
98
+ inline std::vector<u32_t>& getFlattenedElemIdxVec()
99
+ {
100
+ return elemIdxVec;
101
+ }
102
+ inline std::vector<const SVFType*>& getFlattenElementTypes()
103
+ {
104
+ return flattenElementTypes;
105
+ }
106
+ inline std::vector<const SVFType*>& getFlattenFieldTypes()
107
+ {
108
+ return finfo;
109
+ }
110
+ inline const std::vector<u32_t>& getFlattenedFieldIdxVec() const
111
+ {
112
+ return fldIdxVec;
113
+ }
114
+ inline const std::vector<u32_t>& getFlattenedElemIdxVec() const
115
+ {
116
+ return elemIdxVec;
117
+ }
118
+ inline const std::vector<const SVFType*>& getFlattenElementTypes() const
119
+ {
120
+ return flattenElementTypes;
121
+ }
122
+ inline const std::vector<const SVFType*>& getFlattenFieldTypes() const
123
+ {
124
+ return finfo;
125
+ }
126
+ //@}
127
+
128
+ /// Add field index and element index and their corresponding type
129
+ void addFldWithType(u32_t fldIdx, const SVFType* type, u32_t elemIdx);
130
+
131
+ /// Set number of fields and elements of an aggregate
132
+ inline void setNumOfFieldsAndElems(u32_t nf, u32_t ne)
133
+ {
134
+ numOfFlattenFields = nf;
135
+ numOfFlattenElements = ne;
136
+ }
137
+
138
+ /// Return number of elements after flattening (including array elements)
139
+ inline u32_t getNumOfFlattenElements() const
140
+ {
141
+ return numOfFlattenElements;
142
+ }
143
+
144
+ /// Return the number of fields after flattening (ignoring array elements)
145
+ inline u32_t getNumOfFlattenFields() const
146
+ {
147
+ return numOfFlattenFields;
148
+ }
149
+ /// Return the stride
150
+ inline u32_t getStride() const
151
+ {
152
+ return stride;
153
+ }
154
+ };
155
+
156
+ class SVFType
157
+ {
158
+ friend class SVFIRWriter;
159
+ friend class SVFIRReader;
160
+ friend class LLVMModuleSet;
161
+
162
+ public:
163
+ typedef s64_t GNodeK;
164
+
165
+ enum SVFTyKind
166
+ {
167
+ SVFTy,
168
+ SVFPointerTy,
169
+ SVFIntegerTy,
170
+ SVFFunctionTy,
171
+ SVFStructTy,
172
+ SVFArrayTy,
173
+ SVFOtherTy,
174
+ };
175
+
176
+ public:
177
+
178
+ inline static SVFType* getSVFPtrType()
179
+ {
180
+ assert(svfPtrTy && "ptr type not set?");
181
+ return svfPtrTy;
182
+ }
183
+
184
+ inline static SVFType* getSVFInt8Type()
185
+ {
186
+ assert(svfI8Ty && "int8 type not set?");
187
+ return svfI8Ty;
188
+ }
189
+
190
+ private:
191
+
192
+ static SVFType* svfPtrTy; ///< ptr type
193
+ static SVFType* svfI8Ty; ///< 8-bit int type
194
+
195
+ private:
196
+ GNodeK kind; ///< used for classof
197
+ StInfo* typeinfo; ///< SVF's TypeInfo
198
+ bool isSingleValTy; ///< The type represents a single value, not struct or
199
+ u32_t byteSize; ///< LLVM Byte Size
200
+ ///< array
201
+
202
+ protected:
203
+ SVFType(bool svt, SVFTyKind k, u32_t Sz = 1)
204
+ : kind(k), typeinfo(nullptr),
205
+ isSingleValTy(svt), byteSize(Sz)
206
+ {
207
+ }
208
+
209
+ public:
210
+ SVFType(void) = delete;
211
+ virtual ~SVFType() {}
212
+
213
+ inline GNodeK getKind() const
214
+ {
215
+ return kind;
216
+ }
217
+
218
+ /// \note Use `os<<svfType` or `svfType.print(os)` when possible to avoid
219
+ /// string concatenation.
220
+ std::string toString() const;
221
+
222
+ virtual void print(std::ostream& os) const = 0;
223
+
224
+
225
+ inline void setTypeInfo(StInfo* ti)
226
+ {
227
+ typeinfo = ti;
228
+ }
229
+
230
+ inline StInfo* getTypeInfo()
231
+ {
232
+ assert(typeinfo && "set the type info first");
233
+ return typeinfo;
234
+ }
235
+
236
+ inline const StInfo* getTypeInfo() const
237
+ {
238
+ assert(typeinfo && "set the type info first");
239
+ return typeinfo;
240
+ }
241
+
242
+ /// if Type is not sized, byteSize is 0
243
+ /// if Type is sized, byteSize is the LLVM Byte Size.
244
+ inline u32_t getByteSize() const
245
+ {
246
+ return byteSize;
247
+ }
248
+
249
+ inline bool isPointerTy() const
250
+ {
251
+ return kind == SVFPointerTy;
252
+ }
253
+
254
+ inline bool isArrayTy() const
255
+ {
256
+ return kind == SVFArrayTy;
257
+ }
258
+
259
+ inline bool isStructTy() const
260
+ {
261
+ return kind == SVFStructTy;
262
+ }
263
+
264
+ inline bool isSingleValueType() const
265
+ {
266
+ return isSingleValTy;
267
+ }
268
+ };
269
+
270
+ std::ostream& operator<<(std::ostream& os, const SVFType& type);
271
+
272
+ class SVFPointerType : public SVFType
273
+ {
274
+ friend class SVFIRWriter;
275
+ friend class SVFIRReader;
276
+
277
+ public:
278
+ SVFPointerType(u32_t byteSize = 1)
279
+ : SVFType(true, SVFPointerTy, byteSize)
280
+ {
281
+ }
282
+
283
+ static inline bool classof(const SVFType* node)
284
+ {
285
+ return node->getKind() == SVFPointerTy;
286
+ }
287
+
288
+ void print(std::ostream& os) const override;
289
+ };
290
+
291
+ class SVFIntegerType : public SVFType
292
+ {
293
+ friend class SVFIRWriter;
294
+ friend class SVFIRReader;
295
+
296
+ private:
297
+ short signAndWidth; ///< For printing
298
+
299
+ public:
300
+ SVFIntegerType(u32_t byteSize = 1) : SVFType(true, SVFIntegerTy, byteSize) {}
301
+ static inline bool classof(const SVFType* node)
302
+ {
303
+ return node->getKind() == SVFIntegerTy;
304
+ }
305
+
306
+ void print(std::ostream& os) const override;
307
+
308
+ void setSignAndWidth(short sw)
309
+ {
310
+ signAndWidth = sw;
311
+ }
312
+
313
+ bool isSigned() const
314
+ {
315
+ return signAndWidth < 0;
316
+ }
317
+ };
318
+
319
+ class SVFFunctionType : public SVFType
320
+ {
321
+ friend class SVFIRWriter;
322
+ friend class SVFIRReader;
323
+
324
+ private:
325
+ const SVFType* retTy;
326
+
327
+ public:
328
+ SVFFunctionType(const SVFType* rt)
329
+ : SVFType(false, SVFFunctionTy, 1), retTy(rt)
330
+ {
331
+ }
332
+ static inline bool classof(const SVFType* node)
333
+ {
334
+ return node->getKind() == SVFFunctionTy;
335
+ }
336
+ const SVFType* getReturnType() const
337
+ {
338
+ return retTy;
339
+ }
340
+
341
+ void print(std::ostream& os) const override;
342
+ };
343
+
344
+ class SVFStructType : public SVFType
345
+ {
346
+ friend class SVFIRWriter;
347
+ friend class SVFIRReader;
348
+
349
+ private:
350
+ /// @brief Field for printing & debugging
351
+ std::string name;
352
+
353
+ public:
354
+ SVFStructType(u32_t byteSize = 1) : SVFType(false, SVFStructTy, byteSize) {}
355
+
356
+ static inline bool classof(const SVFType* node)
357
+ {
358
+ return node->getKind() == SVFStructTy;
359
+ }
360
+
361
+ void print(std::ostream& os) const override;
362
+
363
+ const std::string& getName()
364
+ {
365
+ return name;
366
+ }
367
+ void setName(const std::string& structName)
368
+ {
369
+ name = structName;
370
+ }
371
+ void setName(std::string&& structName)
372
+ {
373
+ name = std::move(structName);
374
+ }
375
+ };
376
+
377
+ class SVFArrayType : public SVFType
378
+ {
379
+ friend class SVFIRWriter;
380
+ friend class SVFIRReader;
381
+
382
+ private:
383
+ unsigned numOfElement; /// For printing & debugging
384
+ const SVFType* typeOfElement; /// For printing & debugging
385
+
386
+ public:
387
+ SVFArrayType(u32_t byteSize = 1)
388
+ : SVFType(false, SVFArrayTy, byteSize), numOfElement(0), typeOfElement(nullptr)
389
+ {
390
+ }
391
+
392
+ static inline bool classof(const SVFType* node)
393
+ {
394
+ return node->getKind() == SVFArrayTy;
395
+ }
396
+
397
+ void print(std::ostream& os) const override;
398
+
399
+ const SVFType* getTypeOfElement() const
400
+ {
401
+ return typeOfElement;
402
+ }
403
+
404
+ void setTypeOfElement(const SVFType* elemType)
405
+ {
406
+ typeOfElement = elemType;
407
+ }
408
+
409
+ void setNumOfElement(unsigned elemNum)
410
+ {
411
+ numOfElement = elemNum;
412
+ }
413
+
414
+
415
+ };
416
+
417
+ class SVFOtherType : public SVFType
418
+ {
419
+ friend class SVFIRWriter;
420
+ friend class SVFIRReader;
421
+
422
+ private:
423
+ std::string repr; /// Field representation for printing
424
+
425
+ public:
426
+ SVFOtherType(bool isSingleValueTy, u32_t byteSize = 1) : SVFType(isSingleValueTy, SVFOtherTy, byteSize) {}
427
+
428
+ static inline bool classof(const SVFType* node)
429
+ {
430
+ return node->getKind() == SVFOtherTy;
431
+ }
432
+
433
+ const std::string& getRepr()
434
+ {
435
+ return repr;
436
+ }
437
+
438
+ void setRepr(std::string&& r)
439
+ {
440
+ repr = std::move(r);
441
+ }
442
+
443
+ void setRepr(const std::string& r)
444
+ {
445
+ repr = r;
446
+ }
447
+
448
+ void print(std::ostream& os) const override;
449
+ };
450
+
451
+ // TODO: be explicit that this is a pair of 32-bit unsigneds?
452
+ template <> struct Hash<NodePair>
453
+ {
454
+ size_t operator()(const NodePair& p) const
455
+ {
456
+ // Make sure our assumptions are sound: use u32_t
457
+ // and u64_t. If NodeID is not actually u32_t or size_t
458
+ // is not u64_t we should be fine since we get a
459
+ // consistent result.
460
+ uint32_t first = (uint32_t)(p.first);
461
+ uint32_t second = (uint32_t)(p.second);
462
+ return ((uint64_t)(first) << 32) | (uint64_t)(second);
463
+ }
464
+ };
465
+
466
+ #if !defined NDBUG && defined USE_SVF_DBOUT
467
+ // TODO: This comes from the following link
468
+ // https://github.com/llvm/llvm-project/blob/75e33f71c2dae584b13a7d1186ae0a038ba98838/llvm/include/llvm/Support/Debug.h#L64
469
+ // The original LLVM implementation makes use of type. But we can get that info,
470
+ // so we can't simulate the full behaviour for now.
471
+ # define SVF_DEBUG_WITH_TYPE(TYPE, X) \
472
+ do \
473
+ { \
474
+ X; \
475
+ } while (false)
476
+ #else
477
+ # define SVF_DEBUG_WITH_TYPE(TYPE, X) \
478
+ do \
479
+ { \
480
+ } while (false)
481
+ #endif
482
+
483
+ /// LLVM debug macros, define type of your DBUG model of each pass
484
+ #define DBOUT(TYPE, X) SVF_DEBUG_WITH_TYPE(TYPE, X)
485
+ #define DOSTAT(X) X
486
+ #define DOTIMESTAT(X) X
487
+
488
+ /// General debug flag is for each phase of a pass, it is often in a colorful
489
+ /// output format
490
+ #define DGENERAL "general"
491
+
492
+ #define DPAGBuild "pag"
493
+ #define DMemModel "mm"
494
+ #define DMemModelCE "mmce"
495
+ #define DCOMModel "comm"
496
+ #define DDDA "dda"
497
+ #define DDumpPT "dumppt"
498
+ #define DRefinePT "sbpt"
499
+ #define DCache "cache"
500
+ #define DWPA "wpa"
501
+ #define DMSSA "mssa"
502
+ #define DInstrument "ins"
503
+ #define DAndersen "ander"
504
+ #define DSaber "saber"
505
+ #define DMTA "mta"
506
+ #define DCHA "cha"
507
+
508
+ /*
509
+ * Number of clock ticks per second. A clock tick is the unit by which
510
+ * processor time is measured and is returned by 'clock'.
511
+ */
512
+ #define TIMEINTERVAL 1000
513
+ #define CLOCK_IN_MS() (clock() / (CLOCKS_PER_SEC / TIMEINTERVAL))
514
+
515
+ /// Size of native integer that we'll use for bit vectors, in bits.
516
+ #define NATIVE_INT_SIZE (sizeof(unsigned long long) * CHAR_BIT)
517
+
518
+ enum ModRefInfo
519
+ {
520
+ ModRef,
521
+ Ref,
522
+ Mod,
523
+ NoModRef,
524
+ };
525
+
526
+ enum AliasResult
527
+ {
528
+ NoAlias,
529
+ MayAlias,
530
+ MustAlias,
531
+ PartialAlias,
532
+ };
533
+
534
+ } // End namespace SVF
535
+
536
+ template <> struct std::hash<SVF::NodePair>
537
+ {
538
+ size_t operator()(const SVF::NodePair& p) const
539
+ {
540
+ // Make sure our assumptions are sound: use u32_t
541
+ // and u64_t. If NodeID is not actually u32_t or size_t
542
+ // is not u64_t we should be fine since we get a
543
+ // consistent result.
544
+ uint32_t first = (uint32_t)(p.first);
545
+ uint32_t second = (uint32_t)(p.second);
546
+ return ((uint64_t)(first) << 32) | (uint64_t)(second);
547
+ }
548
+ };
549
+
550
+ /// Specialise hash for SparseBitVectors.
551
+ template <unsigned N> struct std::hash<SVF::SparseBitVector<N>>
552
+ {
553
+ size_t operator()(const SVF::SparseBitVector<N>& sbv) const
554
+ {
555
+ SVF::Hash<std::pair<std::pair<size_t, size_t>, size_t>> h;
556
+ return h(std::make_pair(std::make_pair(sbv.count(), sbv.find_first()),
557
+ sbv.find_last()));
558
+ }
559
+ };
560
+
561
+ template <typename T> struct std::hash<std::vector<T>>
562
+ {
563
+ size_t operator()(const std::vector<T>& v) const
564
+ {
565
+ // TODO: repetition with CBV.
566
+ size_t h = v.size();
567
+
568
+ SVF::Hash<T> hf;
569
+ for (const T& t : v)
570
+ {
571
+ h ^= hf(t) + 0x9e3779b9 + (h << 6) + (h >> 2);
572
+ }
573
+
574
+ return h;
575
+ }
576
+ };
577
+
578
+ #endif /* INCLUDE_SVFIR_SVFTYPE_H_ */