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,406 @@
1
+ //===- AbstractExeState.h ----Interval Domain-------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2022> <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
+ * IntervalExeState.h
24
+ *
25
+ * Created on: Jul 9, 2022
26
+ * Author: Xiao Cheng, Jiawei Wang
27
+ *
28
+ * [-oo,+oo]
29
+ * / / \ \
30
+ * [-oo,1] ... [-oo,10] ... [-1,+oo] ... [0,+oo]
31
+ * \ \ / /
32
+ * \ [-1,10] /
33
+ * \ / \ /
34
+ * ... [-1,1] ... [0,10] ...
35
+ * \ | \ / \ /
36
+ * ... [-1,0] [0,1] ... [1,9] ...
37
+ * \ | \ | \ /
38
+ * ... [-1,-1] [0,0] [1,1] ...
39
+ * \ \ \ / /
40
+ * ⊥
41
+ */
42
+ // The implementation is based on
43
+ // Xiao Cheng, Jiawei Wang and Yulei Sui. Precise Sparse Abstract Execution via Cross-Domain Interaction.
44
+ // 46th International Conference on Software Engineering. (ICSE24)
45
+
46
+ #ifndef Z3_EXAMPLE_INTERVAL_DOMAIN_H
47
+ #define Z3_EXAMPLE_INTERVAL_DOMAIN_H
48
+
49
+ #include "AE/Core/AbstractValue.h"
50
+ #include "AE/Core/IntervalValue.h"
51
+ #include "SVFIR/SVFVariables.h"
52
+ #include "Util/Z3Expr.h"
53
+
54
+ #include <iomanip>
55
+
56
+ namespace SVF
57
+ {
58
+ class AbstractState
59
+ {
60
+ friend class SVFIR2AbsState;
61
+ friend class RelationSolver;
62
+ public:
63
+ typedef Map<u32_t, AbstractValue> VarToAbsValMap;
64
+
65
+ typedef VarToAbsValMap AddrToAbsValMap;
66
+
67
+ public:
68
+ /// default constructor
69
+ AbstractState()
70
+ {
71
+ }
72
+
73
+ AbstractState(VarToAbsValMap&_varToValMap, AddrToAbsValMap&_locToValMap) : _varToAbsVal(_varToValMap), _addrToAbsVal(_locToValMap) {}
74
+
75
+ /// copy constructor
76
+ AbstractState(const AbstractState&rhs) : _varToAbsVal(rhs.getVarToVal()), _addrToAbsVal(rhs.getLocToVal())
77
+ {
78
+
79
+ }
80
+
81
+ virtual ~AbstractState() = default;
82
+
83
+ // getGepObjAddrs
84
+ AddressValue getGepObjAddrs(u32_t pointer, IntervalValue offset);
85
+
86
+ // initObjVar
87
+ void initObjVar(ObjVar* objVar);
88
+ // getElementIndex
89
+ IntervalValue getElementIndex(const GepStmt* gep);
90
+ // getByteOffset
91
+ IntervalValue getByteOffset(const GepStmt* gep);
92
+ // printAbstractState
93
+ // loadValue
94
+ AbstractValue loadValue(NodeID varId);
95
+ // storeValue
96
+ void storeValue(NodeID varId, AbstractValue val);
97
+
98
+ u32_t getAllocaInstByteSize(const AddrStmt *addr);
99
+
100
+
101
+ /// The physical address starts with 0x7f...... + idx
102
+ static inline u32_t getVirtualMemAddress(u32_t idx)
103
+ {
104
+ return AddressValue::getVirtualMemAddress(idx);
105
+ }
106
+
107
+ /// Check bit value of val start with 0x7F000000, filter by 0xFF000000
108
+ static inline bool isVirtualMemAddress(u32_t val)
109
+ {
110
+ return AddressValue::isVirtualMemAddress(val);
111
+ }
112
+
113
+ /// Return the internal index if idx is an address otherwise return the value of idx
114
+ static inline u32_t getInternalID(u32_t idx)
115
+ {
116
+ return AddressValue::getInternalID(idx);
117
+ }
118
+
119
+ static inline bool isNullPtr(u32_t addr)
120
+ {
121
+ return getInternalID(addr) == 0;
122
+ }
123
+
124
+ AbstractState&operator=(const AbstractState&rhs)
125
+ {
126
+ if (rhs != *this)
127
+ {
128
+ _varToAbsVal = rhs._varToAbsVal;
129
+ _addrToAbsVal = rhs._addrToAbsVal;
130
+ }
131
+ return *this;
132
+ }
133
+
134
+ /// move constructor
135
+ AbstractState(AbstractState&&rhs) : _varToAbsVal(std::move(rhs._varToAbsVal)),
136
+ _addrToAbsVal(std::move(rhs._addrToAbsVal))
137
+ {
138
+
139
+ }
140
+
141
+ /// operator= move constructor
142
+ AbstractState&operator=(AbstractState&&rhs)
143
+ {
144
+ if (&rhs != this)
145
+ {
146
+ _varToAbsVal = std::move(rhs._varToAbsVal);
147
+ _addrToAbsVal = std::move(rhs._addrToAbsVal);
148
+ }
149
+ return *this;
150
+ }
151
+
152
+ /// Set all value bottom
153
+ AbstractState bottom() const
154
+ {
155
+ AbstractState inv = *this;
156
+ for (auto &item: inv._varToAbsVal)
157
+ {
158
+ if (item.second.isInterval())
159
+ item.second.getInterval().set_to_bottom();
160
+ }
161
+ return inv;
162
+ }
163
+
164
+ /// Set all value top
165
+ AbstractState top() const
166
+ {
167
+ AbstractState inv = *this;
168
+ for (auto &item: inv._varToAbsVal)
169
+ {
170
+ if (item.second.isInterval())
171
+ item.second.getInterval().set_to_top();
172
+ }
173
+ return inv;
174
+ }
175
+
176
+ /// Copy some values and return a new IntervalExeState
177
+ AbstractState sliceState(Set<u32_t> &sl)
178
+ {
179
+ AbstractState inv;
180
+ for (u32_t id: sl)
181
+ {
182
+ inv._varToAbsVal[id] = _varToAbsVal[id];
183
+ }
184
+ return inv;
185
+ }
186
+
187
+ protected:
188
+ VarToAbsValMap _varToAbsVal; ///< Map a variable (symbol) to its abstract value
189
+ AddrToAbsValMap
190
+ _addrToAbsVal; ///< Map a memory address to its stored abstract value
191
+
192
+ public:
193
+
194
+
195
+ /// get abstract value of variable
196
+ inline virtual AbstractValue &operator[](u32_t varId)
197
+ {
198
+ return _varToAbsVal[varId];
199
+ }
200
+
201
+ /// get abstract value of variable
202
+ inline virtual const AbstractValue &operator[](u32_t varId) const
203
+ {
204
+ return _varToAbsVal.at(varId);
205
+ }
206
+
207
+ /// whether the variable is in varToAddrs table
208
+ inline bool inVarToAddrsTable(u32_t id) const
209
+ {
210
+ if (_varToAbsVal.find(id)!= _varToAbsVal.end())
211
+ {
212
+ if (_varToAbsVal.at(id).isAddr())
213
+ {
214
+ return true;
215
+ }
216
+ }
217
+ return false;
218
+ }
219
+
220
+ /// whether the variable is in varToVal table
221
+ inline virtual bool inVarToValTable(u32_t id) const
222
+ {
223
+ if (_varToAbsVal.find(id) != _varToAbsVal.end())
224
+ {
225
+ if (_varToAbsVal.at(id).isInterval())
226
+ {
227
+ return true;
228
+ }
229
+ }
230
+ return false;
231
+ }
232
+
233
+ /// whether the memory address stores memory addresses
234
+ inline bool inAddrToAddrsTable(u32_t id) const
235
+ {
236
+ if (_addrToAbsVal.find(id)!= _addrToAbsVal.end())
237
+ {
238
+ if (_addrToAbsVal.at(id).isAddr())
239
+ {
240
+ return true;
241
+ }
242
+ }
243
+ return false;
244
+ }
245
+
246
+ /// whether the memory address stores abstract value
247
+ inline virtual bool inAddrToValTable(u32_t id) const
248
+ {
249
+ if (_addrToAbsVal.find(id) != _addrToAbsVal.end())
250
+ {
251
+ if (_addrToAbsVal.at(id).isInterval())
252
+ {
253
+ return true;
254
+ }
255
+ }
256
+ return false;
257
+ }
258
+
259
+ /// get var2val map
260
+ const VarToAbsValMap&getVarToVal() const
261
+ {
262
+ return _varToAbsVal;
263
+ }
264
+
265
+ /// get loc2val map
266
+ const AddrToAbsValMap&getLocToVal() const
267
+ {
268
+ return _addrToAbsVal;
269
+ }
270
+
271
+ public:
272
+
273
+ /// domain widen with other, and return the widened domain
274
+ AbstractState widening(const AbstractState&other);
275
+
276
+ /// domain narrow with other, and return the narrowed domain
277
+ AbstractState narrowing(const AbstractState&other);
278
+
279
+ /// domain join with other, important! other widen this.
280
+ void joinWith(const AbstractState&other);
281
+
282
+
283
+ /// domain meet with other, important! other widen this.
284
+ void meetWith(const AbstractState&other);
285
+
286
+ /**
287
+ * if this NodeID in SVFIR is a pointer, get the pointee type
288
+ * e.g arr = (int*) malloc(10*sizeof(int))
289
+ * getPointeeType(arr) -> return int
290
+ * we can set arr[0]='c', arr[1]='c', arr[2]='\0'
291
+ * @param call callnode of memset like api
292
+ */
293
+ const SVFType* getPointeeElement(NodeID id);
294
+
295
+
296
+ u32_t hash() const;
297
+
298
+ public:
299
+ inline void store(u32_t addr, const AbstractValue &val)
300
+ {
301
+ assert(isVirtualMemAddress(addr) && "not virtual address?");
302
+ if (isNullPtr(addr)) return;
303
+ u32_t objId = getInternalID(addr);
304
+ _addrToAbsVal[objId] = val;
305
+ }
306
+
307
+ inline virtual AbstractValue &load(u32_t addr)
308
+ {
309
+ assert(isVirtualMemAddress(addr) && "not virtual address?");
310
+ u32_t objId = getInternalID(addr);
311
+ return _addrToAbsVal[objId];
312
+
313
+ }
314
+
315
+
316
+ void printAbstractState() const;
317
+
318
+ std::string toString() const
319
+ {
320
+ return "";
321
+ }
322
+
323
+ bool equals(const AbstractState&other) const;
324
+
325
+
326
+ static bool eqVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs)
327
+ {
328
+ if (lhs.size() != rhs.size()) return false;
329
+ for (const auto &item: lhs)
330
+ {
331
+ auto it = rhs.find(item.first);
332
+ if (it == rhs.end())
333
+ return false;
334
+ if (!item.second.equals(it->second))
335
+ return false;
336
+ else
337
+ {
338
+ }
339
+ }
340
+ return true;
341
+ }
342
+
343
+ static bool lessThanVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs)
344
+ {
345
+ if (lhs.empty()) return !rhs.empty();
346
+ for (const auto &item: lhs)
347
+ {
348
+ auto it = rhs.find(item.first);
349
+ if (it == rhs.end()) return false;
350
+ // judge from expr id
351
+ if (item.second.getInterval().contain(it->second.getInterval())) return false;
352
+ }
353
+ return true;
354
+ }
355
+
356
+ // lhs >= rhs
357
+ static bool geqVarToValMap(const VarToAbsValMap&lhs, const VarToAbsValMap&rhs)
358
+ {
359
+ if (rhs.empty()) return true;
360
+ for (const auto &item: rhs)
361
+ {
362
+ auto it = lhs.find(item.first);
363
+ if (it == lhs.end()) return false;
364
+ // judge from expr id
365
+ if (!it->second.getInterval().contain(
366
+ item.second.getInterval()))
367
+ return false;
368
+
369
+ }
370
+ return true;
371
+ }
372
+
373
+ bool operator==(const AbstractState&rhs) const
374
+ {
375
+ return eqVarToValMap(_varToAbsVal, rhs.getVarToVal()) &&
376
+ eqVarToValMap(_addrToAbsVal, rhs.getLocToVal());
377
+ }
378
+
379
+ bool operator!=(const AbstractState&rhs) const
380
+ {
381
+ return !(*this == rhs);
382
+ }
383
+
384
+ bool operator<(const AbstractState&rhs) const
385
+ {
386
+ return !(*this >= rhs);
387
+ }
388
+
389
+
390
+ bool operator>=(const AbstractState&rhs) const
391
+ {
392
+ return geqVarToValMap(_varToAbsVal, rhs.getVarToVal()) && geqVarToValMap(_addrToAbsVal, rhs.getLocToVal());
393
+ }
394
+
395
+ void clear()
396
+ {
397
+ _addrToAbsVal.clear();
398
+ _varToAbsVal.clear();
399
+ }
400
+
401
+ };
402
+
403
+ }
404
+
405
+
406
+ #endif //Z3_EXAMPLE_INTERVAL_DOMAIN_H
@@ -0,0 +1,157 @@
1
+ //===- AbstractValue.h ----AbstractValue-------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2022> <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
+ // The implementation is based on
24
+ // Xiao Cheng, Jiawei Wang and Yulei Sui. Precise Sparse Abstract Execution via Cross-Domain Interaction.
25
+ // 46th International Conference on Software Engineering. (ICSE24)
26
+
27
+ #include "AE/Core/IntervalValue.h"
28
+ #include "AE/Core/AddressValue.h"
29
+ #include "Util/SVFUtil.h"
30
+
31
+ namespace SVF
32
+ {
33
+
34
+ class AbstractValue
35
+ {
36
+
37
+ public:
38
+ IntervalValue interval;
39
+ AddressValue addrs;
40
+
41
+ AbstractValue()
42
+ {
43
+ interval = IntervalValue::bottom();
44
+ addrs = AddressValue();
45
+ }
46
+
47
+ AbstractValue(const AbstractValue& other)
48
+ {
49
+ interval = other.interval;
50
+ addrs = other.addrs;
51
+ }
52
+
53
+ inline bool isInterval() const
54
+ {
55
+ return !interval.isBottom();
56
+ }
57
+ inline bool isAddr() const
58
+ {
59
+ return !addrs.isBottom();
60
+ }
61
+
62
+ AbstractValue(AbstractValue &&other)
63
+ {
64
+ interval = SVFUtil::move(other.interval);
65
+ addrs = SVFUtil::move(other.addrs);
66
+ }
67
+
68
+ // operator overload, supporting both interval and address
69
+ AbstractValue& operator=(const AbstractValue& other)
70
+ {
71
+ interval = other.interval;
72
+ addrs = other.addrs;
73
+ return *this;
74
+ }
75
+
76
+ AbstractValue& operator=(const AbstractValue&& other)
77
+ {
78
+ interval = SVFUtil::move(other.interval);
79
+ addrs = SVFUtil::move(other.addrs);
80
+ return *this;
81
+ }
82
+
83
+ AbstractValue& operator=(const IntervalValue& other)
84
+ {
85
+ interval = other;
86
+ addrs = AddressValue();
87
+ return *this;
88
+ }
89
+
90
+ AbstractValue& operator=(const AddressValue& other)
91
+ {
92
+ addrs = other;
93
+ interval = IntervalValue::bottom();
94
+ return *this;
95
+ }
96
+
97
+ AbstractValue(const IntervalValue& ival) : interval(ival), addrs(AddressValue()) {}
98
+
99
+ AbstractValue(const AddressValue& addr) : interval(IntervalValue::bottom()), addrs(addr) {}
100
+
101
+ IntervalValue& getInterval()
102
+ {
103
+ return interval;
104
+ }
105
+
106
+ const IntervalValue getInterval() const
107
+ {
108
+ return interval;
109
+ }
110
+
111
+ AddressValue& getAddrs()
112
+ {
113
+ return addrs;
114
+ }
115
+
116
+ const AddressValue getAddrs() const
117
+ {
118
+ return addrs;
119
+ }
120
+
121
+ ~AbstractValue() {};
122
+
123
+ bool equals(const AbstractValue &rhs) const
124
+ {
125
+ return interval.equals(rhs.interval) && addrs.equals(rhs.addrs);
126
+ }
127
+
128
+ void join_with(const AbstractValue &other)
129
+ {
130
+ interval.join_with(other.interval);
131
+ addrs.join_with(other.addrs);
132
+ }
133
+
134
+ void meet_with(const AbstractValue &other)
135
+ {
136
+ interval.meet_with(other.interval);
137
+ addrs.meet_with(other.addrs);
138
+ }
139
+
140
+ void widen_with(const AbstractValue &other)
141
+ {
142
+ interval.widen_with(other.interval);
143
+ // TODO: widen Addrs
144
+ }
145
+
146
+ void narrow_with(const AbstractValue &other)
147
+ {
148
+ interval.narrow_with(other.interval);
149
+ // TODO: narrow Addrs
150
+ }
151
+
152
+ std::string toString() const
153
+ {
154
+ return "<" + interval.toString() + ", " + addrs.toString() + ">";
155
+ }
156
+ };
157
+ }