svf-lib 1.0.1704 → 1.0.1706

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.
@@ -350,19 +350,26 @@ private:
350
350
  const SVFType* ptrElementType;
351
351
 
352
352
  public:
353
- SVFPointerType(const SVFType* pty)
354
- : SVFType(true, SVFPointerTy), ptrElementType(pty)
353
+ SVFPointerType()
354
+ : SVFType(true, SVFPointerTy), ptrElementType(nullptr)
355
355
  {
356
356
  }
357
+
357
358
  static inline bool classof(const SVFType* node)
358
359
  {
359
360
  return node->getKind() == SVFPointerTy;
360
361
  }
361
362
  inline const SVFType* getPtrElementType() const
362
363
  {
364
+ assert(ptrElementType && "ptrElementType is nullptr");
363
365
  return ptrElementType;
364
366
  }
365
367
 
368
+ inline void setPtrElementType(SVFType* _ptrElementType)
369
+ {
370
+ ptrElementType = _ptrElementType;
371
+ }
372
+
366
373
  void print(std::ostream& os) const override;
367
374
  };
368
375
 
@@ -119,7 +119,7 @@ inline bool isNullPtrSym(const Value* val)
119
119
  static inline Type* getPtrElementType(const PointerType* pty)
120
120
  {
121
121
  #if (LLVM_VERSION_MAJOR < 14)
122
- return pty->getElementType();
122
+ return pty->getPointerElementType();
123
123
  #else
124
124
  assert(!pty->isOpaque() && "Opaque Pointer is used, please recompile the source adding '-Xclang -no-opaque-pointers'");
125
125
  return pty->getNonOpaquePointerElementType();
@@ -384,11 +384,14 @@ void removeUnusedFuncsAndAnnotationsAndGlobalVariables(std::vector<Function*> re
384
384
  inline u32_t SVFType2ByteSize(const SVFType* type)
385
385
  {
386
386
  const llvm::Type* llvm_rhs = LLVMModuleSet::getLLVMModuleSet()->getLLVMType(type);
387
- u32_t llvm_rhs_size = LLVMUtil::getTypeSizeInBytes(llvm_rhs->getPointerElementType());
387
+ const llvm::PointerType* llvm_rhs_ptr = SVFUtil::dyn_cast<PointerType>(llvm_rhs);
388
+ assert(llvm_rhs_ptr && "not a pointer type?");
389
+ const Type *ptrElementType = getPtrElementType(llvm_rhs_ptr);
390
+ u32_t llvm_rhs_size = LLVMUtil::getTypeSizeInBytes(ptrElementType);
388
391
  u32_t llvm_elem_size = -1;
389
- if (llvm_rhs->getPointerElementType()->isArrayTy() && llvm_rhs_size > 0)
392
+ if (ptrElementType->isArrayTy() && llvm_rhs_size > 0)
390
393
  {
391
- size_t array_len = llvm_rhs->getPointerElementType()->getArrayNumElements();
394
+ size_t array_len = ptrElementType->getArrayNumElements();
392
395
  llvm_elem_size = llvm_rhs_size / array_len;
393
396
  }
394
397
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1704",
3
+ "version": "1.0.1706",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {