svf-tools 1.0.979 → 1.0.981

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/svf/include/AE/Core/AbstractState.h +10 -8
  3. package/svf/include/AE/Svfexe/AEDetector.h +322 -0
  4. package/svf/include/AE/Svfexe/AbstractInterpretation.h +30 -66
  5. package/svf/include/Graphs/ICFG.h +9 -0
  6. package/svf/include/MSSA/MemRegion.h +2 -2
  7. package/svf/include/MTA/MHP.h +1 -2
  8. package/svf/include/SVFIR/SVFIR.h +1 -1
  9. package/svf/include/SVFIR/SVFStatements.h +1 -1
  10. package/svf/include/SVFIR/SVFValue.h +21 -16
  11. package/svf/include/Util/SVFUtil.h +19 -17
  12. package/svf/lib/AE/Core/AbstractState.cpp +56 -0
  13. package/svf/lib/AE/Svfexe/AEDetector.cpp +435 -0
  14. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +410 -399
  15. package/svf/lib/Graphs/ICFG.cpp +41 -10
  16. package/svf/lib/Graphs/SVFG.cpp +7 -3
  17. package/svf/lib/Graphs/SVFGReadWrite.cpp +2 -2
  18. package/svf/lib/MSSA/MemRegion.cpp +13 -13
  19. package/svf/lib/MSSA/MemSSA.cpp +10 -18
  20. package/svf/lib/MTA/LockAnalysis.cpp +12 -13
  21. package/svf/lib/MTA/MHP.cpp +26 -28
  22. package/svf/lib/MTA/MTA.cpp +2 -2
  23. package/svf/lib/MTA/MTAStat.cpp +2 -4
  24. package/svf/lib/SABER/SaberCondAllocator.cpp +6 -7
  25. package/svf/lib/SVFIR/SVFFileSystem.cpp +0 -2
  26. package/svf/lib/SVFIR/SVFIR.cpp +1 -1
  27. package/svf/lib/SVFIR/SVFStatements.cpp +1 -1
  28. package/svf/lib/SVFIR/SVFValue.cpp +1 -10
  29. package/svf/lib/Util/CDGBuilder.cpp +6 -9
  30. package/svf/lib/Util/CallGraphBuilder.cpp +7 -7
  31. package/svf/lib/Util/SVFUtil.cpp +49 -0
  32. package/svf/lib/Util/ThreadAPI.cpp +1 -2
  33. package/svf-llvm/include/SVF-LLVM/ICFGBuilder.h +16 -6
  34. package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +11 -0
  35. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +2 -2
  36. package/svf-llvm/lib/ICFGBuilder.cpp +103 -53
  37. package/svf-llvm/lib/LLVMLoopAnalysis.cpp +18 -4
  38. package/svf-llvm/lib/LLVMModule.cpp +16 -3
  39. package/svf-llvm/lib/ObjTypeInference.cpp +6 -2
  40. package/svf-llvm/lib/SVFIRBuilder.cpp +7 -3
  41. package/svf-llvm/tools/AE/ae.cpp +4 -17
  42. package/svf/include/AE/Svfexe/BufOverflowChecker.h +0 -216
  43. package/svf/include/AE/Svfexe/ICFGSimplification.h +0 -44
  44. package/svf/lib/AE/Svfexe/BufOverflowChecker.cpp +0 -829
  45. package/svf/lib/AE/Svfexe/ICFGSimplification.cpp +0 -173
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.979",
3
+ "version": "1.0.981",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -95,6 +95,8 @@ public:
95
95
  // storeValue
96
96
  void storeValue(NodeID varId, AbstractValue val);
97
97
 
98
+ u32_t getAllocaInstByteSize(const AddrStmt *addr);
99
+
98
100
 
99
101
  /// The physical address starts with 0x7f...... + idx
100
102
  static inline u32_t getVirtualMemAddress(u32_t idx)
@@ -281,13 +283,14 @@ public:
281
283
  /// domain meet with other, important! other widen this.
282
284
  void meetWith(const AbstractState&other);
283
285
 
284
-
285
- /// Return int value from an expression if it is a numeral, otherwise return an approximate value
286
- inline s32_t Interval2NumValue(const IntervalValue &e) const
287
- {
288
- //TODO: return concrete value;
289
- return (s32_t) e.lb().getNumeral();
290
- }
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);
291
294
 
292
295
 
293
296
  u32_t hash() const;
@@ -395,7 +398,6 @@ public:
395
398
  _varToAbsVal.clear();
396
399
  }
397
400
 
398
-
399
401
  };
400
402
 
401
403
  }
@@ -0,0 +1,322 @@
1
+ //===- AEDetector.h -- Vulnerability Detectors---------------------------------//
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
+ //
25
+ // Created by Jiawei Wang on 2024/8/20.
26
+ //
27
+ #pragma once
28
+ #include <SVFIR/SVFIR.h>
29
+ #include <AE/Core/AbstractState.h>
30
+ #include "Util/SVFBugReport.h"
31
+
32
+ namespace SVF
33
+ {
34
+ /**
35
+ * @class AEDetector
36
+ * @brief Base class for all detectors.
37
+ */
38
+ class AEDetector
39
+ {
40
+ public:
41
+ /**
42
+ * @enum DetectorKind
43
+ * @brief Enumerates the types of detectors available.
44
+ */
45
+ enum DetectorKind
46
+ {
47
+ BUF_OVERFLOW, ///< Detector for buffer overflow issues.
48
+ UNKNOWN, ///< Default type if the kind is not specified.
49
+ };
50
+
51
+ /**
52
+ * @brief Constructor initializes the detector kind to UNKNOWN.
53
+ */
54
+ AEDetector(): kind(UNKNOWN) {}
55
+
56
+ /**
57
+ * @brief Virtual destructor for safe polymorphic use.
58
+ */
59
+ virtual ~AEDetector() = default;
60
+
61
+ /**
62
+ * @brief Check if the detector is of the UNKNOWN kind.
63
+ * @param detector Pointer to the detector.
64
+ * @return True if the detector is of type UNKNOWN, false otherwise.
65
+ */
66
+ static bool classof(const AEDetector* detector)
67
+ {
68
+ return detector->getKind() == AEDetector::UNKNOWN;
69
+ }
70
+
71
+ /**
72
+ * @brief Pure virtual function for detecting issues within a node.
73
+ * @param as Reference to the abstract state.
74
+ * @param node Pointer to the ICFG node.
75
+ */
76
+ virtual void detect(AbstractState& as, const ICFGNode* node) = 0;
77
+
78
+ /**
79
+ * @brief Pure virtual function to report detected bugs.
80
+ */
81
+ virtual void reportBug() = 0;
82
+
83
+ /**
84
+ * @brief Get the kind of the detector.
85
+ * @return The kind of the detector.
86
+ */
87
+ DetectorKind getKind() const
88
+ {
89
+ return kind;
90
+ }
91
+
92
+ protected:
93
+ DetectorKind kind; ///< The kind of the detector.
94
+ };
95
+
96
+ /**
97
+ * @class AEException
98
+ * @brief Exception class for handling errors in Abstract Execution.
99
+ */
100
+ class AEException : public std::exception
101
+ {
102
+ public:
103
+ /**
104
+ * @brief Constructor initializes the exception with a message.
105
+ * @param message The error message.
106
+ */
107
+ AEException(const std::string& message)
108
+ : msg_(message) {}
109
+
110
+ /**
111
+ * @brief Provides the error message.
112
+ * @return The error message as a C-string.
113
+ */
114
+ virtual const char* what() const throw()
115
+ {
116
+ return msg_.c_str();
117
+ }
118
+
119
+ private:
120
+ std::string msg_; ///< The error message.
121
+ };
122
+
123
+ /**
124
+ * @class BufOverflowDetector
125
+ * @brief Detector for identifying buffer overflow issues.
126
+ */
127
+ class BufOverflowDetector : public AEDetector
128
+ {
129
+ friend class AbstractInterpretation;
130
+ public:
131
+ /**
132
+ * @brief Constructor initializes the detector kind to BUF_OVERFLOW and sets up external API buffer overflow rules.
133
+ */
134
+ BufOverflowDetector()
135
+ {
136
+ kind = BUF_OVERFLOW;
137
+ initExtAPIBufOverflowCheckRules();
138
+ }
139
+
140
+ /**
141
+ * @brief Destructor.
142
+ */
143
+ ~BufOverflowDetector() = default;
144
+
145
+ /**
146
+ * @brief Check if the detector is of the BUF_OVERFLOW kind.
147
+ * @param detector Pointer to the detector.
148
+ * @return True if the detector is of type BUF_OVERFLOW, false otherwise.
149
+ */
150
+ static bool classof(const AEDetector* detector)
151
+ {
152
+ return detector->getKind() == AEDetector::BUF_OVERFLOW;
153
+ }
154
+
155
+ /**
156
+ * @brief Updates the offset of a GEP object from its base.
157
+ * @param gepAddrs Address value for GEP.
158
+ * @param objAddrs Address value for the object.
159
+ * @param offset The interval value of the offset.
160
+ */
161
+ void updateGepObjOffsetFromBase(AddressValue gepAddrs,
162
+ AddressValue objAddrs,
163
+ IntervalValue offset);
164
+
165
+ /**
166
+ * @brief Detect buffer overflow issues within a node.
167
+ * @param as Reference to the abstract state.
168
+ * @param node Pointer to the ICFG node.
169
+ */
170
+ void detect(AbstractState& as, const ICFGNode*);
171
+
172
+ /**
173
+ * @brief Adds an offset to a GEP object.
174
+ * @param obj Pointer to the GEP object.
175
+ * @param offset The interval value of the offset.
176
+ */
177
+ void addToGepObjOffsetFromBase(const GepObjVar* obj, const IntervalValue& offset)
178
+ {
179
+ gepObjOffsetFromBase[obj] = offset;
180
+ }
181
+
182
+ /**
183
+ * @brief Checks if a GEP object has an associated offset.
184
+ * @param obj Pointer to the GEP object.
185
+ * @return True if the GEP object has an offset, false otherwise.
186
+ */
187
+ bool hasGepObjOffsetFromBase(const GepObjVar* obj) const
188
+ {
189
+ return gepObjOffsetFromBase.find(obj) != gepObjOffsetFromBase.end();
190
+ }
191
+
192
+ /**
193
+ * @brief Retrieves the offset of a GEP object from its base.
194
+ * @param obj Pointer to the GEP object.
195
+ * @return The interval value of the offset.
196
+ */
197
+ IntervalValue getGepObjOffsetFromBase(const GepObjVar* obj) const
198
+ {
199
+ if (hasGepObjOffsetFromBase(obj))
200
+ return gepObjOffsetFromBase.at(obj);
201
+ else
202
+ assert(false && "GepObjVar not found in gepObjOffsetFromBase");
203
+ }
204
+
205
+ /**
206
+ * @brief Retrieves the access offset for a given object and GEP statement.
207
+ * @param as Reference to the abstract state.
208
+ * @param objId The ID of the object.
209
+ * @param gep Pointer to the GEP statement.
210
+ * @return The interval value of the access offset.
211
+ */
212
+ IntervalValue getAccessOffset(AbstractState& as, NodeID objId, const GepStmt* gep);
213
+
214
+ /**
215
+ * @brief Adds a bug to the reporter based on an exception.
216
+ * @param e The exception that was thrown.
217
+ * @param node Pointer to the ICFG node where the bug was detected.
218
+ */
219
+ void addBugToReporter(const AEException& e, const ICFGNode* node)
220
+ {
221
+ const SVFInstruction* inst = nullptr;
222
+
223
+ // Determine the instruction associated with the ICFG node
224
+ if (const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(node))
225
+ {
226
+ inst = call->getCallSite(); // If the node is a call node, get the call site instruction
227
+ }
228
+ else
229
+ {
230
+ inst = node->getSVFStmts().back()->getInst(); // Otherwise, get the last instruction of the node's
231
+ // statements
232
+ }
233
+
234
+ GenericBug::EventStack eventStack;
235
+ SVFBugEvent sourceInstEvent(SVFBugEvent::EventType::SourceInst, inst);
236
+ eventStack.push_back(sourceInstEvent); // Add the source instruction event to the event stack
237
+
238
+ if (eventStack.empty())
239
+ {
240
+ return; // If the event stack is empty, return early
241
+ }
242
+
243
+ std::string loc = eventStack.back().getEventLoc(); // Get the location of the last event in the stack
244
+
245
+ // Check if the bug at this location has already been reported
246
+ if (bugLoc.find(loc) != bugLoc.end())
247
+ {
248
+ return; // If the bug location is already reported, return early
249
+ }
250
+ else
251
+ {
252
+ bugLoc.insert(loc); // Otherwise, mark this location as reported
253
+ }
254
+
255
+ // Add the bug to the recorder with details from the event stack
256
+ recoder.addAbsExecBug(GenericBug::FULLBUFOVERFLOW, eventStack, 0, 0, 0, 0);
257
+ nodeToBugInfo[node] = e.what(); // Record the exception information for the node
258
+ }
259
+
260
+ /**
261
+ * @brief Reports all detected buffer overflow bugs.
262
+ */
263
+ void reportBug()
264
+ {
265
+ if (!nodeToBugInfo.empty())
266
+ {
267
+ std::cerr << "######################Buffer Overflow (" + std::to_string(nodeToBugInfo.size())
268
+ + " found)######################\n";
269
+ std::cerr << "---------------------------------------------\n";
270
+ for (const auto& it : nodeToBugInfo)
271
+ {
272
+ std::cerr << it.second << "\n---------------------------------------------\n";
273
+ }
274
+ }
275
+ }
276
+
277
+ /**
278
+ * @brief Initializes external API buffer overflow check rules.
279
+ */
280
+ void initExtAPIBufOverflowCheckRules();
281
+
282
+ /**
283
+ * @brief Handles external API calls related to buffer overflow detection.
284
+ * @param as Reference to the abstract state.
285
+ * @param call Pointer to the call ICFG node.
286
+ */
287
+ void detectExtAPI(AbstractState& as, const CallICFGNode *call);
288
+
289
+ /**
290
+ * @brief Checks if memory can be safely accessed.
291
+ * @param as Reference to the abstract state.
292
+ * @param value Pointer to the SVF value.
293
+ * @param len The interval value representing the length of the memory access.
294
+ * @return True if the memory access is safe, false otherwise.
295
+ */
296
+ bool canSafelyAccessMemory(AbstractState& as, const SVFValue *value, const IntervalValue &len);
297
+
298
+ private:
299
+ /**
300
+ * @brief Detects buffer overflow in 'strcat' function calls.
301
+ * @param as Reference to the abstract state.
302
+ * @param call Pointer to the call ICFG node.
303
+ * @return True if a buffer overflow is detected, false otherwise.
304
+ */
305
+ bool detectStrcat(AbstractState& as, const CallICFGNode *call);
306
+
307
+ /**
308
+ * @brief Detects buffer overflow in 'strcpy' function calls.
309
+ * @param as Reference to the abstract state.
310
+ * @param call Pointer to the call ICFG node.
311
+ * @return True if a buffer overflow is detected, false otherwise.
312
+ */
313
+ bool detectStrcpy(AbstractState& as, const CallICFGNode *call);
314
+
315
+ private:
316
+ Map<const GepObjVar*, IntervalValue> gepObjOffsetFromBase; ///< Maps GEP objects to their offsets from the base.
317
+ Map<std::string, std::vector<std::pair<u32_t, u32_t>>> extAPIBufOverflowCheckRules; ///< Rules for checking buffer overflows in external APIs.
318
+ Set<std::string> bugLoc; ///< Set of locations where bugs have been reported.
319
+ SVFBugReport recoder; ///< Recorder for abstract execution bugs.
320
+ Map<const ICFGNode*, std::string> nodeToBugInfo; ///< Maps ICFG nodes to bug information.
321
+ };
322
+ }
@@ -27,11 +27,12 @@
27
27
  // Xiao Cheng, Jiawei Wang and Yulei Sui. Precise Sparse Abstract Execution via Cross-Domain Interaction.
28
28
  // 46th International Conference on Software Engineering. (ICSE24)
29
29
  //
30
-
30
+ #pragma once
31
+ #include "AE/Core/AbstractState.h"
31
32
  #include "AE/Core/ICFGWTO.h"
33
+ #include "AE/Svfexe/AEDetector.h"
32
34
  #include "Util/SVFBugReport.h"
33
35
  #include "WPA/Andersen.h"
34
- #include "AE/Core/AbstractState.h"
35
36
 
36
37
  namespace SVF
37
38
  {
@@ -41,12 +42,6 @@ class AEAPI;
41
42
 
42
43
  template<typename T> class FILOWorkList;
43
44
 
44
- enum class AEKind
45
- {
46
- AbstractExecution,
47
- BufOverflowChecker,
48
- };
49
-
50
45
  /// AEStat: Statistic for AE
51
46
  class AEStat : public SVFStat
52
47
  {
@@ -67,14 +62,12 @@ public:
67
62
 
68
63
  void finializeStat();
69
64
  void performStat() override;
70
- void reportBug();
71
65
 
72
66
  public:
73
67
  AbstractInterpretation* _ae;
74
68
  s32_t count{0};
75
69
  std::string memory_usage;
76
70
  std::string memUsage;
77
- std::string bugStr;
78
71
 
79
72
 
80
73
  u32_t& getFunctionTrace()
@@ -108,6 +101,7 @@ class AbstractInterpretation
108
101
  {
109
102
  friend class AEStat;
110
103
  friend class AEAPI;
104
+ friend class BufOverflowDetector;
111
105
 
112
106
  public:
113
107
  enum ExtAPIType { UNCLASSIFIED, MEMCPY, MEMSET, STRCPY, STRCAT };
@@ -123,14 +117,15 @@ public:
123
117
  /// Program entry
124
118
  void analyse();
125
119
 
126
- static bool classof(const AbstractInterpretation* ae)
120
+ static AbstractInterpretation& getAEInstance()
127
121
  {
128
- return ae->getKind() == AEKind::AbstractExecution;
122
+ static AbstractInterpretation instance;
123
+ return instance;
129
124
  }
130
125
 
131
- AEKind getKind() const
126
+ void addDetector(std::unique_ptr<AEDetector> detector)
132
127
  {
133
- return _kind;
128
+ detectors.push_back(std::move(detector));
134
129
  }
135
130
 
136
131
  protected:
@@ -233,13 +228,6 @@ protected:
233
228
  */
234
229
  virtual void initExtFunMap();
235
230
 
236
- /**
237
- * get byte size of alloca inst
238
- *
239
- * @param addr Address Stmt like malloc/calloc/ALLOCA/StackAlloc
240
- * @return the byte size e.g. int32_t a[10] -> return 40
241
- */
242
- u32_t getAllocaInstByteSize(AbstractState& as, const AddrStmt *addr);
243
231
 
244
232
  /**
245
233
  * get byte size of alloca inst
@@ -259,16 +247,6 @@ protected:
259
247
  */
260
248
  IntervalValue getStrlen(AbstractState& as, const SVF::SVFValue *strValue);
261
249
 
262
- /**
263
- * get memory allocation size
264
- * e.g arr = new int[10]
265
- * ....
266
- * memset(arr, 1, 10* sizeof(int))
267
- * when we trace the 'arr', we can get the alloc size [40, 40]
268
- * @param value to be traced
269
- * @return IntervalValue of allocation size
270
- */
271
- IntervalValue traceMemoryAllocationSize(AbstractState& as, const SVFValue *value);
272
250
  /**
273
251
  * execute strcpy in abstract execution
274
252
  * e.g arr = new char[10]
@@ -305,23 +283,9 @@ protected:
305
283
  */
306
284
  virtual void handleMemset(AbstractState& as, const SVFValue* dst, IntervalValue elem, IntervalValue len);
307
285
 
308
- /**
309
- * if this NodeID in SVFIR is a pointer, get the pointee type
310
- * e.g arr = (int*) malloc(10*sizeof(int))
311
- * getPointeeType(arr) -> return int
312
- * we can set arr[0]='c', arr[1]='c', arr[2]='\0'
313
- * @param call callnode of memset like api
314
- */
315
- const SVFType* getPointeeElement(AbstractState& as, NodeID id);
316
286
 
317
287
  void collectCheckPoint();
318
288
  void checkPointAllSet();
319
- // helper functions for traceMemoryAllocationSize and canSafelyAccessMemory
320
- void AccessMemoryViaRetNode(const CallICFGNode *callnode, SVF::FILOWorkList<const SVFValue *>& worklist, Set<const SVFValue *>& visited);
321
- void AccessMemoryViaCopyStmt(const CopyStmt *copy, SVF::FILOWorkList<const SVFValue *>& worklist, Set<const SVFValue *>& visited);
322
- void AccessMemoryViaLoadStmt(AbstractState& as, const LoadStmt *load, SVF::FILOWorkList<const SVFValue *>& worklist, Set<const SVFValue *>& visited);
323
- void AccessMemoryViaCallArgs(const SVF::SVFArgument *arg, SVF::FILOWorkList<const SVFValue *>& worklist, Set<const SVFValue *>& visited);
324
-
325
289
 
326
290
  void updateStateOnAddr(const AddrStmt *addr);
327
291
 
@@ -349,20 +313,16 @@ protected:
349
313
 
350
314
 
351
315
  /// protected data members, also used in subclasses
352
- SVFIR* _svfir;
316
+ SVFIR* svfir;
353
317
  /// Execution State, used to store the Interval Value of every SVF variable
354
- AEAPI* _api{nullptr};
318
+ AEAPI* api{nullptr};
355
319
 
356
- ICFG* _icfg;
357
- AEStat* _stat;
358
- AEKind _kind;
320
+ ICFG* icfg;
321
+ AEStat* stat;
359
322
 
360
- Set<std::string> _bugLoc;
361
- SVFBugReport _recoder;
362
- std::vector<const CallICFGNode*> _callSiteStack;
363
- Map<const ICFGNode*, std::string> _nodeToBugInfo;
364
- Map<const SVFFunction*, ICFGWTO*> _funcToWTO;
365
- Set<const SVFFunction*> _recursiveFuns;
323
+ std::vector<const CallICFGNode*> callSiteStack;
324
+ Map<const SVFFunction*, ICFGWTO*> funcToWTO;
325
+ Set<const SVFFunction*> recursiveFuns;
366
326
 
367
327
  private:
368
328
  // helper functions in handleCallSite
@@ -379,29 +339,33 @@ protected:
379
339
 
380
340
  AbstractState& getAbsStateFromTrace(const ICFGNode* node)
381
341
  {
382
- const ICFGNode* repNode = _icfg->getRepNode(node);
383
- if (_abstractTrace.count(repNode) == 0)
342
+ const ICFGNode* repNode = icfg->getRepNode(node);
343
+ if (abstractTrace.count(repNode) == 0)
384
344
  {
385
345
  assert(0 && "No preAbsTrace for this node");
386
346
  }
387
347
  else
388
348
  {
389
- return _abstractTrace[repNode];
349
+ return abstractTrace[repNode];
390
350
  }
391
351
  }
392
352
 
393
353
  bool hasAbsStateFromTrace(const ICFGNode* node)
394
354
  {
395
- const ICFGNode* repNode = _icfg->getRepNode(node);
396
- return _abstractTrace.count(repNode) != 0;
355
+ const ICFGNode* repNode = icfg->getRepNode(node);
356
+ return abstractTrace.count(repNode) != 0;
397
357
  }
398
358
 
399
359
  protected:
400
360
  // there data should be shared with subclasses
401
- Map<std::string, std::function<void(const CallSite &)>> _func_map;
402
- Set<const CallICFGNode*> _checkpoints;
403
- Set<std::string> _checkpoint_names;
404
- Map<const ICFGNode*, AbstractState> _abstractTrace; // abstract states immediately after nodes
405
- std::string _moduleName;
361
+ Map<std::string, std::function<void(const CallSite &)>> func_map;
362
+ Set<const CallICFGNode*> checkpoints;
363
+ Set<std::string> checkpoint_names;
364
+ Map<const ICFGNode*, AbstractState>
365
+ abstractTrace; // abstract states immediately after nodes
366
+ std::string moduleName;
367
+
368
+ std::vector<std::unique_ptr<AEDetector>> detectors;
369
+
406
370
  };
407
371
  }
@@ -198,12 +198,21 @@ public:
198
198
  //@{
199
199
  ICFGNode* getICFGNode(const SVFInstruction* inst);
200
200
 
201
+ /// Whether has the ICFGNode
202
+ bool hasICFGNode(const SVFInstruction* inst);
203
+
201
204
  CallICFGNode* getCallICFGNode(const SVFInstruction* inst);
202
205
 
206
+ CallICFGNode* addCallICFGNode(const SVFInstruction* inst);
207
+
203
208
  RetICFGNode* getRetICFGNode(const SVFInstruction* inst);
204
209
 
210
+ RetICFGNode* addRetICFGNode(const SVFInstruction* inst);
211
+
205
212
  IntraICFGNode* getIntraICFGNode(const SVFInstruction* inst);
206
213
 
214
+ IntraICFGNode* addIntraICFGNode(const SVFInstruction* inst);
215
+
207
216
  FunEntryICFGNode* getFunEntryICFGNode(const SVFFunction* fun);
208
217
 
209
218
  FunExitICFGNode* getFunExitICFGNode(const SVFFunction* fun);
@@ -470,9 +470,9 @@ public:
470
470
  }
471
471
  //@}
472
472
  /// Whether this instruction has SVFIR Edge
473
- bool hasSVFStmtList(const SVFInstruction* inst);
473
+ bool hasSVFStmtList(const ICFGNode* icfgNode);
474
474
  /// Given an instruction, get all its the PAGEdge (statement) in sequence
475
- SVFStmtList& getPAGEdgesFromInst(const SVFInstruction* inst);
475
+ SVFStmtList& getPAGEdgesFromInst(const ICFGNode* node);
476
476
 
477
477
  /// getModRefInfo APIs
478
478
  //@{
@@ -341,8 +341,7 @@ public:
341
341
  NodeID parentTid = tct->getParentThread(tid);
342
342
  const CxtThread& parentct = tct->getTCTNode(parentTid)->getCxtThread();
343
343
  const SVFFunction* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
344
- const SVFInstruction* inst = parentRoutine->getExitBB()->back();
345
- return tct->getICFGNode(inst);
344
+ return parentRoutine->getExitBB()->back();
346
345
  }
347
346
 
348
347
  /// Get loop for join site
@@ -658,7 +658,7 @@ private:
658
658
  /// Add Load edge
659
659
  LoadStmt* addLoadStmt(NodeID src, NodeID dst);
660
660
  /// Add Store edge
661
- StoreStmt* addStoreStmt(NodeID src, NodeID dst, const IntraICFGNode* val);
661
+ StoreStmt* addStoreStmt(NodeID src, NodeID dst, const ICFGNode* val);
662
662
  /// Add Call edge
663
663
  CallPE* addCallPE(NodeID src, NodeID dst, const CallICFGNode* cs,
664
664
  const FunEntryICFGNode* entry);
@@ -478,7 +478,7 @@ public:
478
478
  //@}
479
479
 
480
480
  /// constructor
481
- StoreStmt(SVFVar* s, SVFVar* d, const IntraICFGNode* st);
481
+ StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
482
482
 
483
483
  virtual const std::string toString() const override;
484
484
  };