svf-lib 1.0.2446 → 1.0.2451

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 (53) hide show
  1. package/.github/workflows/publish-svf-lib.yml +14 -7
  2. package/SVF-linux-aarch64/bin/ae +0 -0
  3. package/SVF-linux-aarch64/bin/dvf +0 -0
  4. package/SVF-linux-aarch64/bin/mta +0 -0
  5. package/SVF-linux-aarch64/bin/saber +0 -0
  6. package/SVF-linux-aarch64/bin/svf-ex +0 -0
  7. package/SVF-linux-aarch64/bin/wpa +0 -0
  8. package/SVF-linux-aarch64/include/Graphs/BasicBlockG.h +18 -4
  9. package/SVF-linux-aarch64/include/Graphs/CHG.h +12 -0
  10. package/SVF-linux-aarch64/include/Graphs/CallGraph.h +14 -2
  11. package/SVF-linux-aarch64/include/Graphs/ICFG.h +24 -8
  12. package/SVF-linux-aarch64/include/Graphs/ICFGEdge.h +1 -0
  13. package/SVF-linux-aarch64/include/Graphs/ICFGNode.h +39 -6
  14. package/SVF-linux-aarch64/include/Graphs/IRGraph.h +12 -0
  15. package/SVF-linux-aarch64/include/MemoryModel/AccessPath.h +7 -1
  16. package/SVF-linux-aarch64/include/SVF-LLVM/ICFGBuilder.h +1 -1
  17. package/SVF-linux-aarch64/include/SVF-LLVM/SVFIRBuilder.h +1 -0
  18. package/SVF-linux-aarch64/include/SVFIR/ObjTypeInfo.h +5 -0
  19. package/SVF-linux-aarch64/include/SVFIR/SVFIR.h +61 -39
  20. package/SVF-linux-aarch64/include/SVFIR/SVFStatements.h +125 -10
  21. package/SVF-linux-aarch64/include/SVFIR/SVFType.h +97 -1
  22. package/SVF-linux-aarch64/include/SVFIR/SVFValue.h +1 -0
  23. package/SVF-linux-aarch64/include/SVFIR/SVFVariables.h +164 -4
  24. package/SVF-linux-aarch64/include/Util/ExtAPI.h +1 -0
  25. package/SVF-linux-aarch64/include/Util/NodeIDAllocator.h +11 -0
  26. package/SVF-linux-aarch64/include/Util/SVFLoopAndDomInfo.h +37 -0
  27. package/SVF-linux-aarch64/lib/libSvfCore.so.3.2 +0 -0
  28. package/SVF-linux-aarch64/lib/libSvfLLVM.so.3.2 +0 -0
  29. package/SVF-osx/bin/ae +0 -0
  30. package/SVF-osx/bin/svf-ex +0 -0
  31. package/SVF-osx/bin/wpa +0 -0
  32. package/SVF-osx/include/Graphs/BasicBlockG.h +18 -4
  33. package/SVF-osx/include/Graphs/CHG.h +12 -0
  34. package/SVF-osx/include/Graphs/CallGraph.h +14 -2
  35. package/SVF-osx/include/Graphs/ICFG.h +24 -8
  36. package/SVF-osx/include/Graphs/ICFGEdge.h +1 -0
  37. package/SVF-osx/include/Graphs/ICFGNode.h +39 -6
  38. package/SVF-osx/include/Graphs/IRGraph.h +12 -0
  39. package/SVF-osx/include/MemoryModel/AccessPath.h +7 -1
  40. package/SVF-osx/include/SVF-LLVM/ICFGBuilder.h +1 -1
  41. package/SVF-osx/include/SVF-LLVM/SVFIRBuilder.h +1 -0
  42. package/SVF-osx/include/SVFIR/ObjTypeInfo.h +5 -0
  43. package/SVF-osx/include/SVFIR/SVFIR.h +61 -39
  44. package/SVF-osx/include/SVFIR/SVFStatements.h +125 -10
  45. package/SVF-osx/include/SVFIR/SVFType.h +97 -1
  46. package/SVF-osx/include/SVFIR/SVFValue.h +1 -0
  47. package/SVF-osx/include/SVFIR/SVFVariables.h +164 -4
  48. package/SVF-osx/include/Util/ExtAPI.h +1 -0
  49. package/SVF-osx/include/Util/NodeIDAllocator.h +11 -0
  50. package/SVF-osx/include/Util/SVFLoopAndDomInfo.h +37 -0
  51. package/SVF-osx/lib/libSvfCore.3.2.dylib +0 -0
  52. package/SVF-osx/lib/libSvfLLVM.3.2.dylib +0 -0
  53. package/package.json +1 -1
@@ -3,24 +3,31 @@ name: svf-build
3
3
  # Triggers the workflow on push or pull request events
4
4
  on: [push, pull_request]
5
5
 
6
+ permissions:
7
+ contents: read
8
+ id-token: write
9
+
6
10
  jobs:
7
11
  build:
8
12
  runs-on: ubuntu-latest
13
+ environment: npm-publish
9
14
  steps:
10
- - uses: actions/checkout@v2
15
+ - uses: actions/checkout@v4
11
16
 
12
- - uses: actions/setup-node@v2
17
+ - uses: actions/setup-node@v4
13
18
  with:
14
- node-version: 12
19
+ node-version: 20
15
20
  registry-url: https://registry.npmjs.org/
16
-
21
+
17
22
  - name: publish-svf-lib
23
+ env:
24
+ NODE_AUTH_TOKEN: ""
25
+ NPM_CONFIG_USERCONFIG: ""
18
26
  run: |
27
+ npm i -g npm@latest
19
28
  if [ "$RUNNER_OS" = "Linux" ]; then sudo apt-get update ; fi
20
29
  cat package.json
21
- npm publish
22
- env:
23
- NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
30
+ npm publish --access public
24
31
 
25
32
  trigger-svf-python:
26
33
  if: github.event_name == 'push' # Only run on push events
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -74,6 +74,7 @@ class SVFBasicBlock : public GenericBasicBlockNodeTy
74
74
  friend class FunObjVar;
75
75
  friend class ICFGBuilder;
76
76
  friend class ICFG;
77
+ friend class GraphDBClient;
77
78
 
78
79
  public:
79
80
  typedef std::vector<const ICFGNode*>::const_iterator const_iterator;
@@ -98,6 +99,17 @@ protected:
98
99
 
99
100
  /// @}
100
101
 
102
+ // Getters of predecessor and successor basic blocks, used for writing bb to DB
103
+ const std::vector<const SVFBasicBlock*> getSuccBBs() const
104
+ {
105
+ return succBBs;
106
+ }
107
+
108
+ const std::vector<const SVFBasicBlock*> getPredBBs() const
109
+ {
110
+ return predBBs;
111
+ }
112
+
101
113
  public:
102
114
  /// Constructor without name
103
115
  SVFBasicBlock(NodeID id, const FunObjVar* f): GenericBasicBlockNodeTy(id, BasicBlockKd), fun(f)
@@ -289,24 +301,26 @@ public:
289
301
  typedef GenericGraph<SVFBasicBlock, BasicBlockEdge> GenericBasicBlockGraphTy;
290
302
  class BasicBlockGraph: public GenericBasicBlockGraphTy
291
303
  {
292
- private:
293
- NodeID id{0};
294
304
  public:
305
+ NodeID id{0};
295
306
  /// Constructor
296
- BasicBlockGraph()
307
+ BasicBlockGraph(): GenericBasicBlockGraphTy()
297
308
  {
298
309
 
299
310
  }
300
311
 
312
+
301
313
  SVFBasicBlock* addBasicBlock(const std::string& bbname)
302
314
  {
303
315
  id++;
304
316
  SVFBasicBlock* bb = new SVFBasicBlock(id, nullptr);
305
- addGNode(id, bb);
306
317
  bb->setName(bbname);
318
+ addBasicBlock(bb);
307
319
  return bb;
308
320
  }
309
321
 
322
+ void addBasicBlock(SVFBasicBlock* bb);
323
+
310
324
  };
311
325
  }
312
326
 
@@ -105,6 +105,7 @@ private:
105
105
  typedef GenericNode<CHNode, CHEdge> GenericCHNodeTy;
106
106
  class CHNode: public GenericCHNodeTy
107
107
  {
108
+ friend class GraphDBClient;
108
109
 
109
110
  public:
110
111
  typedef enum
@@ -222,6 +223,16 @@ private:
222
223
  * virtualFunctionVectors = {{Af1, Af2, ...}, {Bg1, Bg2, ...}}
223
224
  */
224
225
  std::vector<FuncVector> virtualFunctionVectors;
226
+
227
+ protected:
228
+ inline size_t getFlags() const
229
+ {
230
+ return flags;
231
+ }
232
+ inline void setFlags(size_t f)
233
+ {
234
+ flags = f;
235
+ }
225
236
  };
226
237
 
227
238
  /// class hierarchy graph
@@ -229,6 +240,7 @@ typedef GenericGraph<CHNode, CHEdge> GenericCHGraphTy;
229
240
  class CHGraph: public CommonCHGraph, public GenericCHGraphTy
230
241
  {
231
242
  friend class CHGBuilder;
243
+ friend class GraphDBClient;
232
244
 
233
245
  public:
234
246
  typedef Set<const CHNode*> CHNodeSetTy;
@@ -224,6 +224,7 @@ public:
224
224
  {
225
225
  return node->getNodeKind() == CallNodeKd;
226
226
  }
227
+
227
228
  //@}
228
229
  };
229
230
 
@@ -233,6 +234,8 @@ public:
233
234
  typedef GenericGraph<CallGraphNode, CallGraphEdge> GenericPTACallGraphTy;
234
235
  class CallGraph : public GenericPTACallGraphTy
235
236
  {
237
+ friend class GraphDBClient;
238
+
236
239
 
237
240
  public:
238
241
  typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
@@ -281,13 +284,14 @@ protected:
281
284
  if(it == csToIdMap.end())
282
285
  {
283
286
  CallSiteID id = totalCallSiteNum++;
284
- csToIdMap.insert(std::make_pair(newCS, id));
285
- idToCSMap.insert(std::make_pair(id, newCS));
287
+ addCallSite(cs,callee,id, newCS);
286
288
  return id;
287
289
  }
288
290
  return it->second;
289
291
  }
290
292
 
293
+ CallSiteID addCallSite(const CallICFGNode* cs, const FunObjVar* callee, const CallSiteID csid, std::pair<const CallICFGNode*, const FunObjVar*> newCS);
294
+
291
295
  /// Add call graph edge
292
296
  inline void addEdge(CallGraphEdge* edge)
293
297
  {
@@ -295,6 +299,14 @@ protected:
295
299
  edge->getSrcNode()->addOutgoingEdge(edge);
296
300
  }
297
301
 
302
+ /// add direct call graph edge from database [only used this function when loading cgEdges from db results]
303
+ void addDirectCallGraphEdge(CallGraphEdge* cgEdge);
304
+
305
+ /// add call graph node from database [only used this function when loading cgNodes from db results]
306
+ void addCallGraphNode(CallGraphNode* cgNode);
307
+
308
+ /// Whether we have already created this call graph edge
309
+ CallGraphEdge* hasGraphEdge(CallGraphEdge* cgEdge) const;
298
310
  public:
299
311
  /// Constructor
300
312
  CallGraph(CGEK k = NormCallGraph);
@@ -34,6 +34,7 @@
34
34
  #include "Graphs/ICFGEdge.h"
35
35
  #include "Util/WorkList.h"
36
36
  #include "MemoryModel/SVFLoop.h"
37
+ #include "SVFIR/SVFVariables.h"
37
38
 
38
39
  namespace SVF
39
40
  {
@@ -48,6 +49,7 @@ class ICFG : public GenericICFGTy
48
49
  {
49
50
  friend class ICFGBuilder;
50
51
  friend class ICFGSimplification;
52
+ friend class GraphDBClient;
51
53
 
52
54
  public:
53
55
 
@@ -198,23 +200,37 @@ protected:
198
200
  virtual inline FunEntryICFGNode* addFunEntryICFGNode(const FunObjVar* svfFunc)
199
201
  {
200
202
  FunEntryICFGNode* sNode = new FunEntryICFGNode(totalICFGNode++,svfFunc);
201
- addICFGNode(sNode);
202
- return FunToFunEntryNodeMap[svfFunc] = sNode;
203
+ return addFunEntryICFGNode(sNode);
203
204
  }
204
205
 
206
+ virtual inline FunEntryICFGNode* addFunEntryICFGNode(FunEntryICFGNode* funEntryICFGNode)
207
+ {
208
+ addICFGNode(funEntryICFGNode);
209
+ return FunToFunEntryNodeMap[funEntryICFGNode->getFun()] = funEntryICFGNode;
210
+ }
211
+
212
+ virtual void addGlobalICFGNode(GlobalICFGNode* globalICFGNode);
213
+
205
214
  virtual inline FunExitICFGNode* addFunExitICFGNode(const FunObjVar* svfFunc)
206
215
  {
207
- FunExitICFGNode* sNode = new FunExitICFGNode(totalICFGNode++, svfFunc);
208
- addICFGNode(sNode);
209
- return FunToFunExitNodeMap[svfFunc] = sNode;
216
+ const SVFBasicBlock* bb = nullptr;
217
+ if (svfFunc->begin() != svfFunc->end())
218
+ {
219
+ bb = svfFunc->getExitBB();
220
+ }
221
+ FunExitICFGNode* sNode = new FunExitICFGNode(totalICFGNode++, svfFunc, bb);
222
+ return addFunExitICFGNode(sNode);
210
223
  }
211
224
 
212
- /// Add a ICFG node
213
- virtual inline void addICFGNode(ICFGNode* node)
225
+ virtual inline FunExitICFGNode* addFunExitICFGNode(FunExitICFGNode* funExitICFGNode)
214
226
  {
215
- addGNode(node->getId(),node);
227
+ addICFGNode(funExitICFGNode);
228
+ return FunToFunExitNodeMap[funExitICFGNode->getFun()] = funExitICFGNode;
216
229
  }
217
230
 
231
+ /// Add a ICFG node
232
+ virtual void addICFGNode(ICFGNode* node);
233
+
218
234
  public:
219
235
  /// Get a basic block ICFGNode
220
236
  /// TODO:: need to fix the assertions
@@ -112,6 +112,7 @@ class IntraCFGEdge : public ICFGEdge
112
112
  {
113
113
  friend class ICFG;
114
114
  friend class SVFIRBuilder;
115
+ friend class GraphDBClient;
115
116
 
116
117
  public:
117
118
  /// Constructor
@@ -140,8 +140,6 @@ public:
140
140
  return isICFGNodeKinds(node->getNodeKind());
141
141
  }
142
142
 
143
-
144
-
145
143
  protected:
146
144
  const FunObjVar* fun;
147
145
  const SVFBasicBlock* bb;
@@ -192,6 +190,8 @@ public:
192
190
  */
193
191
  class IntraICFGNode : public ICFGNode
194
192
  {
193
+ friend class GraphDBClient;
194
+
195
195
  private:
196
196
  bool isRet;
197
197
 
@@ -270,6 +270,7 @@ public:
270
270
  */
271
271
  class FunEntryICFGNode : public InterICFGNode
272
272
  {
273
+ friend class GraphDBClient;
273
274
 
274
275
  public:
275
276
  typedef std::vector<const SVFVar *> FormalParmNodeVec;
@@ -335,12 +336,18 @@ public:
335
336
  */
336
337
  class FunExitICFGNode : public InterICFGNode
337
338
  {
339
+ friend class GraphDBClient;
338
340
 
339
341
  private:
340
342
  const SVFVar *formalRet;
341
343
 
342
344
  public:
343
- FunExitICFGNode(NodeID id, const FunObjVar* f);
345
+ FunExitICFGNode(NodeID id, const FunObjVar* f, const SVFBasicBlock* b)
346
+ : InterICFGNode(id, FunExitBlock), formalRet(nullptr)
347
+ {
348
+ this->fun = f;
349
+ this->bb = b;
350
+ }
344
351
 
345
352
  /// Return function
346
353
  inline const FunObjVar* getFun() const override
@@ -398,6 +405,7 @@ public:
398
405
  */
399
406
  class CallICFGNode : public InterICFGNode
400
407
  {
408
+ friend class GraphDBClient;
401
409
 
402
410
  public:
403
411
  typedef std::vector<const ValVar *> ActualParmNodeVec;
@@ -411,6 +419,8 @@ protected:
411
419
  SVFVar* vtabPtr; /// virtual table pointer
412
420
  s32_t virtualFunIdx; /// virtual function index of the virtual table(s) at a virtual call
413
421
  std::string funNameOfVcall; /// the function name of this virtual call
422
+ const SVFVar* indFunPtr;
423
+
414
424
 
415
425
  public:
416
426
  CallICFGNode(NodeID id, const SVFBasicBlock* b, const SVFType* ty,
@@ -561,6 +571,18 @@ public:
561
571
  {
562
572
  return "CallICFGNode: " + ICFGNode::getSourceLoc();
563
573
  }
574
+
575
+ inline void setIndFunPtr(const SVFVar* indFun)
576
+ {
577
+ assert(isIndirectCall() && "not a indirect call?");
578
+ indFunPtr = indFun;
579
+ }
580
+
581
+ inline const SVFVar* getIndFunPtr() const
582
+ {
583
+ assert(isIndirectCall() && "not a indirect call?");
584
+ return indFunPtr;
585
+ }
564
586
  };
565
587
 
566
588
 
@@ -569,6 +591,14 @@ public:
569
591
  */
570
592
  class RetICFGNode : public InterICFGNode
571
593
  {
594
+ friend class GraphDBClient;
595
+
596
+ protected:
597
+ /// Add call block node from database for the new RetICFGNode [only used this function when loading from db results]
598
+ inline void setCallBlockNode(const CallICFGNode* cb)
599
+ {
600
+ callBlockNode = cb;
601
+ }
572
602
 
573
603
  private:
574
604
  const SVFVar *actualRet;
@@ -578,9 +608,12 @@ public:
578
608
  RetICFGNode(NodeID id, CallICFGNode* cb) :
579
609
  InterICFGNode(id, FunRetBlock), actualRet(nullptr), callBlockNode(cb)
580
610
  {
581
- fun = cb->getFun();
582
- bb = cb->getBB();
583
- type = cb->getType();
611
+ if (nullptr != cb)
612
+ {
613
+ fun = cb->getFun();
614
+ bb = cb->getBB();
615
+ type = cb->getType();
616
+ }
584
617
  }
585
618
 
586
619
  inline const CallICFGNode* getCallICFGNode() const
@@ -52,6 +52,7 @@ class IRGraph : public GenericGraph<SVFVar, SVFStmt>
52
52
  {
53
53
  friend class SVFIRBuilder;
54
54
  friend class SymbolTableBuilder;
55
+ friend class GraphDBClient;
55
56
 
56
57
  public:
57
58
 
@@ -129,6 +130,7 @@ protected:
129
130
  /// blocks, thus flags are needed to distinguish them
130
131
  SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind,
131
132
  const ICFGNode* cs);
133
+ SVFStmt* hasEdge(SVFStmt* edge, SVFStmt::PEDGEK kind);
132
134
  /// Return MultiOpndStmt since it has more than one operands (we use operand
133
135
  /// 2 here to make the flag)
134
136
  SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* op1, SVFStmt::PEDGEK kind,
@@ -270,6 +272,15 @@ public:
270
272
  return svfTypes;
271
273
  }
272
274
 
275
+ inline const SVFType* getSVFType(u32_t id) const
276
+ {
277
+ for(const SVFType* type : svfTypes)
278
+ {
279
+ if(type->getId() == id)
280
+ return type;
281
+ }
282
+ return nullptr;
283
+ }
273
284
  inline const Set<const StInfo*>& getStInfos() const
274
285
  {
275
286
  return stInfos;
@@ -360,6 +371,7 @@ public:
360
371
 
361
372
  inline void addStInfo(StInfo* stInfo)
362
373
  {
374
+ stInfo->setStinfoId(stInfos.size());
363
375
  stInfos.insert(stInfo);
364
376
  }
365
377
 
@@ -51,7 +51,7 @@ class SVFVar;
51
51
  */
52
52
  class AccessPath
53
53
  {
54
-
54
+ friend class GraphDBClient;
55
55
  public:
56
56
  enum LSRelation
57
57
  {
@@ -161,6 +161,12 @@ public:
161
161
  /// Dump location set
162
162
  std::string dump() const;
163
163
 
164
+ protected:
165
+ inline void addIdxOperandPair(std::pair<const SVFVar*, const SVFType*> pair)
166
+ {
167
+ idxOperandPairs.push_back(pair);
168
+ }
169
+
164
170
  private:
165
171
 
166
172
  /// Check relations of two location sets
@@ -148,7 +148,7 @@ private:
148
148
  inline void addGlobalICFGNode()
149
149
  {
150
150
  icfg->globalBlockNode = new GlobalICFGNode(icfg->totalICFGNode++);
151
- icfg->addICFGNode(icfg->globalBlockNode);
151
+ icfg->addGlobalICFGNode(icfg->globalBlockNode);
152
152
  }
153
153
 
154
154
  private:
@@ -46,6 +46,7 @@ namespace SVF
46
46
  */
47
47
  class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
48
48
  {
49
+ friend class GraphDBSVFIRBuilder;
49
50
 
50
51
  private:
51
52
  SVFIR* pag;
@@ -42,6 +42,7 @@ namespace SVF
42
42
  class ObjTypeInfo
43
43
  {
44
44
  friend class SymbolTableBuilder;
45
+ friend class GraphDBClient;
45
46
 
46
47
  public:
47
48
  typedef enum
@@ -148,6 +149,10 @@ public:
148
149
  {
149
150
  flags |= mask;
150
151
  }
152
+ inline u32_t getFlag() const
153
+ {
154
+ return flags;
155
+ }
151
156
  inline bool hasFlag(MEMTYPE mask)
152
157
  {
153
158
  return (flags & mask) == mask;