svf-lib 1.0.2238 → 1.0.2240

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,2204 @@
1
+ //===- SVFSymbols.h -- SVF Variables------------------------//
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
+ * SVFVariables.h
25
+ *
26
+ * Created on: Nov 11, 2013
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef INCLUDE_SVFIR_SVFVARIABLE_H_
31
+ #define INCLUDE_SVFIR_SVFVARIABLE_H_
32
+
33
+ #include "Graphs/GenericGraph.h"
34
+ #include "SVFIR/ObjTypeInfo.h"
35
+ #include "SVFIR/SVFStatements.h"
36
+
37
+ namespace SVF
38
+ {
39
+
40
+ class SVFVar;
41
+ /*
42
+ * Program variables in SVFIR (based on PAG nodes)
43
+ * These represent variables in the program analysis graph
44
+ */
45
+ typedef GenericNode<SVFVar, SVFStmt> GenericPAGNodeTy;
46
+ class SVFVar : public GenericPAGNodeTy
47
+ {
48
+ friend class SVFIRWriter;
49
+ friend class SVFIRReader;
50
+ friend class SVFIRBuilder;
51
+ friend class IRGraph;
52
+ friend class SVFIR;
53
+ friend class VFG;
54
+
55
+ public:
56
+ /// Node kinds for SVFIR variables:
57
+ /// ValNode - LLVM pointer value
58
+ /// ObjNode - Memory object
59
+ /// RetValNode - Function return value
60
+ /// VarargNode - Variable argument parameter
61
+ /// GepValNode - Temporary value for field-sensitive analysis
62
+ /// GepObjNode - Temporary object for field-sensitive analysis
63
+ /// BaseObjNode - Base object for field-insensitive analysis
64
+ /// DummyValNode/DummyObjNode - Nodes for non-LLVM values
65
+ typedef GNodeK PNODEK;
66
+ typedef s64_t GEdgeKind;
67
+
68
+ protected:
69
+ /// Maps tracking incoming and outgoing edges by kind
70
+ SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap;
71
+ SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap;
72
+
73
+ /// Empty constructor for deserialization
74
+ SVFVar(NodeID i, PNODEK k) : GenericPAGNodeTy(i, k) {}
75
+
76
+
77
+ public:
78
+ /// Standard constructor with ID, type and kind
79
+ SVFVar(NodeID i, const SVFType* svfType, PNODEK k);
80
+
81
+ /// Virtual destructor
82
+ virtual ~SVFVar() {}
83
+
84
+ /// Check if this variable represents a pointer
85
+ virtual inline bool isPointer() const
86
+ {
87
+ assert(type && "type is null?");
88
+ return type->isPointerTy();
89
+ }
90
+
91
+ /// Check if this variable represents constant data/metadata but not null pointer
92
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
93
+ {
94
+ return false;
95
+ }
96
+
97
+ /// Check if this node is isolated (no edges) in the SVFIR graph
98
+ virtual bool isIsolatedNode() const;
99
+
100
+ /// Get string name of the represented LLVM value
101
+ virtual const std::string getValueName() const = 0;
102
+
103
+ /// Get containing function, or null for globals/constants
104
+ virtual inline const FunObjVar* getFunction() const
105
+ {
106
+ return nullptr;
107
+ }
108
+
109
+ /// Edge accessors and checkers
110
+ //@{
111
+ inline SVFStmt::SVFStmtSetTy& getIncomingEdges(SVFStmt::PEDGEK kind)
112
+ {
113
+ return InEdgeKindToSetMap[kind];
114
+ }
115
+
116
+ inline SVFStmt::SVFStmtSetTy& getOutgoingEdges(SVFStmt::PEDGEK kind)
117
+ {
118
+ return OutEdgeKindToSetMap[kind];
119
+ }
120
+
121
+ inline bool hasIncomingEdges(SVFStmt::PEDGEK kind) const
122
+ {
123
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
124
+ if (it != InEdgeKindToSetMap.end())
125
+ return (!it->second.empty());
126
+ else
127
+ return false;
128
+ }
129
+
130
+ inline bool hasOutgoingEdges(SVFStmt::PEDGEK kind) const
131
+ {
132
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
133
+ if (it != OutEdgeKindToSetMap.end())
134
+ return (!it->second.empty());
135
+ else
136
+ return false;
137
+ }
138
+
139
+ /// Edge iterators
140
+ inline SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesBegin(SVFStmt::PEDGEK kind) const
141
+ {
142
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
143
+ assert(it!=InEdgeKindToSetMap.end() && "Edge kind not found");
144
+ return it->second.begin();
145
+ }
146
+
147
+ inline SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesEnd(SVFStmt::PEDGEK kind) const
148
+ {
149
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
150
+ assert(it!=InEdgeKindToSetMap.end() && "Edge kind not found");
151
+ return it->second.end();
152
+ }
153
+
154
+ inline SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesBegin(SVFStmt::PEDGEK kind) const
155
+ {
156
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
157
+ assert(it!=OutEdgeKindToSetMap.end() && "Edge kind not found");
158
+ return it->second.begin();
159
+ }
160
+
161
+ inline SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesEnd(SVFStmt::PEDGEK kind) const
162
+ {
163
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
164
+ assert(it!=OutEdgeKindToSetMap.end() && "Edge kind not found");
165
+ return it->second.end();
166
+ }
167
+ //@}
168
+
169
+ /// Type checking support for LLVM-style RTTI
170
+ static inline bool classof(const SVFVar *)
171
+ {
172
+ return true;
173
+ }
174
+
175
+ static inline bool classof(const GenericPAGNodeTy * node)
176
+ {
177
+ return isSVFVarKind(node->getNodeKind());
178
+ }
179
+
180
+ static inline bool classof(const SVFValue* node)
181
+ {
182
+ return isSVFVarKind(node->getNodeKind());
183
+ }
184
+
185
+ /// Check if this pointer is in an uncalled function
186
+ virtual bool ptrInUncalledFunction() const;
187
+
188
+ /// Check if this variable represents constant/aggregate data
189
+ virtual bool isConstDataOrAggData() const
190
+ {
191
+ return false;
192
+ }
193
+
194
+
195
+ private:
196
+ /// Edge management methods
197
+ //@{
198
+ inline void addInEdge(SVFStmt* inEdge)
199
+ {
200
+ GEdgeKind kind = inEdge->getEdgeKind();
201
+ InEdgeKindToSetMap[kind].insert(inEdge);
202
+ addIncomingEdge(inEdge);
203
+ }
204
+
205
+ inline void addOutEdge(SVFStmt* outEdge)
206
+ {
207
+ GEdgeKind kind = outEdge->getEdgeKind();
208
+ OutEdgeKindToSetMap[kind].insert(outEdge);
209
+ addOutgoingEdge(outEdge);
210
+ }
211
+
212
+ /// Check for incoming variable field GEP edges
213
+ inline bool hasIncomingVariantGepEdge() const
214
+ {
215
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
216
+ if (it != InEdgeKindToSetMap.end())
217
+ {
218
+ for(auto gep : it->second)
219
+ {
220
+ if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
221
+ return true;
222
+ }
223
+ }
224
+ return false;
225
+ }
226
+
227
+ public:
228
+ /// Get string representation
229
+ virtual const std::string toString() const;
230
+
231
+ /// Debug dump to console
232
+ void dump() const;
233
+
234
+ /// Stream operator overload for output
235
+ friend OutStream& operator<< (OutStream &o, const SVFVar &node)
236
+ {
237
+ o << node.toString();
238
+ return o;
239
+ }
240
+ };
241
+
242
+
243
+
244
+ /*
245
+ * Value (Pointer) variable
246
+ */
247
+ class ValVar: public SVFVar
248
+ {
249
+ friend class SVFIRWriter;
250
+ friend class SVFIRReader;
251
+
252
+ private:
253
+ const ICFGNode* icfgNode; // icfgnode related to valvar
254
+ protected:
255
+ /// Constructor to create an empty ValVar (for SVFIRReader/deserialization)
256
+ ValVar(NodeID i, PNODEK ty = ValNode) : SVFVar(i, ty), icfgNode(nullptr) {}
257
+
258
+ public:
259
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
260
+ //@{
261
+ static inline bool classof(const ValVar*)
262
+ {
263
+ return true;
264
+ }
265
+ static inline bool classof(const SVFVar* node)
266
+ {
267
+ return isValVarKinds(node->getNodeKind());
268
+ }
269
+ static inline bool classof(const GenericPAGNodeTy* node)
270
+ {
271
+ return isValVarKinds(node->getNodeKind());
272
+ }
273
+ static inline bool classof(const SVFValue* node)
274
+ {
275
+ return isValVarKinds(node->getNodeKind());
276
+ }
277
+ //@}
278
+
279
+ /// Constructor
280
+ ValVar(NodeID i, const SVFType* svfType, const ICFGNode* node, PNODEK ty = ValNode)
281
+ : SVFVar(i, svfType, ty), icfgNode(node)
282
+ {
283
+ }
284
+ /// Return name of a LLVM value
285
+ inline const std::string getValueName() const
286
+ {
287
+ return getName();
288
+ }
289
+
290
+ const ICFGNode* getICFGNode() const
291
+ {
292
+ return icfgNode;
293
+ }
294
+
295
+ virtual const FunObjVar* getFunction() const;
296
+
297
+ virtual const std::string toString() const;
298
+ };
299
+
300
+ /*
301
+ * Memory Object variable
302
+ */
303
+ class ObjVar: public SVFVar
304
+ {
305
+ friend class SVFIRWriter;
306
+ friend class SVFIRReader;
307
+
308
+ protected:
309
+ /// Constructor to create an empty ObjVar (for SVFIRReader/deserialization)
310
+ ObjVar(NodeID i, PNODEK ty = ObjNode) : SVFVar(i, ty) {}
311
+ /// Constructor
312
+ ObjVar(NodeID i, const SVFType* svfType, PNODEK ty = ObjNode) :
313
+ SVFVar(i, svfType, ty)
314
+ {
315
+ }
316
+ public:
317
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
318
+ //@{
319
+ static inline bool classof(const ObjVar*)
320
+ {
321
+ return true;
322
+ }
323
+ static inline bool classof(const SVFVar* node)
324
+ {
325
+ return isObjVarKinds(node->getNodeKind());
326
+ }
327
+ static inline bool classof(const GenericPAGNodeTy* node)
328
+ {
329
+ return isObjVarKinds(node->getNodeKind());
330
+ }
331
+ static inline bool classof(const SVFValue* node)
332
+ {
333
+ return isObjVarKinds(node->getNodeKind());
334
+ }
335
+ //@}
336
+
337
+ /// Return name of a LLVM value
338
+ virtual const std::string getValueName() const
339
+ {
340
+ return getName();
341
+ }
342
+
343
+ virtual const std::string toString() const;
344
+ };
345
+
346
+
347
+ /**
348
+ * @brief Class representing a function argument variable in the SVFIR
349
+ *
350
+ * This class models function argument in the program analysis. It extends ValVar
351
+ * to specifically handle function argument.
352
+ */
353
+ class ArgValVar: public ValVar
354
+ {
355
+ friend class SVFIRWriter;
356
+ friend class SVFIRReader;
357
+
358
+ private:
359
+ const FunObjVar* cgNode;
360
+ u32_t argNo;
361
+
362
+ protected:
363
+ /// Constructor to create function argument (for SVFIRReader/deserialization)
364
+ ArgValVar(NodeID i, PNODEK ty = ArgValNode) : ValVar(i, ty) {}
365
+
366
+ public:
367
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
368
+ //@{
369
+ static inline bool classof(const ArgValVar*)
370
+ {
371
+ return true;
372
+ }
373
+ static inline bool classof(const ValVar* node)
374
+ {
375
+ return node->getNodeKind() == ArgValNode;
376
+ }
377
+ static inline bool classof(const SVFVar* node)
378
+ {
379
+ return node->getNodeKind() == ArgValNode;
380
+ }
381
+ static inline bool classof(const GenericPAGNodeTy* node)
382
+ {
383
+ return node->getNodeKind() == ArgValNode;
384
+ }
385
+ static inline bool classof(const SVFValue* node)
386
+ {
387
+ return node->getNodeKind() == ArgValNode;
388
+ }
389
+ //@}
390
+
391
+ /// Constructor
392
+ ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const FunObjVar* callGraphNode,
393
+ const SVFType* svfType);
394
+
395
+ /// Return name of a LLVM value
396
+ inline const std::string getValueName() const
397
+ {
398
+ return getName() + " (argument valvar)";
399
+ }
400
+
401
+ virtual const FunObjVar* getFunction() const;
402
+
403
+ const FunObjVar* getParent() const;
404
+
405
+ /// Return the index of this formal argument in its containing function.
406
+ /// For example in "void foo(int a, float b)" a is 0 and b is 1.
407
+ inline u32_t getArgNo() const
408
+ {
409
+ return argNo;
410
+ }
411
+
412
+ bool isArgOfUncalledFunction() const;
413
+
414
+ virtual bool isPointer() const;
415
+
416
+ virtual const std::string toString() const;
417
+ };
418
+
419
+
420
+ /*
421
+ * Gep Value (Pointer) variable, this variable can be dynamic generated for field sensitive analysis
422
+ * e.g. memcpy, temp gep value variable needs to be created
423
+ * Each Gep Value variable is connected to base value variable via gep edge
424
+ */
425
+ class GepValVar: public ValVar
426
+ {
427
+ friend class SVFIRWriter;
428
+ friend class SVFIRReader;
429
+
430
+ private:
431
+ AccessPath ap; // AccessPath
432
+ const ValVar* base; // base node
433
+ const SVFType* gepValType;
434
+
435
+ /// Constructor to create empty GeValVar (for SVFIRReader/deserialization)
436
+ GepValVar(NodeID i) : ValVar(i, GepValNode), gepValType{} {}
437
+
438
+ public:
439
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
440
+ //@{
441
+ static inline bool classof(const GepValVar *)
442
+ {
443
+ return true;
444
+ }
445
+ static inline bool classof(const ValVar * node)
446
+ {
447
+ return node->getNodeKind() == SVFVar::GepValNode;
448
+ }
449
+ static inline bool classof(const SVFVar *node)
450
+ {
451
+ return node->getNodeKind() == SVFVar::GepValNode;
452
+ }
453
+ static inline bool classof(const GenericPAGNodeTy *node)
454
+ {
455
+ return node->getNodeKind() == SVFVar::GepValNode;
456
+ }
457
+ static inline bool classof(const SVFValue* node)
458
+ {
459
+ return node->getNodeKind() == SVFVar::GepValNode;
460
+ }
461
+ //@}
462
+
463
+ /// Constructor
464
+ GepValVar(const ValVar* baseNode, NodeID i, const AccessPath& ap,
465
+ const SVFType* ty, const ICFGNode* node);
466
+
467
+ /// offset of the base value variable
468
+ inline APOffset getConstantFieldIdx() const
469
+ {
470
+ return ap.getConstantStructFldIdx();
471
+ }
472
+
473
+ /// Return the base object from which this GEP node came from.
474
+ inline const ValVar* getBaseNode(void) const
475
+ {
476
+ return base;
477
+ }
478
+
479
+ /// Return name of a LLVM value
480
+ inline const std::string getValueName() const
481
+ {
482
+ return getName() + "_" +
483
+ std::to_string(getConstantFieldIdx());
484
+ }
485
+
486
+ virtual bool isPointer() const
487
+ {
488
+ return base->isPointer();
489
+ }
490
+
491
+ inline const SVFType* getType() const
492
+ {
493
+ return gepValType;
494
+ }
495
+
496
+ virtual const FunObjVar* getFunction() const
497
+ {
498
+ return base->getFunction();
499
+ }
500
+
501
+ virtual const std::string toString() const;
502
+
503
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
504
+ {
505
+ return base->isConstDataOrAggDataButNotNullPtr();
506
+ }
507
+ virtual inline bool ptrInUncalledFunction() const
508
+ {
509
+ return base->ptrInUncalledFunction();
510
+ }
511
+
512
+ virtual inline bool isConstDataOrAggData() const
513
+ {
514
+ return base->isConstDataOrAggData();
515
+ }
516
+ };
517
+
518
+ /*
519
+ * Base memory object variable (address-taken variables in LLVM-based languages)
520
+ */
521
+ class BaseObjVar : public ObjVar
522
+ {
523
+ friend class SVFIRWriter;
524
+ friend class SVFIRReader;
525
+ friend class SVFIRBuilder;
526
+ private:
527
+ ObjTypeInfo* typeInfo;
528
+
529
+ const ICFGNode* icfgNode; /// ICFGNode related to the creation of this object
530
+
531
+ protected:
532
+ /// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
533
+ BaseObjVar(NodeID i, const ICFGNode* node, PNODEK ty = BaseObjNode) : ObjVar(i, ty), icfgNode(node) {}
534
+
535
+ public:
536
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
537
+ //@{
538
+ static inline bool classof(const BaseObjVar*)
539
+ {
540
+ return true;
541
+ }
542
+ static inline bool classof(const ObjVar* node)
543
+ {
544
+ return isBaseObjVarKinds(node->getNodeKind());
545
+ }
546
+ static inline bool classof(const SVFVar* node)
547
+ {
548
+ return isBaseObjVarKinds(node->getNodeKind());
549
+ }
550
+ static inline bool classof(const GenericPAGNodeTy* node)
551
+ {
552
+ return isBaseObjVarKinds(node->getNodeKind());
553
+ }
554
+ static inline bool classof(const SVFValue* node)
555
+ {
556
+ return isBaseObjVarKinds(node->getNodeKind());
557
+ }
558
+ //@}
559
+
560
+ /// Constructor
561
+ BaseObjVar(NodeID i, ObjTypeInfo* ti,
562
+ const SVFType* svfType, const ICFGNode* node, PNODEK ty = BaseObjNode)
563
+ : ObjVar(i, svfType, ty), typeInfo(ti), icfgNode(node)
564
+ {
565
+ }
566
+
567
+ virtual const BaseObjVar* getBaseMemObj() const
568
+ {
569
+ return this;
570
+ }
571
+
572
+ /// Get the ICFGNode related to the creation of this object
573
+ inline const ICFGNode* getICFGNode() const
574
+ {
575
+ return icfgNode;
576
+ }
577
+
578
+ /// Return name of a LLVM value
579
+ inline const std::string getValueName() const
580
+ {
581
+ return getName() + " (base object)";
582
+ }
583
+
584
+ virtual const std::string toString() const;
585
+
586
+ /// Get the memory object id
587
+ inline NodeID getId() const
588
+ {
589
+ return id;
590
+ }
591
+
592
+ /// Get obj type
593
+ const SVFType* getType() const
594
+ {
595
+ return typeInfo->getType();
596
+ }
597
+
598
+ /// Get the number of elements of this object
599
+ u32_t getNumOfElements() const
600
+ {
601
+ return typeInfo->getNumOfElements();
602
+ }
603
+
604
+ /// Set the number of elements of this object
605
+ void setNumOfElements(u32_t num)
606
+ {
607
+ return typeInfo->setNumOfElements(num);
608
+ }
609
+
610
+ /// Get max field offset limit
611
+ u32_t getMaxFieldOffsetLimit() const
612
+ {
613
+ return typeInfo->getMaxFieldOffsetLimit();
614
+ }
615
+
616
+
617
+ /// Return true if its field limit is 0
618
+ bool isFieldInsensitive() const
619
+ {
620
+ return getMaxFieldOffsetLimit() == 0;
621
+ }
622
+
623
+ /// Set the memory object to be field insensitive
624
+ void setFieldInsensitive()
625
+ {
626
+ typeInfo->setMaxFieldOffsetLimit(0);
627
+ }
628
+
629
+
630
+ /// Set the memory object to be field sensitive (up to max field limit)
631
+ void setFieldSensitive()
632
+ {
633
+ typeInfo->setMaxFieldOffsetLimit(typeInfo->getNumOfElements());
634
+ }
635
+
636
+ /// Whether it is a black hole object
637
+ bool isBlackHoleObj() const;
638
+
639
+ /// Get the byte size of this object
640
+ u32_t getByteSizeOfObj() const
641
+ {
642
+ return typeInfo->getByteSizeOfObj();
643
+ }
644
+
645
+ /// Check if byte size is a const value
646
+ bool isConstantByteSize() const
647
+ {
648
+ return typeInfo->isConstantByteSize();
649
+ }
650
+
651
+
652
+ /// object attributes methods
653
+ //@{
654
+ bool isFunction() const
655
+ {
656
+ return typeInfo->isFunction();
657
+ }
658
+ bool isGlobalObj() const
659
+ {
660
+ return typeInfo->isGlobalObj();
661
+ }
662
+ bool isStaticObj() const
663
+ {
664
+ return typeInfo->isStaticObj();
665
+ }
666
+ bool isStack() const
667
+ {
668
+ return typeInfo->isStack();
669
+ }
670
+ bool isHeap() const
671
+ {
672
+ return typeInfo->isHeap();
673
+ }
674
+ bool isStruct() const
675
+ {
676
+ return typeInfo->isStruct();
677
+ }
678
+ bool isArray() const
679
+ {
680
+ return typeInfo->isArray();
681
+ }
682
+ bool isVarStruct() const
683
+ {
684
+ return typeInfo->isVarStruct();
685
+ }
686
+ bool isVarArray() const
687
+ {
688
+ return typeInfo->isVarArray();
689
+ }
690
+ bool isConstantStruct() const
691
+ {
692
+ return typeInfo->isConstantStruct();
693
+ }
694
+ bool isConstantArray() const
695
+ {
696
+ return typeInfo->isConstantArray();
697
+ }
698
+ bool isConstDataOrConstGlobal() const
699
+ {
700
+ return typeInfo->isConstDataOrConstGlobal();
701
+ }
702
+ virtual inline bool isConstDataOrAggData() const
703
+ {
704
+ return typeInfo->isConstDataOrAggData();
705
+ }
706
+ //@}
707
+
708
+ /// Clean up memory
709
+ void destroy()
710
+ {
711
+ delete typeInfo;
712
+ typeInfo = nullptr;
713
+ }
714
+
715
+ virtual const FunObjVar* getFunction() const;
716
+
717
+ };
718
+
719
+
720
+ /*
721
+ * Gep Obj variable, this is dynamic generated for field sensitive analysis
722
+ * Each gep obj variable is one field of a BaseObjVar (base)
723
+ */
724
+ class GepObjVar: public ObjVar
725
+ {
726
+ friend class SVFIRWriter;
727
+ friend class SVFIRReader;
728
+
729
+ private:
730
+ APOffset apOffset = 0;
731
+
732
+ const BaseObjVar* base;
733
+
734
+ /// Constructor to create empty GepObjVar (for SVFIRReader/deserialization)
735
+ // only for reading from file when we don't have BaseObjVar*
736
+ GepObjVar(NodeID i, PNODEK ty = GepObjNode) : ObjVar(i, ty), base{} {}
737
+
738
+ public:
739
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
740
+ //@{
741
+ static inline bool classof(const GepObjVar*)
742
+ {
743
+ return true;
744
+ }
745
+ static inline bool classof(const ObjVar* node)
746
+ {
747
+ return node->getNodeKind() == SVFVar::GepObjNode;
748
+ }
749
+ static inline bool classof(const SVFVar* node)
750
+ {
751
+ return node->getNodeKind() == SVFVar::GepObjNode;
752
+ }
753
+ static inline bool classof(const GenericPAGNodeTy* node)
754
+ {
755
+ return node->getNodeKind() == SVFVar::GepObjNode;
756
+ }
757
+ static inline bool classof(const SVFValue* node)
758
+ {
759
+ return node->getNodeKind() == SVFVar::GepObjNode;
760
+ }
761
+ //@}
762
+
763
+ /// Constructor
764
+ GepObjVar(const BaseObjVar* baseObj, NodeID i,
765
+ const APOffset& apOffset, PNODEK ty = GepObjNode)
766
+ : ObjVar(i, baseObj->getType(), ty), apOffset(apOffset), base(baseObj)
767
+ {
768
+ }
769
+
770
+ /// offset of the mem object
771
+ inline APOffset getConstantFieldIdx() const
772
+ {
773
+ return apOffset;
774
+ }
775
+
776
+ /// Return the base object from which this GEP node came from.
777
+ inline NodeID getBaseNode(void) const
778
+ {
779
+ return base->getId();
780
+ }
781
+
782
+ inline const BaseObjVar* getBaseObj() const
783
+ {
784
+ return base;
785
+ }
786
+
787
+ /// Return the type of this gep object
788
+ inline virtual const SVFType* getType() const;
789
+
790
+
791
+ /// Return name of a LLVM value
792
+ inline const std::string getValueName() const
793
+ {
794
+ return getName() + "_" + std::to_string(apOffset);
795
+ }
796
+
797
+ virtual const FunObjVar* getFunction() const
798
+ {
799
+ return base->getFunction();
800
+ }
801
+
802
+ virtual const std::string toString() const;
803
+
804
+ virtual inline bool ptrInUncalledFunction() const
805
+ {
806
+ return base->ptrInUncalledFunction();
807
+ }
808
+
809
+ virtual inline bool isConstDataOrAggData() const
810
+ {
811
+ return base->isConstDataOrAggData();
812
+ }
813
+
814
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
815
+ {
816
+ return base->isConstDataOrAggDataButNotNullPtr();
817
+ }
818
+
819
+ virtual bool isPointer() const
820
+ {
821
+ return base->isPointer();
822
+ }
823
+ };
824
+
825
+
826
+
827
+ /**
828
+ * @brief Class representing a heap object variable in the SVFIR
829
+ *
830
+ * This class models heap-allocated objects in the program analysis. It extends BaseObjVar
831
+ * to specifically handle heap memory locations.
832
+ */
833
+ class HeapObjVar: public BaseObjVar
834
+ {
835
+
836
+ friend class SVFIRWriter;
837
+ friend class SVFIRReader;
838
+
839
+ protected:
840
+ /// Constructor to create heap object var
841
+ HeapObjVar(NodeID i, const ICFGNode* node) : BaseObjVar(i, node, HeapObjNode) {}
842
+
843
+ public:
844
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
845
+ //@{
846
+ static inline bool classof(const HeapObjVar*)
847
+ {
848
+ return true;
849
+ }
850
+ static inline bool classof(const BaseObjVar* node)
851
+ {
852
+ return node->getNodeKind() == HeapObjNode;
853
+ }
854
+ static inline bool classof(const ObjVar* node)
855
+ {
856
+ return node->getNodeKind() == HeapObjNode;
857
+ }
858
+ static inline bool classof(const SVFVar* node)
859
+ {
860
+ return node->getNodeKind() == HeapObjNode;
861
+ }
862
+ static inline bool classof(const GenericPAGNodeTy* node)
863
+ {
864
+ return node->getNodeKind() == HeapObjNode;
865
+ }
866
+ static inline bool classof(const SVFValue* node)
867
+ {
868
+ return node->getNodeKind() == HeapObjNode;
869
+ }
870
+ //@}
871
+
872
+ /// Constructor
873
+ HeapObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node):
874
+ BaseObjVar(i, ti, svfType, node, HeapObjNode)
875
+ {
876
+ }
877
+
878
+ /// Return name of a LLVM value
879
+ inline const std::string getValueName() const
880
+ {
881
+ return " (heap base object)";
882
+ }
883
+
884
+ virtual const std::string toString() const;
885
+ };
886
+
887
+
888
+ /**
889
+ * @brief Represents a stack-allocated object variable in the SVFIR (SVF Intermediate Representation)
890
+ * @inherits BaseObjVar
891
+ *
892
+ * This class models variables that are allocated on the stack in the program.
893
+ * It provides type checking functionality through LLVM-style RTTI (Runtime Type Information)
894
+ * methods like classof.
895
+ */
896
+ class StackObjVar: public BaseObjVar
897
+ {
898
+
899
+ friend class SVFIRWriter;
900
+ friend class SVFIRReader;
901
+
902
+ protected:
903
+ /// Constructor to create stack object var
904
+ StackObjVar(NodeID i, const ICFGNode* node) : BaseObjVar(i, node, StackObjNode) {}
905
+
906
+ public:
907
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
908
+ //@{
909
+ static inline bool classof(const StackObjVar*)
910
+ {
911
+ return true;
912
+ }
913
+ static inline bool classof(const BaseObjVar* node)
914
+ {
915
+ return node->getNodeKind() == StackObjNode;
916
+ }
917
+ static inline bool classof(const ObjVar* node)
918
+ {
919
+ return node->getNodeKind() == StackObjNode;
920
+ }
921
+ static inline bool classof(const SVFVar* node)
922
+ {
923
+ return node->getNodeKind() == StackObjNode;
924
+ }
925
+ static inline bool classof(const GenericPAGNodeTy* node)
926
+ {
927
+ return node->getNodeKind() == StackObjNode;
928
+ }
929
+ static inline bool classof(const SVFValue* node)
930
+ {
931
+ return node->getNodeKind() == StackObjNode;
932
+ }
933
+ //@}
934
+
935
+ /// Constructor
936
+ StackObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node):
937
+ BaseObjVar(i, ti, svfType, node, StackObjNode)
938
+ {
939
+ }
940
+
941
+ /// Return name of a LLVM value
942
+ inline const std::string getValueName() const
943
+ {
944
+ return " (stack base object)";
945
+ }
946
+
947
+ virtual const std::string toString() const;
948
+ };
949
+
950
+
951
+ class CallGraphNode;
952
+
953
+ class FunObjVar : public BaseObjVar
954
+ {
955
+ friend class SVFIRWriter;
956
+ friend class SVFIRReader;
957
+ friend class SVFIRBuilder;
958
+
959
+ public:
960
+ typedef SVFLoopAndDomInfo::BBSet BBSet;
961
+ typedef SVFLoopAndDomInfo::BBList BBList;
962
+ typedef SVFLoopAndDomInfo::LoopBBs LoopBBs;
963
+
964
+ typedef BasicBlockGraph::IDToNodeMapTy::const_iterator const_bb_iterator;
965
+
966
+
967
+ private:
968
+ bool isDecl; /// return true if this function does not have a body
969
+ bool intrinsic; /// return true if this function is an intrinsic function (e.g., llvm.dbg), which does not reside in the application code
970
+ bool isAddrTaken; /// return true if this function is address-taken (for indirect call purposes)
971
+ bool isUncalled; /// return true if this function is never called
972
+ bool isNotRet; /// return true if this function never returns
973
+ bool supVarArg; /// return true if this function supports variable arguments
974
+ const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVF Function
975
+ SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
976
+ const FunObjVar * realDefFun; /// the definition of a function across multiple modules
977
+ BasicBlockGraph* bbGraph; /// the basic block graph of this function
978
+ std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
979
+ SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
980
+
981
+
982
+ private:
983
+ /// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
984
+ FunObjVar(NodeID i, const ICFGNode* node) : BaseObjVar(i,node, FunObjNode) {}
985
+
986
+ public:
987
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
988
+ //@{
989
+ static inline bool classof(const FunObjVar*)
990
+ {
991
+ return true;
992
+ }
993
+ static inline bool classof(const BaseObjVar* node)
994
+ {
995
+ return node->getNodeKind() == FunObjNode;
996
+ }
997
+ static inline bool classof(const ObjVar* node)
998
+ {
999
+ return node->getNodeKind() == FunObjNode;
1000
+ }
1001
+ static inline bool classof(const SVFVar* node)
1002
+ {
1003
+ return node->getNodeKind() == FunObjNode;
1004
+ }
1005
+ static inline bool classof(const GenericPAGNodeTy* node)
1006
+ {
1007
+ return node->getNodeKind() == FunObjNode;
1008
+ }
1009
+ static inline bool classof(const SVFValue* node)
1010
+ {
1011
+ return node->getNodeKind() == FunObjNode;
1012
+ }
1013
+ //@}
1014
+
1015
+ /// Constructor
1016
+ FunObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node);
1017
+
1018
+ void initFunObjVar(bool decl, bool intrinc, bool addr, bool uncalled, bool notret, bool vararg, const SVFFunctionType *ft,
1019
+ SVFLoopAndDomInfo *ld, const FunObjVar *real, BasicBlockGraph *bbg,
1020
+ const std::vector<const ArgValVar *> &allarg, SVFBasicBlock *exit);
1021
+
1022
+ void setRelDefFun(const FunObjVar *real)
1023
+ {
1024
+ realDefFun = real;
1025
+ }
1026
+
1027
+ virtual const FunObjVar*getFunction() const;
1028
+
1029
+ inline void addArgument(const ArgValVar *arg)
1030
+ {
1031
+ allArgs.push_back(arg);
1032
+ }
1033
+ inline bool isDeclaration() const
1034
+ {
1035
+ return isDecl;
1036
+ }
1037
+
1038
+ inline bool isIntrinsic() const
1039
+ {
1040
+ return intrinsic;
1041
+ }
1042
+
1043
+ inline bool hasAddressTaken() const
1044
+ {
1045
+ return isAddrTaken;
1046
+ }
1047
+
1048
+ inline bool isVarArg() const
1049
+ {
1050
+ return supVarArg;
1051
+ }
1052
+
1053
+ inline bool isUncalledFunction() const
1054
+ {
1055
+ return isUncalled;
1056
+ }
1057
+
1058
+ inline bool hasReturn() const
1059
+ {
1060
+ return !isNotRet;
1061
+ }
1062
+
1063
+ /// Returns the FunctionType
1064
+ inline const SVFFunctionType* getFunctionType() const
1065
+ {
1066
+ return funcType;
1067
+ }
1068
+
1069
+ /// Returns the FunctionType
1070
+ inline const SVFType* getReturnType() const
1071
+ {
1072
+ return funcType->getReturnType();
1073
+ }
1074
+
1075
+ inline SVFLoopAndDomInfo* getLoopAndDomInfo()
1076
+ {
1077
+ return loopAndDom;
1078
+ }
1079
+
1080
+ inline const std::vector<const SVFBasicBlock*>& getReachableBBs() const
1081
+ {
1082
+ return loopAndDom->getReachableBBs();
1083
+ }
1084
+
1085
+ inline void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const
1086
+ {
1087
+ return loopAndDom->getExitBlocksOfLoop(bb,exitbbs);
1088
+ }
1089
+
1090
+ inline bool hasLoopInfo(const SVFBasicBlock* bb) const
1091
+ {
1092
+ return loopAndDom->hasLoopInfo(bb);
1093
+ }
1094
+
1095
+ const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const
1096
+ {
1097
+ return loopAndDom->getLoopInfo(bb);
1098
+ }
1099
+
1100
+ inline const SVFBasicBlock* getLoopHeader(const BBList& lp) const
1101
+ {
1102
+ return loopAndDom->getLoopHeader(lp);
1103
+ }
1104
+
1105
+ inline bool loopContainsBB(const BBList& lp, const SVFBasicBlock* bb) const
1106
+ {
1107
+ return loopAndDom->loopContainsBB(lp,bb);
1108
+ }
1109
+
1110
+ inline const Map<const SVFBasicBlock*,BBSet>& getDomTreeMap() const
1111
+ {
1112
+ return loopAndDom->getDomTreeMap();
1113
+ }
1114
+
1115
+ inline const Map<const SVFBasicBlock*,BBSet>& getDomFrontierMap() const
1116
+ {
1117
+ return loopAndDom->getDomFrontierMap();
1118
+ }
1119
+
1120
+ inline bool isLoopHeader(const SVFBasicBlock* bb) const
1121
+ {
1122
+ return loopAndDom->isLoopHeader(bb);
1123
+ }
1124
+
1125
+ inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
1126
+ {
1127
+ return loopAndDom->dominate(bbKey,bbValue);
1128
+ }
1129
+
1130
+ inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
1131
+ {
1132
+ return loopAndDom->postDominate(bbKey,bbValue);
1133
+ }
1134
+
1135
+ inline const FunObjVar* getDefFunForMultipleModule() const
1136
+ {
1137
+ if(realDefFun==nullptr)
1138
+ return this;
1139
+ return realDefFun;
1140
+ }
1141
+
1142
+ void setBasicBlockGraph(BasicBlockGraph* graph)
1143
+ {
1144
+ this->bbGraph = graph;
1145
+ }
1146
+
1147
+ BasicBlockGraph* getBasicBlockGraph()
1148
+ {
1149
+ return bbGraph;
1150
+ }
1151
+
1152
+ const BasicBlockGraph* getBasicBlockGraph() const
1153
+ {
1154
+ return bbGraph;
1155
+ }
1156
+
1157
+ inline bool hasBasicBlock() const
1158
+ {
1159
+ return bbGraph && bbGraph->begin() != bbGraph->end();
1160
+ }
1161
+
1162
+ inline const SVFBasicBlock* getEntryBlock() const
1163
+ {
1164
+ assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
1165
+ assert(bbGraph->begin()->second->getInEdges().size() == 0 && "the first basic block is not entry block");
1166
+ return bbGraph->begin()->second;
1167
+ }
1168
+
1169
+ inline const SVFBasicBlock* getExitBB() const
1170
+ {
1171
+ assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
1172
+ assert(exitBlock && "must have an exitBlock");
1173
+ return exitBlock;
1174
+ }
1175
+
1176
+ inline void setExitBlock(SVFBasicBlock *bb)
1177
+ {
1178
+ assert(!exitBlock && "have already set exit Basicblock!");
1179
+ exitBlock = bb;
1180
+ }
1181
+
1182
+
1183
+ u32_t inline arg_size() const
1184
+ {
1185
+ return allArgs.size();
1186
+ }
1187
+
1188
+ inline const ArgValVar* getArg(u32_t idx) const
1189
+ {
1190
+ assert (idx < allArgs.size() && "getArg() out of range!");
1191
+ return allArgs[idx];
1192
+ }
1193
+
1194
+ inline const SVFBasicBlock* front() const
1195
+ {
1196
+ return getEntryBlock();
1197
+ }
1198
+
1199
+ inline const SVFBasicBlock* back() const
1200
+ {
1201
+ assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
1202
+ /// Carefully! 'back' is just the last basic block of function,
1203
+ /// but not necessarily a exit basic block
1204
+ /// more refer to: https://github.com/SVF-tools/SVF/pull/1262
1205
+ return std::prev(bbGraph->end())->second;
1206
+ }
1207
+
1208
+ inline const_bb_iterator begin() const
1209
+ {
1210
+ return bbGraph->begin();
1211
+ }
1212
+
1213
+ inline const_bb_iterator end() const
1214
+ {
1215
+ return bbGraph->end();
1216
+ }
1217
+
1218
+ virtual bool isIsolatedNode() const;
1219
+
1220
+ virtual const std::string toString() const;
1221
+ };
1222
+ class FunValVar : public ValVar
1223
+ {
1224
+ friend class SVFIRWriter;
1225
+ friend class SVFIRReader;
1226
+ private:
1227
+ const FunObjVar* funObjVar;
1228
+
1229
+ public:
1230
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1231
+ //@{
1232
+ static inline bool classof(const FunValVar*)
1233
+ {
1234
+ return true;
1235
+ }
1236
+ static inline bool classof(const ValVar* node)
1237
+ {
1238
+ return node->getNodeKind() == FunValNode;
1239
+ }
1240
+ static inline bool classof(const SVFVar* node)
1241
+ {
1242
+ return node->getNodeKind() == FunValNode;
1243
+ }
1244
+ static inline bool classof(const GenericPAGNodeTy* node)
1245
+ {
1246
+ return node->getNodeKind() == FunValNode;
1247
+ }
1248
+ static inline bool classof(const SVFValue* node)
1249
+ {
1250
+ return node->getNodeKind() == FunValNode;
1251
+ }
1252
+ //@}
1253
+
1254
+ inline virtual const FunObjVar* getFunction() const
1255
+ {
1256
+ return funObjVar->getFunction();
1257
+ }
1258
+
1259
+ /// Constructor
1260
+ FunValVar(NodeID i, const ICFGNode* icn, const FunObjVar* cgn, const SVFType* svfType);
1261
+
1262
+
1263
+ virtual bool isPointer() const
1264
+ {
1265
+ return true;
1266
+ }
1267
+
1268
+ virtual const std::string toString() const;
1269
+ };
1270
+
1271
+
1272
+
1273
+ class GlobalValVar : public ValVar
1274
+ {
1275
+ friend class SVFIRWriter;
1276
+ friend class SVFIRReader;
1277
+
1278
+ public:
1279
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1280
+ //@{
1281
+ static inline bool classof(const GlobalValVar*)
1282
+ {
1283
+ return true;
1284
+ }
1285
+ static inline bool classof(const ValVar* node)
1286
+ {
1287
+ return node->getNodeKind() == GlobalValNode;
1288
+ }
1289
+ static inline bool classof(const SVFVar* node)
1290
+ {
1291
+ return node->getNodeKind() == GlobalValNode;
1292
+ }
1293
+ static inline bool classof(const GenericPAGNodeTy* node)
1294
+ {
1295
+ return node->getNodeKind() == GlobalValNode;
1296
+ }
1297
+ static inline bool classof(const SVFValue* node)
1298
+ {
1299
+ return node->getNodeKind() == GlobalValNode;
1300
+ }
1301
+ //@}
1302
+
1303
+ /// Constructor
1304
+ GlobalValVar(NodeID i, const ICFGNode* icn, const SVFType* svfType)
1305
+ : ValVar(i, svfType, icn, GlobalValNode)
1306
+ {
1307
+ type = svfType;
1308
+ }
1309
+
1310
+
1311
+ virtual const std::string toString() const;
1312
+ };
1313
+
1314
+ class ConstAggValVar: public ValVar
1315
+ {
1316
+ friend class SVFIRWriter;
1317
+ friend class SVFIRReader;
1318
+
1319
+ public:
1320
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1321
+ //@{
1322
+ static inline bool classof(const ConstAggValVar*)
1323
+ {
1324
+ return true;
1325
+ }
1326
+ static inline bool classof(const ValVar* node)
1327
+ {
1328
+ return node->getNodeKind() == ConstAggValNode;
1329
+ }
1330
+ static inline bool classof(const SVFVar* node)
1331
+ {
1332
+ return node->getNodeKind() == ConstAggValNode;
1333
+ }
1334
+ static inline bool classof(const GenericPAGNodeTy* node)
1335
+ {
1336
+ return node->getNodeKind() == ConstAggValNode;
1337
+ }
1338
+ static inline bool classof(const SVFValue* node)
1339
+ {
1340
+ return node->getNodeKind() == ConstAggValNode;
1341
+ }
1342
+ //@}
1343
+
1344
+ /// Constructor
1345
+ ConstAggValVar(NodeID i, const ICFGNode* icn, const SVFType* svfTy)
1346
+ : ValVar(i, svfTy, icn, ConstAggValNode)
1347
+ {
1348
+ type = svfTy;
1349
+ }
1350
+
1351
+
1352
+ virtual bool isConstDataOrAggData() const
1353
+ {
1354
+ return true;
1355
+ }
1356
+
1357
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
1358
+ {
1359
+ return true;
1360
+ }
1361
+
1362
+ virtual const std::string toString() const;
1363
+ };
1364
+
1365
+
1366
+ class ConstDataValVar : public ValVar
1367
+ {
1368
+ friend class SVFIRWriter;
1369
+ friend class SVFIRReader;
1370
+
1371
+ public:
1372
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1373
+ //@{
1374
+ static inline bool classof(const ConstDataValVar*)
1375
+ {
1376
+ return true;
1377
+ }
1378
+ static inline bool classof(const ValVar* node)
1379
+ {
1380
+ return isConstantDataValVar(node->getNodeKind());
1381
+ }
1382
+ static inline bool classof(const SVFVar* node)
1383
+ {
1384
+ return isConstantDataValVar(node->getNodeKind());
1385
+ }
1386
+ static inline bool classof(const GenericPAGNodeTy* node)
1387
+ {
1388
+ return isConstantDataValVar(node->getNodeKind());
1389
+ }
1390
+ static inline bool classof(const SVFValue* node)
1391
+ {
1392
+ return isConstantDataValVar(node->getNodeKind());
1393
+ }
1394
+ //@}
1395
+
1396
+ /// Constructor
1397
+ ConstDataValVar(NodeID i, const ICFGNode* icn, const SVFType* svfType,
1398
+ PNODEK ty = ConstDataValNode)
1399
+ : ValVar(i, svfType, icn, ty)
1400
+ {
1401
+
1402
+ }
1403
+
1404
+ virtual bool isConstDataOrAggData() const
1405
+ {
1406
+ return true;
1407
+ }
1408
+
1409
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
1410
+ {
1411
+ return true;
1412
+ }
1413
+
1414
+ virtual const std::string toString() const;
1415
+ };
1416
+
1417
+ class BlackHoleValVar : public ConstDataValVar
1418
+ {
1419
+ friend class SVFIRWriter;
1420
+ friend class SVFIRReader;
1421
+
1422
+ public:
1423
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1424
+ //@{
1425
+ static inline bool classof(const BlackHoleValVar*)
1426
+ {
1427
+ return true;
1428
+ }
1429
+ static inline bool classof(const ConstDataValVar* node)
1430
+ {
1431
+ return node->getNodeKind() == BlackHoleValNode;
1432
+ }
1433
+ static inline bool classof(const ValVar* node)
1434
+ {
1435
+ return node->getNodeKind() == BlackHoleValNode;
1436
+ }
1437
+ static inline bool classof(const SVFVar* node)
1438
+ {
1439
+ return node->getNodeKind() == BlackHoleValNode;
1440
+ }
1441
+ static inline bool classof(const GenericPAGNodeTy* node)
1442
+ {
1443
+ return node->getNodeKind() == BlackHoleValNode;
1444
+ }
1445
+ static inline bool classof(const SVFValue* node)
1446
+ {
1447
+ return node->getNodeKind() == BlackHoleValNode;
1448
+ }
1449
+ //@}
1450
+
1451
+ /// Constructor
1452
+ BlackHoleValVar(NodeID i, const SVFType* svfType, PNODEK ty = BlackHoleValNode)
1453
+ : ConstDataValVar(i, nullptr, svfType, ty)
1454
+ {
1455
+
1456
+ }
1457
+
1458
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
1459
+ {
1460
+ return false;
1461
+ }
1462
+
1463
+ virtual const std::string toString() const
1464
+ {
1465
+ return "BlackHoleValVar";
1466
+ }
1467
+ };
1468
+
1469
+ class ConstFPValVar : public ConstDataValVar
1470
+ {
1471
+ friend class SVFIRWriter;
1472
+ friend class SVFIRReader;
1473
+ private:
1474
+ double dval;
1475
+
1476
+ public:
1477
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1478
+ //@{
1479
+ static inline bool classof(const ConstFPValVar*)
1480
+ {
1481
+ return true;
1482
+ }
1483
+ static inline bool classof(const ConstDataValVar* node)
1484
+ {
1485
+ return node->getNodeKind() == ConstFPValNode;
1486
+ }
1487
+ static inline bool classof(const ValVar* node)
1488
+ {
1489
+ return node->getNodeKind() == ConstFPValNode;
1490
+ }
1491
+ static inline bool classof(const SVFVar* node)
1492
+ {
1493
+ return node->getNodeKind() == ConstFPValNode;
1494
+ }
1495
+ static inline bool classof(const GenericPAGNodeTy* node)
1496
+ {
1497
+ return node->getNodeKind() == ConstFPValNode;
1498
+ }
1499
+ static inline bool classof(const SVFValue* node)
1500
+ {
1501
+ return node->getNodeKind() == ConstFPValNode;
1502
+ }
1503
+ //@}
1504
+
1505
+ inline double getFPValue() const
1506
+ {
1507
+ return dval;
1508
+ }
1509
+
1510
+ /// Constructor
1511
+ ConstFPValVar(NodeID i, double dv,
1512
+ const ICFGNode* icn, const SVFType* svfType)
1513
+ : ConstDataValVar(i, icn, svfType, ConstFPValNode), dval(dv)
1514
+ {
1515
+ }
1516
+
1517
+ virtual const std::string toString() const;
1518
+ };
1519
+
1520
+ class ConstIntValVar : public ConstDataValVar
1521
+ {
1522
+ friend class SVFIRWriter;
1523
+ friend class SVFIRReader;
1524
+ private:
1525
+ u64_t zval;
1526
+ s64_t sval;
1527
+
1528
+ public:
1529
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1530
+ //@{
1531
+ static inline bool classof(const ConstIntValVar*)
1532
+ {
1533
+ return true;
1534
+ }
1535
+ static inline bool classof(const ConstDataValVar* node)
1536
+ {
1537
+ return node->getNodeKind() == ConstIntValNode;
1538
+ }
1539
+ static inline bool classof(const ValVar* node)
1540
+ {
1541
+ return node->getNodeKind() == ConstIntValNode;
1542
+ }
1543
+ static inline bool classof(const SVFVar* node)
1544
+ {
1545
+ return node->getNodeKind() == ConstIntValNode;
1546
+ }
1547
+ static inline bool classof(const GenericPAGNodeTy* node)
1548
+ {
1549
+ return node->getNodeKind() == ConstIntValNode;
1550
+ }
1551
+ static inline bool classof(const SVFValue* node)
1552
+ {
1553
+ return node->getNodeKind() == ConstIntValNode;
1554
+ }
1555
+ //@}
1556
+
1557
+ s64_t getSExtValue() const
1558
+ {
1559
+ return sval;
1560
+ }
1561
+
1562
+
1563
+ u64_t getZExtValue() const
1564
+ {
1565
+ return zval;
1566
+ }
1567
+
1568
+ /// Constructor
1569
+ ConstIntValVar(NodeID i, s64_t sv, u64_t zv, const ICFGNode* icn, const SVFType* svfType)
1570
+ : ConstDataValVar(i, icn, svfType, ConstIntValNode), zval(zv), sval(sv)
1571
+ {
1572
+
1573
+ }
1574
+ virtual const std::string toString() const;
1575
+ };
1576
+
1577
+ class ConstNullPtrValVar : public ConstDataValVar
1578
+ {
1579
+ friend class SVFIRWriter;
1580
+ friend class SVFIRReader;
1581
+
1582
+ public:
1583
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1584
+ //@{
1585
+ static inline bool classof(const ConstNullPtrValVar*)
1586
+ {
1587
+ return true;
1588
+ }
1589
+ static inline bool classof(const ConstDataValVar* node)
1590
+ {
1591
+ return node->getNodeKind() == ConstNullptrValNode;
1592
+ }
1593
+ static inline bool classof(const ValVar* node)
1594
+ {
1595
+ return node->getNodeKind() == ConstNullptrValNode;
1596
+ }
1597
+ static inline bool classof(const SVFVar* node)
1598
+ {
1599
+ return node->getNodeKind() == ConstNullptrValNode;
1600
+ }
1601
+ static inline bool classof(const GenericPAGNodeTy* node)
1602
+ {
1603
+ return node->getNodeKind() == ConstNullptrValNode;
1604
+ }
1605
+ static inline bool classof(const SVFValue* node)
1606
+ {
1607
+ return node->getNodeKind() == ConstNullptrValNode;
1608
+ }
1609
+ //@}
1610
+
1611
+ /// Constructor
1612
+ ConstNullPtrValVar(NodeID i, const ICFGNode* icn, const SVFType* svfType)
1613
+ : ConstDataValVar(i, icn, svfType, ConstNullptrValNode)
1614
+ {
1615
+
1616
+ }
1617
+
1618
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
1619
+ {
1620
+ return false;
1621
+ }
1622
+
1623
+ virtual const std::string toString() const;
1624
+ };
1625
+
1626
+ class GlobalObjVar : public BaseObjVar
1627
+ {
1628
+ friend class SVFIRWriter;
1629
+ friend class SVFIRReader;
1630
+
1631
+ private:
1632
+ /// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
1633
+ GlobalObjVar(NodeID i, const ICFGNode* node) : BaseObjVar(i, node, GlobalObjNode) {}
1634
+
1635
+ public:
1636
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1637
+ //@{
1638
+ static inline bool classof(const GlobalObjVar*)
1639
+ {
1640
+ return true;
1641
+ }
1642
+ static inline bool classof(const BaseObjVar* node)
1643
+ {
1644
+ return node->getNodeKind() == GlobalObjNode;
1645
+ }
1646
+ static inline bool classof(const ObjVar* node)
1647
+ {
1648
+ return node->getNodeKind() == GlobalObjNode;
1649
+ }
1650
+ static inline bool classof(const SVFVar* node)
1651
+ {
1652
+ return node->getNodeKind() == GlobalObjNode;
1653
+ }
1654
+ static inline bool classof(const GenericPAGNodeTy* node)
1655
+ {
1656
+ return node->getNodeKind() == GlobalObjNode;
1657
+ }
1658
+ static inline bool classof(const SVFValue* node)
1659
+ {
1660
+ return node->getNodeKind() == GlobalObjNode;
1661
+ }
1662
+ //@}
1663
+
1664
+ /// Constructor
1665
+ GlobalObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node,
1666
+ PNODEK ty = GlobalObjNode): BaseObjVar(i, ti, svfType, node, ty)
1667
+ {
1668
+
1669
+ }
1670
+
1671
+
1672
+ virtual const std::string toString() const;
1673
+ };
1674
+
1675
+ class ConstAggObjVar : public BaseObjVar
1676
+ {
1677
+ friend class SVFIRWriter;
1678
+ friend class SVFIRReader;
1679
+
1680
+ public:
1681
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
1682
+ //@{
1683
+ static inline bool classof(const ConstAggObjVar*)
1684
+ {
1685
+ return true;
1686
+ }
1687
+ static inline bool classof(const BaseObjVar* node)
1688
+ {
1689
+ return node->getNodeKind() == ConstAggObjNode;
1690
+ }
1691
+
1692
+ static inline bool classof(const ObjVar* node)
1693
+ {
1694
+ return node->getNodeKind() == ConstAggObjNode;
1695
+ }
1696
+ static inline bool classof(const SVFVar* node)
1697
+ {
1698
+ return node->getNodeKind() == ConstAggObjNode;
1699
+ }
1700
+ static inline bool classof(const GenericPAGNodeTy* node)
1701
+ {
1702
+ return node->getNodeKind() == ConstAggObjNode;
1703
+ }
1704
+ static inline bool classof(const SVFValue* node)
1705
+ {
1706
+ return node->getNodeKind() == ConstAggObjNode;
1707
+ }
1708
+ //@}
1709
+
1710
+ /// Constructor
1711
+ ConstAggObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node)
1712
+ : BaseObjVar(i, ti, svfType, node, ConstAggObjNode)
1713
+ {
1714
+
1715
+ }
1716
+
1717
+ virtual bool isConstDataOrAggData() const
1718
+ {
1719
+ return true;
1720
+ }
1721
+
1722
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
1723
+ {
1724
+ return true;
1725
+ }
1726
+
1727
+ virtual const std::string toString() const;
1728
+ };
1729
+
1730
+ class ConstDataObjVar : public BaseObjVar
1731
+ {
1732
+ friend class SVFIRWriter;
1733
+ friend class SVFIRReader;
1734
+
1735
+ protected:
1736
+ /// Constructor to create empty DummyObjVar (for SVFIRReader/deserialization)
1737
+ ConstDataObjVar(NodeID i, const ICFGNode* node) : BaseObjVar(i, node, ConstDataObjNode) {}
1738
+
1739
+ public:
1740
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
1741
+ static inline bool classof(const ConstDataObjVar*)
1742
+ {
1743
+ return true;
1744
+ }
1745
+ static inline bool classof(const BaseObjVar* node)
1746
+ {
1747
+ return isConstantDataObjVarKinds(node->getNodeKind());
1748
+ }
1749
+ static inline bool classof(const SVFVar* node)
1750
+ {
1751
+ return isConstantDataObjVarKinds(node->getNodeKind());
1752
+ }
1753
+ static inline bool classof(const ObjVar* node)
1754
+ {
1755
+ return isConstantDataObjVarKinds(node->getNodeKind());
1756
+ }
1757
+ static inline bool classof(const GenericPAGNodeTy* node)
1758
+ {
1759
+ return isConstantDataObjVarKinds(node->getNodeKind());
1760
+ }
1761
+
1762
+ static inline bool classof(const SVFValue* node)
1763
+ {
1764
+ return isConstantDataObjVarKinds(node->getNodeKind());
1765
+ }
1766
+ //@}
1767
+
1768
+ /// Constructor
1769
+ ConstDataObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node, PNODEK ty = ConstDataObjNode)
1770
+ : BaseObjVar(i, ti, svfType, node, ty)
1771
+ {
1772
+ }
1773
+
1774
+ virtual bool isConstDataOrAggData() const
1775
+ {
1776
+ return true;
1777
+ }
1778
+
1779
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
1780
+ {
1781
+ return true;
1782
+ }
1783
+
1784
+ virtual const std::string toString() const;
1785
+ };
1786
+
1787
+ class ConstFPObjVar : public ConstDataObjVar
1788
+ {
1789
+ friend class SVFIRWriter;
1790
+ friend class SVFIRReader;
1791
+
1792
+ private:
1793
+ /// Constructor to create empty DummyObjVar (for SVFIRReader/deserialization)
1794
+ ConstFPObjVar(NodeID i, const ICFGNode* node) : ConstDataObjVar(i, node) {}
1795
+
1796
+ private:
1797
+ float dval;
1798
+
1799
+ public:
1800
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
1801
+ static inline bool classof(const ConstFPObjVar*)
1802
+ {
1803
+ return true;
1804
+ }
1805
+ static inline bool classof(const ConstDataObjVar* node)
1806
+ {
1807
+ return node->getNodeKind() == SVFVar::ConstFPObjNode;
1808
+ }
1809
+ static inline bool classof(const BaseObjVar* node)
1810
+ {
1811
+ return node->getNodeKind() == SVFVar::ConstFPObjNode;
1812
+ }
1813
+
1814
+ static inline bool classof(const SVFVar* node)
1815
+ {
1816
+ return node->getNodeKind() == SVFVar::ConstFPObjNode;
1817
+ }
1818
+
1819
+ static inline bool classof(const ObjVar* node)
1820
+ {
1821
+ return node->getNodeKind() == SVFVar::ConstFPObjNode;
1822
+ }
1823
+
1824
+ static inline bool classof(const GenericPAGNodeTy* node)
1825
+ {
1826
+ return node->getNodeKind() == SVFVar::ConstFPObjNode;
1827
+ }
1828
+
1829
+ static inline bool classof(const SVFValue* node)
1830
+ {
1831
+ return node->getNodeKind() == SVFVar::ConstFPObjNode;
1832
+ }
1833
+ //@}
1834
+
1835
+ /// Constructor
1836
+ ConstFPObjVar(NodeID i, double dv, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node)
1837
+ : ConstDataObjVar(i, ti, svfType, node, ConstFPObjNode), dval(dv)
1838
+ {
1839
+ }
1840
+
1841
+ inline double getFPValue() const
1842
+ {
1843
+ return dval;
1844
+ }
1845
+
1846
+
1847
+ virtual const std::string toString() const;
1848
+ };
1849
+
1850
+ class ConstIntObjVar : public ConstDataObjVar
1851
+ {
1852
+ friend class SVFIRWriter;
1853
+ friend class SVFIRReader;
1854
+
1855
+ private:
1856
+ /// Constructor to create empty DummyObjVar (for SVFIRReader/deserialization)
1857
+ ConstIntObjVar(NodeID i, const ICFGNode* node) : ConstDataObjVar(i, node) {}
1858
+
1859
+ private:
1860
+ u64_t zval;
1861
+ s64_t sval;
1862
+
1863
+ public:
1864
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
1865
+ static inline bool classof(const ConstIntObjVar*)
1866
+ {
1867
+ return true;
1868
+ }
1869
+
1870
+ static inline bool classof(const ConstDataObjVar* node)
1871
+ {
1872
+ return node->getNodeKind() == SVFVar::ConstIntObjNode;
1873
+ }
1874
+
1875
+ static inline bool classof(const BaseObjVar* node)
1876
+ {
1877
+ return node->getNodeKind() == SVFVar::ConstIntObjNode;
1878
+ }
1879
+
1880
+ static inline bool classof(const SVFVar* node)
1881
+ {
1882
+ return node->getNodeKind() == SVFVar::ConstIntObjNode;
1883
+ }
1884
+ static inline bool classof(const ObjVar* node)
1885
+ {
1886
+ return node->getNodeKind() == SVFVar::ConstIntObjNode;
1887
+ }
1888
+ static inline bool classof(const GenericPAGNodeTy* node)
1889
+ {
1890
+ return node->getNodeKind() == SVFVar::ConstIntObjNode;
1891
+ }
1892
+
1893
+ static inline bool classof(const SVFValue* node)
1894
+ {
1895
+ return node->getNodeKind() == SVFVar::ConstIntObjNode;
1896
+ }
1897
+
1898
+ s64_t getSExtValue() const
1899
+ {
1900
+ return sval;
1901
+ }
1902
+
1903
+
1904
+ u64_t getZExtValue() const
1905
+ {
1906
+ return zval;
1907
+ }
1908
+ //@}
1909
+
1910
+ /// Constructor
1911
+ ConstIntObjVar(NodeID i, s64_t sv, u64_t zv, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node)
1912
+ : ConstDataObjVar(i, ti, svfType, node, ConstIntObjNode), zval(zv), sval(sv)
1913
+ {
1914
+ }
1915
+
1916
+
1917
+ virtual const std::string toString() const;
1918
+ };
1919
+
1920
+ class ConstNullPtrObjVar : public ConstDataObjVar
1921
+ {
1922
+ friend class SVFIRWriter;
1923
+ friend class SVFIRReader;
1924
+
1925
+ private:
1926
+ /// Constructor to create empty DummyObjVar (for SVFIRReader/deserialization)
1927
+ ConstNullPtrObjVar(NodeID i, const ICFGNode* node) : ConstDataObjVar(i, node) {}
1928
+
1929
+ public:
1930
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
1931
+ static inline bool classof(const ConstNullPtrObjVar*)
1932
+ {
1933
+ return true;
1934
+ }
1935
+
1936
+ static inline bool classof(const ConstDataObjVar* node)
1937
+ {
1938
+ return node->getNodeKind() == SVFVar::ConstNullptrObjNode;
1939
+ }
1940
+
1941
+ static inline bool classof(const BaseObjVar* node)
1942
+ {
1943
+ return node->getNodeKind() == SVFVar::ConstNullptrObjNode;
1944
+ }
1945
+
1946
+ static inline bool classof(const SVFVar* node)
1947
+ {
1948
+ return node->getNodeKind() == SVFVar::ConstNullptrObjNode;
1949
+ }
1950
+ static inline bool classof(const ObjVar* node)
1951
+ {
1952
+ return node->getNodeKind() == SVFVar::ConstNullptrObjNode;
1953
+ }
1954
+ static inline bool classof(const GenericPAGNodeTy* node)
1955
+ {
1956
+ return node->getNodeKind() == SVFVar::ConstNullptrObjNode;
1957
+ }
1958
+
1959
+ static inline bool classof(const SVFValue* node)
1960
+ {
1961
+ return node->getNodeKind() == SVFVar::ConstNullptrObjNode;
1962
+ }
1963
+ //@}
1964
+
1965
+ /// Constructor
1966
+ ConstNullPtrObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node)
1967
+ : ConstDataObjVar(i, ti, svfType, node, ConstNullptrObjNode)
1968
+ {
1969
+ }
1970
+ virtual bool isConstDataOrAggDataButNotNullPtr() const
1971
+ {
1972
+ return false;
1973
+ }
1974
+ virtual const std::string toString() const;
1975
+ };
1976
+ /*
1977
+ * Unique Return node of a procedure
1978
+ */
1979
+ class RetValPN : public ValVar
1980
+ {
1981
+ friend class SVFIRWriter;
1982
+ friend class SVFIRReader;
1983
+
1984
+ private:
1985
+ const FunObjVar* callGraphNode;
1986
+ private:
1987
+ /// Constructor to create empty RetValPN (for SVFIRReader/deserialization)
1988
+ RetValPN(NodeID i) : ValVar(i, RetValNode) {}
1989
+
1990
+ public:
1991
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
1992
+ static inline bool classof(const RetValPN*)
1993
+ {
1994
+ return true;
1995
+ }
1996
+ static inline bool classof(const SVFVar* node)
1997
+ {
1998
+ return node->getNodeKind() == SVFVar::RetValNode;
1999
+ }
2000
+ static inline bool classof(const ValVar* node)
2001
+ {
2002
+ return node->getNodeKind() == SVFVar::RetValNode;
2003
+ }
2004
+ static inline bool classof(const GenericPAGNodeTy* node)
2005
+ {
2006
+ return node->getNodeKind() == SVFVar::RetValNode;
2007
+ }
2008
+ static inline bool classof(const SVFValue* node)
2009
+ {
2010
+ return node->getNodeKind() == SVFVar::RetValNode;
2011
+ }
2012
+ //@}
2013
+
2014
+
2015
+ /// Constructor
2016
+ RetValPN(NodeID i, const FunObjVar* node, const SVFType* svfType, const ICFGNode* icn);
2017
+
2018
+ inline const FunObjVar* getCallGraphNode() const
2019
+ {
2020
+ return callGraphNode;
2021
+ }
2022
+
2023
+ virtual const FunObjVar* getFunction() const;
2024
+
2025
+ virtual bool isPointer() const;
2026
+
2027
+ /// Return name of a LLVM value
2028
+ const std::string getValueName() const;
2029
+
2030
+ virtual const std::string toString() const;
2031
+ };
2032
+
2033
+ /*
2034
+ * Unique vararg node of a procedure
2035
+ */
2036
+ class VarArgValPN : public ValVar
2037
+ {
2038
+ friend class SVFIRWriter;
2039
+ friend class SVFIRReader;
2040
+ private:
2041
+ const FunObjVar* callGraphNode;
2042
+
2043
+ private:
2044
+ /// Constructor to create empty VarArgValPN (for SVFIRReader/deserialization)
2045
+ VarArgValPN(NodeID i) : ValVar(i, VarargValNode) {}
2046
+
2047
+ public:
2048
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
2049
+ static inline bool classof(const VarArgValPN*)
2050
+ {
2051
+ return true;
2052
+ }
2053
+ static inline bool classof(const SVFVar* node)
2054
+ {
2055
+ return node->getNodeKind() == SVFVar::VarargValNode;
2056
+ }
2057
+ static inline bool classof(const ValVar* node)
2058
+ {
2059
+ return node->getNodeKind() == SVFVar::VarargValNode;
2060
+ }
2061
+ static inline bool classof(const GenericPAGNodeTy* node)
2062
+ {
2063
+ return node->getNodeKind() == SVFVar::VarargValNode;
2064
+ }
2065
+ static inline bool classof(const SVFValue* node)
2066
+ {
2067
+ return node->getNodeKind() == SVFVar::VarargValNode;
2068
+ }
2069
+ //@}
2070
+
2071
+ /// Constructor
2072
+ VarArgValPN(NodeID i, const FunObjVar* node, const SVFType* svfType, const ICFGNode* icn)
2073
+ : ValVar(i, svfType, icn, VarargValNode), callGraphNode(node)
2074
+ {
2075
+ }
2076
+
2077
+ virtual const FunObjVar* getFunction() const;
2078
+
2079
+ /// Return name of a LLVM value
2080
+ const std::string getValueName() const;
2081
+
2082
+ virtual bool isPointer() const
2083
+ {
2084
+ return true;
2085
+ }
2086
+ virtual const std::string toString() const;
2087
+ };
2088
+
2089
+ /*
2090
+ * Dummy variable without any LLVM value
2091
+ */
2092
+ class DummyValVar: public ValVar
2093
+ {
2094
+ friend class SVFIRWriter;
2095
+ friend class SVFIRReader;
2096
+
2097
+ public:
2098
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
2099
+ static inline bool classof(const DummyValVar*)
2100
+ {
2101
+ return true;
2102
+ }
2103
+ static inline bool classof(const SVFVar* node)
2104
+ {
2105
+ return node->getNodeKind() == SVFVar::DummyValNode;
2106
+ }
2107
+ static inline bool classof(const ValVar* node)
2108
+ {
2109
+ return node->getNodeKind() == SVFVar::DummyValNode;
2110
+ }
2111
+ static inline bool classof(const GenericPAGNodeTy* node)
2112
+ {
2113
+ return node->getNodeKind() == SVFVar::DummyValNode;
2114
+ }
2115
+ static inline bool classof(const SVFValue* node)
2116
+ {
2117
+ return node->getNodeKind() == SVFVar::DummyValNode;
2118
+ }
2119
+ //@}
2120
+
2121
+ /// Constructor
2122
+ DummyValVar(NodeID i, const ICFGNode* node, const SVFType* svfType = SVFType::getSVFPtrType())
2123
+ : ValVar(i, svfType, node, DummyValNode)
2124
+ {
2125
+ }
2126
+
2127
+ /// Return name of this node
2128
+ inline const std::string getValueName() const
2129
+ {
2130
+ return "dummyVal";
2131
+ }
2132
+
2133
+ virtual bool isPointer() const
2134
+ {
2135
+ return true;
2136
+ }
2137
+
2138
+ virtual const std::string toString() const;
2139
+ };
2140
+
2141
+ /*
2142
+ * Dummy object variable
2143
+ */
2144
+ class DummyObjVar: public BaseObjVar
2145
+ {
2146
+ friend class SVFIRWriter;
2147
+ friend class SVFIRReader;
2148
+
2149
+ private:
2150
+ /// Constructor to create empty DummyObjVar (for SVFIRReader/deserialization)
2151
+ DummyObjVar(NodeID i, const ICFGNode* node) : BaseObjVar(i, node, DummyObjNode) {}
2152
+
2153
+ public:
2154
+ //@{ Methods for support type inquiry through isa, cast, and dyn_cast:
2155
+ static inline bool classof(const DummyObjVar*)
2156
+ {
2157
+ return true;
2158
+ }
2159
+ static inline bool classof(const BaseObjVar* node)
2160
+ {
2161
+ return node->getNodeKind() == SVFVar::DummyObjNode;
2162
+ }
2163
+ static inline bool classof(const SVFVar* node)
2164
+ {
2165
+ return node->getNodeKind() == SVFVar::DummyObjNode;
2166
+ }
2167
+ static inline bool classof(const ObjVar* node)
2168
+ {
2169
+ return node->getNodeKind() == SVFVar::DummyObjNode;
2170
+ }
2171
+ static inline bool classof(const GenericPAGNodeTy* node)
2172
+ {
2173
+ return node->getNodeKind() == SVFVar::DummyObjNode;
2174
+ }
2175
+
2176
+ static inline bool classof(const SVFValue* node)
2177
+ {
2178
+ return node->getNodeKind() == SVFVar::DummyObjNode;
2179
+ }
2180
+ //@}
2181
+
2182
+ /// Constructor
2183
+ DummyObjVar(NodeID i, ObjTypeInfo* ti, const ICFGNode* node, const SVFType* svfType = SVFType::getSVFPtrType())
2184
+ : BaseObjVar(i, ti, svfType, node, DummyObjNode)
2185
+ {
2186
+ }
2187
+
2188
+ /// Return name of this node
2189
+ inline const std::string getValueName() const
2190
+ {
2191
+ return "dummyObj";
2192
+ }
2193
+
2194
+ virtual bool isPointer() const
2195
+ {
2196
+ return true;
2197
+ }
2198
+
2199
+ virtual const std::string toString() const;
2200
+ };
2201
+
2202
+ } // End namespace SVF
2203
+
2204
+ #endif /* INCLUDE_SVFIR_SVFVARIABLE_H_ */