svf-lib 1.0.813 → 1.0.817

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.
@@ -408,13 +408,13 @@ protected:
408
408
  }
409
409
  else
410
410
  {
411
- assert((it->second == node->getId()) && "a SVFIR node can only have unique definition ");
411
+ assert((it->second == node->getId()) && "a SVFVar can only have unique definition ");
412
412
  }
413
413
  }
414
414
  inline NodeID getDef(const PAGNode* pagNode) const
415
415
  {
416
416
  PAGNodeToDefMapTy::const_iterator it = PAGNodeToDefMap.find(pagNode);
417
- assert(it!=PAGNodeToDefMap.end() && "SVFIR node does not have a definition??");
417
+ assert(it!=PAGNodeToDefMap.end() && "SVFVar does not have a definition??");
418
418
  return it->second;
419
419
  }
420
420
  inline bool hasDef(const PAGNode* pagNode) const
@@ -344,18 +344,7 @@ public:
344
344
  /// Get struct info
345
345
  //@{
346
346
  ///Get an iterator for StructInfo, designed as internal methods
347
- TypeToFieldInfoMap::iterator getStructInfoIter(const Type *T)
348
- {
349
- assert(T);
350
- TypeToFieldInfoMap::iterator it = typeToFieldInfo.find(T);
351
- if (it != typeToFieldInfo.end())
352
- return it;
353
- else
354
- {
355
- collectTypeInfo(T);
356
- return typeToFieldInfo.find(T);
357
- }
358
- }
347
+ TypeToFieldInfoMap::iterator getStructInfoIter(const Type *T);
359
348
 
360
349
  ///Get a reference to StructInfo.
361
350
  inline StInfo* getStructInfo(const Type *T)
@@ -364,8 +353,12 @@ public:
364
353
  }
365
354
 
366
355
  ///Get a reference to the components of struct_info.
367
- /// Flatterned full offset information of a struct including its array fields
368
- const std::vector<u32_t>& getFlattenedOffsetVec(const StructType *T);
356
+ /// Number of flattenned elements of an array or struct
357
+ const u32_t getNumOfFlattenElements(const Type *T);
358
+ /// Number of flattenned fields of a struct
359
+ const u32_t getNumOfFlattenFields(const StructType *T);
360
+ /// Flatterned element idx of an array or struct by considering stride
361
+ const std::vector<u32_t>& getFlattenedElemIdxVec(const Type *T);
369
362
  /// Flatterned field index information of a struct ignoring any array field
370
363
  const std::vector<u32_t>& getFlattenedFieldIdxVec(const StructType *T);
371
364
 
@@ -513,14 +506,18 @@ class StInfo
513
506
  private:
514
507
  /// flattened field indices of a struct (ignoring arrays)
515
508
  std::vector<u32_t> fldIdxVec;
516
- /// flattened full offset (including array strides)
517
- std::vector<u32_t> fullOffsetVec;
509
+ /// flattened element indices including structs and arrays by considering strides
510
+ std::vector<u32_t> elemIdxVec;
518
511
  /// Types of all fields of a struct
519
512
  Map<u32_t, const Type*> fldIdx2TypeMap;
520
513
  /// All field infos after flattening a struct
521
514
  std::vector<FlattenedFieldInfo> finfo;
522
515
  /// stride represents the number of repetitive elements if this StInfo represent an ArrayType. stride is 1 by default.
523
516
  u32_t stride;
517
+ /// number of elements after flattenning (including array elements)
518
+ u32_t numOfFlattenElements;
519
+ /// number of fields after flattenning (ignoring array elements)
520
+ u32_t numOfFlattenFields;
524
521
  /// Max field limit
525
522
  static u32_t maxFieldLimit;
526
523
 
@@ -530,7 +527,7 @@ private:
530
527
 
531
528
  public:
532
529
  /// Constructor
533
- StInfo(u32_t s) : stride(s)
530
+ StInfo(u32_t s) : stride(s), numOfFlattenElements(s), numOfFlattenFields(s)
534
531
  {
535
532
  }
536
533
  /// Destructor
@@ -552,28 +549,16 @@ public:
552
549
  /// OriginalFieldType of b with field_idx 1 : Struct A
553
550
  /// FlatternedFieldType of b with field_idx 1 : int
554
551
  //{@
555
- inline const Type* getOriginalFieldType(u32_t fldIdx)
556
- {
557
- Map<u32_t, const Type*>::const_iterator it = fldIdx2TypeMap.find(fldIdx);
558
- if(it!=fldIdx2TypeMap.end())
559
- return it->second;
560
- return nullptr;
561
- }
562
- inline const Type* getFlatternedFieldType(u32_t fldIdx)
563
- {
564
- for(FlattenedFieldInfo& fallenedFld : finfo){
565
- if(fallenedFld.getFlattenFldIdx() == fldIdx)
566
- return fallenedFld.getFlattenElemTy();
567
- }
568
- return nullptr;
569
- }
552
+ const Type* getOriginalFieldType(u32_t fldIdx);
553
+ const Type* getFlatternedFieldType(u32_t fldIdx);
554
+
570
555
  inline std::vector<u32_t>& getFlattenedFieldIdxVec()
571
556
  {
572
557
  return fldIdxVec;
573
558
  }
574
- inline std::vector<u32_t>& getFlattenedOffsetVec()
559
+ inline std::vector<u32_t>& getFlattenedElemIdxVec()
575
560
  {
576
- return fullOffsetVec;
561
+ return elemIdxVec;
577
562
  }
578
563
  inline std::vector<FlattenedFieldInfo>& getFlattenedFieldInfoVec()
579
564
  {
@@ -581,16 +566,27 @@ public:
581
566
  }
582
567
  //@}
583
568
 
584
- /// Add field (index and offset) with its corresponding type
585
- inline void addFldWithType(u32_t fldIdx, const Type* type, u32_t fullOffset)
569
+ /// Add field index and element index and their corresponding type
570
+ void addFldWithType(u32_t fldIdx, const Type* type, u32_t elemIdx);
571
+
572
+ /// Set number of fields and elements of an aggrate
573
+ inline void setNumOfFieldsAndElems(u32_t nf, u32_t ne)
586
574
  {
587
- fldIdxVec.push_back(fldIdx);
588
- fullOffsetVec.push_back(fullOffset);
589
- fldIdx2TypeMap[fldIdx] = type;
575
+ numOfFlattenFields = nf;
576
+ numOfFlattenElements = ne;
590
577
  }
591
578
 
592
- /// Array Type can have
593
- inline u32_t getStride() const {
579
+ /// Return number of elements after flattenning (including array elements)
580
+ inline u32_t getNumOfFlattenElements() const {
581
+ return numOfFlattenElements;
582
+ }
583
+
584
+ /// Return the number of fields after flattenning (ignoring array elements)
585
+ inline u32_t getNumOfFlattenFields() const {
586
+ return numOfFlattenFields;
587
+ }
588
+ /// Return the stride
589
+ inline u32_t getStride() const{
594
590
  return stride;
595
591
  }
596
592
  };
Binary file
@@ -408,13 +408,13 @@ protected:
408
408
  }
409
409
  else
410
410
  {
411
- assert((it->second == node->getId()) && "a SVFIR node can only have unique definition ");
411
+ assert((it->second == node->getId()) && "a SVFVar can only have unique definition ");
412
412
  }
413
413
  }
414
414
  inline NodeID getDef(const PAGNode* pagNode) const
415
415
  {
416
416
  PAGNodeToDefMapTy::const_iterator it = PAGNodeToDefMap.find(pagNode);
417
- assert(it!=PAGNodeToDefMap.end() && "SVFIR node does not have a definition??");
417
+ assert(it!=PAGNodeToDefMap.end() && "SVFVar does not have a definition??");
418
418
  return it->second;
419
419
  }
420
420
  inline bool hasDef(const PAGNode* pagNode) const
@@ -344,18 +344,7 @@ public:
344
344
  /// Get struct info
345
345
  //@{
346
346
  ///Get an iterator for StructInfo, designed as internal methods
347
- TypeToFieldInfoMap::iterator getStructInfoIter(const Type *T)
348
- {
349
- assert(T);
350
- TypeToFieldInfoMap::iterator it = typeToFieldInfo.find(T);
351
- if (it != typeToFieldInfo.end())
352
- return it;
353
- else
354
- {
355
- collectTypeInfo(T);
356
- return typeToFieldInfo.find(T);
357
- }
358
- }
347
+ TypeToFieldInfoMap::iterator getStructInfoIter(const Type *T);
359
348
 
360
349
  ///Get a reference to StructInfo.
361
350
  inline StInfo* getStructInfo(const Type *T)
@@ -364,8 +353,12 @@ public:
364
353
  }
365
354
 
366
355
  ///Get a reference to the components of struct_info.
367
- /// Flatterned full offset information of a struct including its array fields
368
- const std::vector<u32_t>& getFlattenedOffsetVec(const StructType *T);
356
+ /// Number of flattenned elements of an array or struct
357
+ const u32_t getNumOfFlattenElements(const Type *T);
358
+ /// Number of flattenned fields of a struct
359
+ const u32_t getNumOfFlattenFields(const StructType *T);
360
+ /// Flatterned element idx of an array or struct by considering stride
361
+ const std::vector<u32_t>& getFlattenedElemIdxVec(const Type *T);
369
362
  /// Flatterned field index information of a struct ignoring any array field
370
363
  const std::vector<u32_t>& getFlattenedFieldIdxVec(const StructType *T);
371
364
 
@@ -513,14 +506,18 @@ class StInfo
513
506
  private:
514
507
  /// flattened field indices of a struct (ignoring arrays)
515
508
  std::vector<u32_t> fldIdxVec;
516
- /// flattened full offset (including array strides)
517
- std::vector<u32_t> fullOffsetVec;
509
+ /// flattened element indices including structs and arrays by considering strides
510
+ std::vector<u32_t> elemIdxVec;
518
511
  /// Types of all fields of a struct
519
512
  Map<u32_t, const Type*> fldIdx2TypeMap;
520
513
  /// All field infos after flattening a struct
521
514
  std::vector<FlattenedFieldInfo> finfo;
522
515
  /// stride represents the number of repetitive elements if this StInfo represent an ArrayType. stride is 1 by default.
523
516
  u32_t stride;
517
+ /// number of elements after flattenning (including array elements)
518
+ u32_t numOfFlattenElements;
519
+ /// number of fields after flattenning (ignoring array elements)
520
+ u32_t numOfFlattenFields;
524
521
  /// Max field limit
525
522
  static u32_t maxFieldLimit;
526
523
 
@@ -530,7 +527,7 @@ private:
530
527
 
531
528
  public:
532
529
  /// Constructor
533
- StInfo(u32_t s) : stride(s)
530
+ StInfo(u32_t s) : stride(s), numOfFlattenElements(s), numOfFlattenFields(s)
534
531
  {
535
532
  }
536
533
  /// Destructor
@@ -552,28 +549,16 @@ public:
552
549
  /// OriginalFieldType of b with field_idx 1 : Struct A
553
550
  /// FlatternedFieldType of b with field_idx 1 : int
554
551
  //{@
555
- inline const Type* getOriginalFieldType(u32_t fldIdx)
556
- {
557
- Map<u32_t, const Type*>::const_iterator it = fldIdx2TypeMap.find(fldIdx);
558
- if(it!=fldIdx2TypeMap.end())
559
- return it->second;
560
- return nullptr;
561
- }
562
- inline const Type* getFlatternedFieldType(u32_t fldIdx)
563
- {
564
- for(FlattenedFieldInfo& fallenedFld : finfo){
565
- if(fallenedFld.getFlattenFldIdx() == fldIdx)
566
- return fallenedFld.getFlattenElemTy();
567
- }
568
- return nullptr;
569
- }
552
+ const Type* getOriginalFieldType(u32_t fldIdx);
553
+ const Type* getFlatternedFieldType(u32_t fldIdx);
554
+
570
555
  inline std::vector<u32_t>& getFlattenedFieldIdxVec()
571
556
  {
572
557
  return fldIdxVec;
573
558
  }
574
- inline std::vector<u32_t>& getFlattenedOffsetVec()
559
+ inline std::vector<u32_t>& getFlattenedElemIdxVec()
575
560
  {
576
- return fullOffsetVec;
561
+ return elemIdxVec;
577
562
  }
578
563
  inline std::vector<FlattenedFieldInfo>& getFlattenedFieldInfoVec()
579
564
  {
@@ -581,16 +566,27 @@ public:
581
566
  }
582
567
  //@}
583
568
 
584
- /// Add field (index and offset) with its corresponding type
585
- inline void addFldWithType(u32_t fldIdx, const Type* type, u32_t fullOffset)
569
+ /// Add field index and element index and their corresponding type
570
+ void addFldWithType(u32_t fldIdx, const Type* type, u32_t elemIdx);
571
+
572
+ /// Set number of fields and elements of an aggrate
573
+ inline void setNumOfFieldsAndElems(u32_t nf, u32_t ne)
586
574
  {
587
- fldIdxVec.push_back(fldIdx);
588
- fullOffsetVec.push_back(fullOffset);
589
- fldIdx2TypeMap[fldIdx] = type;
575
+ numOfFlattenFields = nf;
576
+ numOfFlattenElements = ne;
590
577
  }
591
578
 
592
- /// Array Type can have
593
- inline u32_t getStride() const {
579
+ /// Return number of elements after flattenning (including array elements)
580
+ inline u32_t getNumOfFlattenElements() const {
581
+ return numOfFlattenElements;
582
+ }
583
+
584
+ /// Return the number of fields after flattenning (ignoring array elements)
585
+ inline u32_t getNumOfFlattenFields() const {
586
+ return numOfFlattenFields;
587
+ }
588
+ /// Return the stride
589
+ inline u32_t getStride() const{
594
590
  return stride;
595
591
  }
596
592
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.813",
3
+ "version": "1.0.817",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {