svf-lib 1.0.1037 → 1.0.1038

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.
Binary file
@@ -57,6 +57,7 @@ typedef llvm::ConstantDataSequential ConstantDataSequential;
57
57
  typedef llvm::ConstantExpr ConstantExpr;
58
58
  typedef llvm::ConstantDataArray ConstantDataArray;
59
59
  typedef llvm::ConstantData ConstantData;
60
+ typedef llvm::ConstantArray ConstantArray;
60
61
 
61
62
  // LLVM Instructions
62
63
  typedef llvm::AllocaInst AllocaInst;
@@ -5,7 +5,7 @@
5
5
  #include "Graphs/ICFG.h"
6
6
  #include "Graphs/ICFGNode.h"
7
7
  #include "Graphs/ICFGEdge.h"
8
- #include "SVF-FE/LLVMUtil.h"
8
+ #include "Util/SVFUtil.h"
9
9
 
10
10
  namespace SVF
11
11
  {
@@ -66,14 +66,6 @@ inline bool isBlackholeSym(const Value *val)
66
66
  }
67
67
 
68
68
 
69
- /// Return true if the call is an external call (external library in function summary table)
70
- /// If the libary function is redefined in the application code (e.g., memcpy), it will return false and will not be treated as an external call.
71
- //@{
72
- inline bool isExtCall(const SVFFunction* fun)
73
- {
74
- return fun && ExtAPI::getExtAPI()->is_ext(fun);
75
- }
76
-
77
69
  inline bool isExtCall(const CallSite cs)
78
70
  {
79
71
  return isExtCall(getCallee(cs));
@@ -91,19 +83,6 @@ inline bool isReturn(const Instruction* inst)
91
83
  return SVFUtil::isa<ReturnInst>(inst);
92
84
  }
93
85
 
94
- /// Return true if the call is a heap allocator/reallocator
95
- //@{
96
- /// note that these two functions are not suppose to be used externally
97
- inline bool isHeapAllocExtFunViaRet(const SVFFunction* fun)
98
- {
99
- return fun && (ExtAPI::getExtAPI()->is_alloc(fun)
100
- || ExtAPI::getExtAPI()->is_realloc(fun));
101
- }
102
- inline bool isHeapAllocExtFunViaArg(const SVFFunction* fun)
103
- {
104
- return fun && ExtAPI::getExtAPI()->is_arg_alloc(fun);
105
- }
106
-
107
86
  static inline Type *getPtrElementType(const PointerType* pty)
108
87
  {
109
88
  #if (LLVM_VERSION_MAJOR < 14)
@@ -148,13 +127,6 @@ inline bool isHeapAllocExtCall(const Instruction *inst)
148
127
  }
149
128
  //@}
150
129
 
151
- /// Get the position of argument that holds an allocated heap object.
152
- //@{
153
- inline int getHeapAllocHoldingArgPosition(const SVFFunction* fun)
154
- {
155
- return ExtAPI::getExtAPI()->get_alloc_arg_pos(fun);
156
- }
157
-
158
130
  inline int getHeapAllocHoldingArgPosition(const CallSite cs)
159
131
  {
160
132
  return getHeapAllocHoldingArgPosition(getCallee(cs));
@@ -166,14 +138,6 @@ inline int getHeapAllocHoldingArgPosition(const Instruction *inst)
166
138
  }
167
139
  //@}
168
140
 
169
- /// Return true if the call is a heap reallocator
170
- //@{
171
- /// note that this function is not suppose to be used externally
172
- inline bool isReallocExtFun(const SVFFunction* fun)
173
- {
174
- return fun && (ExtAPI::getExtAPI()->is_realloc(fun));
175
- }
176
-
177
141
  inline bool isReallocExtCall(const CallSite cs)
178
142
  {
179
143
  bool isPtrTy = cs.getInstruction()->getType()->isPointerTy();
@@ -187,14 +151,6 @@ inline bool isReallocExtCall(const Instruction *inst)
187
151
  }
188
152
  //@}
189
153
 
190
- /// Return true if the call is a heap dealloc or not
191
- //@{
192
- /// note that this function is not suppose to be used externally
193
- inline bool isDeallocExtFun(const SVFFunction* fun)
194
- {
195
- return fun && (ExtAPI::getExtAPI()->is_dealloc(fun));
196
- }
197
-
198
154
  inline bool isDeallocExtCall(const CallSite cs)
199
155
  {
200
156
  return isDeallocExtFun(getCallee(cs));
@@ -206,15 +162,6 @@ inline bool isDeallocExtCall(const Instruction *inst)
206
162
  }
207
163
  //@}
208
164
 
209
-
210
- /// Return true if the call is a static global call
211
- //@{
212
- /// note that this function is not suppose to be used externally
213
- inline bool isStaticExtFun(const SVFFunction* fun)
214
- {
215
- return fun && ExtAPI::getExtAPI()->has_static(fun);
216
- }
217
-
218
165
  inline bool isStaticExtCall(const CallSite cs)
219
166
  {
220
167
  bool isPtrTy = cs.getInstruction()->getType()->isPointerTy();
@@ -241,12 +188,6 @@ inline bool isHeapAllocOrStaticExtCall(const Instruction *inst)
241
188
  }
242
189
  //@}
243
190
 
244
- /// Return external call type
245
- inline ExtAPI::extf_t extCallTy(const SVFFunction* fun)
246
- {
247
- return ExtAPI::getExtAPI()->get_type(fun);
248
- }
249
-
250
191
  /// Get the reference type of heap/static object from an allocation site.
251
192
  //@{
252
193
  inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallSite cs)
@@ -362,18 +303,6 @@ inline bool isBarrierWaitCall(const Instruction *inst)
362
303
  }
363
304
  //@}
364
305
 
365
- /// Return thread fork function
366
- //@{
367
- inline const Value* getForkedFun(const CallSite cs)
368
- {
369
- return ThreadAPI::getThreadAPI()->getForkedFun(cs);
370
- }
371
- inline const Value* getForkedFun(const Instruction *inst)
372
- {
373
- return ThreadAPI::getThreadAPI()->getForkedFun(inst);
374
- }
375
- //@}
376
-
377
306
  /// Return sole argument of the thread routine
378
307
  //@{
379
308
  inline const Value* getActualParmAtForkSite(const CallSite cs)
@@ -413,15 +342,6 @@ inline const Value* getTaskDataAtHareParForSite(const Instruction *inst)
413
342
  /// Return true if this value refers to a object
414
343
  bool isObject (const Value * ref);
415
344
 
416
- /// Return true if the value refers to constant data, e.g., i32 0
417
- inline bool isConstantData(const Value* val)
418
- {
419
- return SVFUtil::isa<ConstantData>(val)
420
- || SVFUtil::isa<ConstantAggregate>(val)
421
- || SVFUtil::isa<MetadataAsValue>(val)
422
- || SVFUtil::isa<BlockAddress>(val);
423
- }
424
-
425
345
  /// Method for dead function, which does not have any possible caller
426
346
  /// function address is not taken and never be used in call or invoke instruction
427
347
  //@{
@@ -436,43 +356,11 @@ inline bool ArgInDeadFunction (const Value * val)
436
356
  }
437
357
  //@}
438
358
 
439
- /// Program entry function e.g. main
440
- //@{
441
- /// Return true if this is a program entry function (e.g. main)
442
- inline bool isProgEntryFunction (const SVFFunction * fun)
443
- {
444
- return fun && fun->getName() == "main";
445
- }
446
-
447
359
  inline bool isProgEntryFunction (const Function * fun)
448
360
  {
449
361
  return fun && fun->getName() == "main";
450
362
  }
451
363
 
452
- /// Get program entry function from module.
453
- inline const SVFFunction* getProgFunction(SVFModule* svfModule, const std::string& funName)
454
- {
455
- for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
456
- {
457
- const SVFFunction *fun = *it;
458
- if (fun->getName()==funName)
459
- return fun;
460
- }
461
- return nullptr;
462
- }
463
-
464
- /// Get program entry function from module.
465
- inline const SVFFunction* getProgEntryFunction(SVFModule* svfModule)
466
- {
467
- for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
468
- {
469
- const SVFFunction *fun = *it;
470
- if (isProgEntryFunction(fun))
471
- return (fun);
472
- }
473
- return nullptr;
474
- }
475
-
476
364
  /// Return true if this is an argument of a program entry function (e.g. main)
477
365
  inline bool ArgInProgEntryFunction (const Value * val)
478
366
  {
@@ -483,15 +371,6 @@ inline bool ArgInProgEntryFunction (const Value * val)
483
371
  bool isPtrInDeadFunction (const Value * value);
484
372
  //@}
485
373
 
486
- /// Return true if this is a program exit function call
487
- //@{
488
- inline bool isProgExitFunction (const SVFFunction * fun)
489
- {
490
- return fun && (fun->getName() == "exit" ||
491
- fun->getName() == "__assert_rtn" ||
492
- fun->getName() == "__assert_fail" );
493
- }
494
-
495
374
  inline bool isProgExitCall(const CallSite cs)
496
375
  {
497
376
  return isProgExitFunction(getCallee(cs));
@@ -677,7 +556,6 @@ u32_t getTypeSizeInBytes(const Type* type);
677
556
  u32_t getTypeSizeInBytes(const StructType *sty, u32_t field_index);
678
557
  //@}
679
558
 
680
- const std::string type2String(const Type* type);
681
559
 
682
560
  } // End namespace SVFUtil
683
561
 
@@ -94,7 +94,6 @@ typedef llvm::Argument Argument;
94
94
  typedef llvm::Constant Constant;
95
95
  typedef llvm::ConstantInt ConstantInt;
96
96
  typedef llvm::ConstantPointerNull ConstantPointerNull;
97
- typedef llvm::ConstantArray ConstantArray;
98
97
  typedef llvm::GlobalAlias GlobalAlias;
99
98
 
100
99
  /// LLVM metadata
@@ -352,6 +352,130 @@ bool startAnalysisLimitTimer(unsigned timeLimit);
352
352
  /// timer or not (return value of startLimitTimer).
353
353
  void stopAnalysisLimitTimer(bool limitTimerSet);
354
354
 
355
+ /// Return true if the call is an external call (external library in function summary table)
356
+ /// If the libary function is redefined in the application code (e.g., memcpy), it will return false and will not be treated as an external call.
357
+ //@{
358
+ inline bool isExtCall(const SVFFunction* fun)
359
+ {
360
+ return fun && ExtAPI::getExtAPI()->is_ext(fun);
361
+ }
362
+
363
+ /// Return true if the call is a heap allocator/reallocator
364
+ //@{
365
+ /// note that these two functions are not suppose to be used externally
366
+ inline bool isHeapAllocExtFunViaRet(const SVFFunction* fun)
367
+ {
368
+ return fun && (ExtAPI::getExtAPI()->is_alloc(fun)
369
+ || ExtAPI::getExtAPI()->is_realloc(fun));
370
+ }
371
+
372
+ inline bool isHeapAllocExtFunViaArg(const SVFFunction* fun)
373
+ {
374
+ return fun && ExtAPI::getExtAPI()->is_arg_alloc(fun);
375
+ }
376
+
377
+ /// Get the position of argument that holds an allocated heap object.
378
+ //@{
379
+ inline int getHeapAllocHoldingArgPosition(const SVFFunction* fun)
380
+ {
381
+ return ExtAPI::getExtAPI()->get_alloc_arg_pos(fun);
382
+ }
383
+
384
+ /// Return true if the call is a heap reallocator
385
+ //@{
386
+ /// note that this function is not suppose to be used externally
387
+ inline bool isReallocExtFun(const SVFFunction* fun)
388
+ {
389
+ return fun && (ExtAPI::getExtAPI()->is_realloc(fun));
390
+ }
391
+
392
+ /// Return true if the call is a heap dealloc or not
393
+ //@{
394
+ /// note that this function is not suppose to be used externally
395
+ inline bool isDeallocExtFun(const SVFFunction* fun)
396
+ {
397
+ return fun && (ExtAPI::getExtAPI()->is_dealloc(fun));
398
+ }
399
+
400
+ /// Return true if the call is a static global call
401
+ //@{
402
+ /// note that this function is not suppose to be used externally
403
+ inline bool isStaticExtFun(const SVFFunction* fun)
404
+ {
405
+ return fun && ExtAPI::getExtAPI()->has_static(fun);
406
+ }
407
+
408
+ /// Return external call type
409
+ inline ExtAPI::extf_t extCallTy(const SVFFunction* fun)
410
+ {
411
+ return ExtAPI::getExtAPI()->get_type(fun);
412
+ }
413
+
414
+ /// Program entry function e.g. main
415
+ //@{
416
+ /// Return true if this is a program entry function (e.g. main)
417
+ inline bool isProgEntryFunction (const SVFFunction * fun)
418
+ {
419
+ return fun && fun->getName() == "main";
420
+ }
421
+
422
+
423
+ /// Get program entry function from module.
424
+ inline const SVFFunction* getProgFunction(SVFModule* svfModule, const std::string& funName)
425
+ {
426
+ for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
427
+ {
428
+ const SVFFunction *fun = *it;
429
+ if (fun->getName()==funName)
430
+ return fun;
431
+ }
432
+ return nullptr;
433
+ }
434
+
435
+ /// Get program entry function from module.
436
+ inline const SVFFunction* getProgEntryFunction(SVFModule* svfModule)
437
+ {
438
+ for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
439
+ {
440
+ const SVFFunction *fun = *it;
441
+ if (isProgEntryFunction(fun))
442
+ return (fun);
443
+ }
444
+ return nullptr;
445
+ }
446
+
447
+ /// Return true if this is a program exit function call
448
+ //@{
449
+ inline bool isProgExitFunction (const SVFFunction * fun)
450
+ {
451
+ return fun && (fun->getName() == "exit" ||
452
+ fun->getName() == "__assert_rtn" ||
453
+ fun->getName() == "__assert_fail" );
454
+ }
455
+
456
+ /// Return true if the value refers to constant data, e.g., i32 0
457
+ inline bool isConstantData(const Value* val)
458
+ {
459
+ return SVFUtil::isa<ConstantData>(val)
460
+ || SVFUtil::isa<ConstantAggregate>(val)
461
+ || SVFUtil::isa<MetadataAsValue>(val)
462
+ || SVFUtil::isa<BlockAddress>(val);
463
+ }
464
+
465
+ /// Return thread fork function
466
+ //@{
467
+ inline const Value* getForkedFun(const CallSite cs)
468
+ {
469
+ return ThreadAPI::getThreadAPI()->getForkedFun(cs);
470
+ }
471
+ inline const Value* getForkedFun(const Instruction *inst)
472
+ {
473
+ return ThreadAPI::getThreadAPI()->getForkedFun(inst);
474
+ }
475
+ //@}
476
+
477
+ const std::string type2String(const Type* type);
478
+
355
479
  } // End namespace SVFUtil
356
480
 
357
481
  } // End namespace SVF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1037",
3
+ "version": "1.0.1038",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {