svf-lib 1.0.2618 → 1.0.2619

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.
@@ -155,28 +155,6 @@ bool isDynCast(const Function *foo);
155
155
  std::string extractClsNameFromDynCast(const CallBase* callBase);
156
156
 
157
157
  const Type *cppClsNameToType(const std::string &className);
158
-
159
-
160
-
161
- /// Constants pertaining to CTir, for C and C++.
162
- /// TODO: move helper functions here too?
163
- namespace ctir
164
- {
165
- /// On loads, stores, GEPs representing dereferences, and calls
166
- /// representing virtual calls.
167
- /// (The static type.)
168
- const std::string derefMDName = "ctir";
169
- /// On the (global) virtual table itself.
170
- /// (The class it corresponds to.)
171
- const std::string vtMDName = "ctir.vt";
172
- /// On the bitcast of `this` to i8*.
173
- /// (The class the constructor it corresponds to.)
174
- const std::string vtInitMDName = "ctir.vt.init";
175
-
176
- /// Value we expect a ctir-annotated module to have.
177
- const uint32_t moduleFlagValue = 1;
178
- } // namespace ctir
179
-
180
158
  } // End namespace cppUtil
181
159
 
182
160
  } // End namespace SVF
@@ -148,7 +148,6 @@ public:
148
148
  CHNodeKd, // Class hierarchy graph node
149
149
  ConstraintNodeKd, // Constraint graph node
150
150
  TCTNodeKd, // Thread creation tree node
151
- DCHNodeKd, // DCHG node
152
151
  BasicBlockKd, // Basic block node
153
152
  OtherKd // Other node kind
154
153
  };
@@ -172,9 +172,6 @@ public:
172
172
  // CHG.cpp
173
173
  static const Option<bool> DumpCHA;
174
174
 
175
- // DCHG.cpp
176
- static const Option<bool> PrintDCHG;
177
-
178
175
  // LLVMModule.cpp
179
176
  static const Option<std::string> Graphtxt;
180
177
  static Option<bool> SVFMain;
@@ -103,7 +103,7 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.23.0")
103
103
  FILE_SET "HEADERS"
104
104
  TYPE "HEADERS"
105
105
  BASE_DIRS "${_IMPORT_PREFIX}/include"
106
- FILES "${_IMPORT_PREFIX}/include/SVF-LLVM/BasicTypes.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/BreakConstantExpr.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/CHGBuilder.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/CppUtil.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/DCHG.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/GEPTypeBridgeIterator.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/ICFGBuilder.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/LLVMLoopAnalysis.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/LLVMModule.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/LLVMUtil.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/ObjTypeInference.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/SVFIRBuilder.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/SymbolTableBuilder.h"
106
+ FILES "${_IMPORT_PREFIX}/include/SVF-LLVM/BasicTypes.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/BreakConstantExpr.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/CHGBuilder.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/CppUtil.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/GEPTypeBridgeIterator.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/ICFGBuilder.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/LLVMLoopAnalysis.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/LLVMModule.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/LLVMUtil.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/ObjTypeInference.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/SVFIRBuilder.h" "${_IMPORT_PREFIX}/include/SVF-LLVM/SymbolTableBuilder.h"
107
107
  )
108
108
  else()
109
109
  set_property(TARGET SVF::SvfLLVM
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2618",
3
+ "version": "1.0.2619",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,473 +0,0 @@
1
- //===----- DCHG.h -- CHG using DWARF debug info ---------------------------//
2
- // This is based upon the original CHA.h (now CHG.h).
3
-
4
- /*
5
- * DCHG.h
6
- *
7
- * Created on: Aug 23, 2019
8
- * Author: Mohamad Barbar
9
- */
10
-
11
- // TODO: add a flag such that getCanonicalType returns its arg so
12
- // that the impl. does not "node collapsing" based on teq.
13
-
14
- #ifndef DCHG_H_
15
- #define DCHG_H_
16
-
17
- #include "Graphs/GenericGraph.h"
18
- #include "Graphs/CHG.h"
19
- #include "SVF-LLVM/BasicTypes.h"
20
- #include "Util/SVFUtil.h"
21
- #include "Util/WorkList.h"
22
-
23
- namespace SVF
24
- {
25
-
26
- class DCHNode;
27
-
28
- class DCHEdge : public GenericEdge<DCHNode>
29
- {
30
- public:
31
- enum
32
- {
33
- INHERITANCE, // inheritance relation
34
- INSTANCE, // template-instance relation
35
- FIRST_FIELD, // src -ff-> dst => dst is first field of src
36
- STD_DEF // Edges defined by the standard like (int -std-> char)
37
- // We also make the char --> void edge a STD_DEF edge.
38
- };
39
-
40
- typedef GenericNode<DCHNode, DCHEdge>::GEdgeSetTy DCHEdgeSetTy;
41
-
42
- DCHEdge(DCHNode *src, DCHNode *dst, GEdgeFlag k = 0)
43
- : GenericEdge<DCHNode>(src, dst, k), offset(0)
44
- {
45
- }
46
-
47
- u32_t getConstantFieldIdx(void) const
48
- {
49
- return offset;
50
- }
51
-
52
- void setOffset(u32_t offset)
53
- {
54
- this->offset = offset;
55
- }
56
-
57
- private:
58
- u32_t offset;
59
- };
60
-
61
- class DCHNode : public GenericNode<DCHNode, DCHEdge>
62
- {
63
- public:
64
- typedef enum
65
- {
66
- PURE_ABSTRACT = 0x1, // pure virtual abstract class
67
- MULTI_INHERITANCE = 0x2, // multi inheritance class
68
- TEMPLATE = 0x04, // template class
69
- SCALAR = 0x08 // non-class scalar type
70
- } CLASSATTR;
71
-
72
- typedef std::vector<const Function*> FuncVector;
73
-
74
- DCHNode(const DIType* diType, NodeID i = 0, GNodeK k = GNodeK::DCHNodeKd)
75
- : GenericNode<DCHNode, DCHEdge>(i, k), vtable(nullptr), flags(0)
76
- {
77
- this->diType = diType;
78
- if (diType == nullptr)
79
- {
80
- typeName = "null-void";
81
- }
82
- else if (diType->getRawName() != nullptr)
83
- {
84
- typeName = diType->getName().str();
85
- }
86
- else
87
- {
88
- typeName = "unnamed!";
89
- }
90
- }
91
-
92
- ~DCHNode() { }
93
-
94
- const DIType * getDIType(void) const
95
- {
96
- return diType;
97
- }
98
-
99
- virtual const std::string& getName() const
100
- {
101
- return typeName;
102
- }
103
-
104
- /// Flags
105
- //@{
106
- inline void setFlag(CLASSATTR mask)
107
- {
108
- flags |= mask;
109
- }
110
- inline bool hasFlag(CLASSATTR mask) const
111
- {
112
- return (flags & mask) == mask;
113
- }
114
- //@}
115
-
116
- /// Attribute
117
- //@{
118
- inline void setPureAbstract()
119
- {
120
- setFlag(PURE_ABSTRACT);
121
- }
122
- inline void setMultiInheritance()
123
- {
124
- setFlag(MULTI_INHERITANCE);
125
- }
126
- inline void setTemplate()
127
- {
128
- setFlag(TEMPLATE);
129
- }
130
- inline void setScalar()
131
- {
132
- setFlag(SCALAR);
133
- }
134
- inline bool isPureAbstract() const
135
- {
136
- return hasFlag(PURE_ABSTRACT);
137
- }
138
- inline bool isMultiInheritance() const
139
- {
140
- return hasFlag(MULTI_INHERITANCE);
141
- }
142
- inline bool isTemplate() const
143
- {
144
- return hasFlag(TEMPLATE);
145
- }
146
- inline bool isScalar() const
147
- {
148
- return hasFlag(SCALAR);
149
- }
150
- //@}
151
-
152
- void addTypedef(const DIDerivedType *diTypedef)
153
- {
154
- typedefs.insert(diTypedef);
155
- }
156
-
157
- const Set<const DIDerivedType *> &getTypedefs(void) const
158
- {
159
- return typedefs;
160
- }
161
-
162
- void setVTable(const GlobalObjVar *vtbl)
163
- {
164
- vtable = vtbl;
165
- }
166
-
167
- const GlobalObjVar *getVTable() const
168
- {
169
- return vtable;
170
- }
171
-
172
- /// Returns the vector of virtual function vectors.
173
- const std::vector<std::vector<const Function* >> &getVfnVectors(void) const
174
- {
175
- return vfnVectors;
176
- }
177
-
178
- /// Return the nth virtual function vector in the vtable.
179
- std::vector<const Function* > &getVfnVector(unsigned n)
180
- {
181
- if (vfnVectors.size() < n + 1)
182
- {
183
- vfnVectors.resize(n + 1);
184
- }
185
-
186
- return vfnVectors[n];
187
- }
188
-
189
- private:
190
- /// Type of this node.
191
- const DIType *diType;
192
- /// Typedefs which map to this type.
193
- Set<const DIDerivedType *> typedefs;
194
- const GlobalObjVar* vtable;
195
- std::string typeName;
196
- size_t flags;
197
- /// The virtual functions which this class actually defines/overrides.
198
- std::vector<const Function* > primaryVTable;
199
- /// If a vtable is split into more than one vfn vector for multiple inheritance,
200
- /// 0 would be the primary base + this classes virtual functions, 1 would be
201
- /// the second parent, 2 would be third parent, etc.
202
- std::vector<std::vector<const Function*>> vfnVectors;
203
- };
204
-
205
- /// Dwarf based CHG.
206
- class DCHGraph : public CommonCHGraph, public GenericGraph<DCHNode, DCHEdge>
207
- {
208
- public:
209
- /// Returns the DIType beneath the qualifiers. Does not strip away "DW_TAG_members".
210
- static const DIType* stripQualifiers(const DIType*);
211
-
212
- /// Returns the DIType beneath all qualifiers and arrays.
213
- static const DIType* stripArray(const DIType*);
214
-
215
- /// Returns true if t1 and t2 are equivalent, ignoring qualifiers.
216
- /// For equality...
217
- /// Tags always need to be equal.
218
- /// DIBasicType: shallow pointer equality.
219
- /// DIDerivedType: base types (teq).
220
- /// DICompositeType: shallow pointer equality.
221
- /// DISubroutineType: shallow pointer equality.
222
- static bool teq(const DIType* t1, const DIType* t2);
223
-
224
- /// Returns a human-readable version of the DIType.
225
- static std::string diTypeToStr(const DIType *);
226
-
227
- // Returns whether t is an array, a struct, a class, a union, or neither.
228
- static bool isAgg(const DIType* t);
229
-
230
- public:
231
- DCHGraph()
232
- :numTypes(0) // vfID(0), buildingCHGTime(0) {
233
- {
234
- this->kind = DI;
235
- }
236
-
237
- virtual ~DCHGraph() { };
238
-
239
- /// Builds the CHG from DWARF debug information. extend determines
240
- /// whether to extend the CHG with first field edges.
241
- virtual void buildCHG(bool extend);
242
-
243
- void dump(const std::string& filename)
244
- {
245
- GraphPrinter::WriteGraphToFile(SVFUtil::outs(), filename, this);
246
- }
247
-
248
- void print(void);
249
-
250
- virtual bool csHasVFnsBasedonCHA(const CallICFGNode* cs) override
251
- {
252
- return csHasVtblsBasedonCHA(cs);
253
- }
254
-
255
- virtual const VFunSet &getCSVFsBasedonCHA(const CallICFGNode* cs) override;
256
-
257
- virtual bool csHasVtblsBasedonCHA(CallBase* cs)
258
- {
259
- assert(false && "not supported");
260
- const DIType *type = getCanonicalType(getCSStaticType(cs));
261
- if (!hasNode(type))
262
- {
263
- return false;
264
- }
265
-
266
- return getNode(type)->getVTable() != nullptr;
267
- }
268
-
269
- virtual bool csHasVtblsBasedonCHA(const CallICFGNode* cs) override
270
- {
271
- assert(false && "not supported!");
272
- abort();
273
- }
274
-
275
- virtual const VTableSet &getCSVtblsBasedonCHA(const CallICFGNode* cs) override;
276
- virtual void getVFnsFromVtbls(const CallICFGNode* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
277
-
278
- /// Returns true if a is a transitive base of b. firstField determines
279
- /// whether to consider first-field edges.
280
- virtual bool isBase(const DIType *a, const DIType *b, bool firstField);
281
-
282
- /// Returns true if f is a field of b (fields from getFieldTypes).
283
- virtual bool isFieldOf(const DIType *f, const DIType *b);
284
-
285
- static inline bool classof(const CommonCHGraph *chg)
286
- {
287
- return chg->getKind() == DI;
288
- }
289
-
290
- /// Returns the type representing all qualifier-variations of t.
291
- /// This should only matter in the case of DerivedTypes where
292
- /// qualifiers and have qualified base types cause a mess.
293
- const DIType* getCanonicalType(const DIType* t);
294
-
295
- /// Returns the type of field number idx (flattened) in base.
296
- const DIType *getFieldType(const DIType *base, unsigned idx)
297
- {
298
- base = getCanonicalType(base);
299
- if (base == nullptr)
300
- {
301
- // Conservative; the base object is untyped, sadly.
302
- return nullptr;
303
- }
304
-
305
- // For TBHC this is conservative because the union type is lower in the DCHG
306
- // than its fields. TODO: make more precise.
307
- if (base->getTag() == dwarf::DW_TAG_union_type)
308
- {
309
- return base;
310
- }
311
-
312
- if (base->getTag() == dwarf::DW_TAG_array_type)
313
- {
314
- const DICompositeType* cbase =
315
- SVFUtil::dyn_cast<DICompositeType>(base);
316
- assert(cbase && "DCHG: bad DIComposite case");
317
- return cbase->getBaseType();
318
- }
319
-
320
- if (!(base->getTag() == dwarf::DW_TAG_class_type ||
321
- base->getTag() == dwarf::DW_TAG_structure_type))
322
- {
323
- return nullptr;
324
- }
325
-
326
- assert(fieldTypes.find(base) != fieldTypes.end() && "DCHG: base not flattened!");
327
- std::vector<const DIType *> &fields = fieldTypes[base];
328
- assert(fields.size() > idx && "DCHG: idx into struct larger than # fields!");
329
- return getCanonicalType(fields[idx]);
330
- }
331
-
332
- /// Returns a vector of the types of all fields in base.
333
- const std::vector<const DIType *> &getFieldTypes(const DIType *base)
334
- {
335
- base = getCanonicalType(base);
336
- assert(fieldTypes.find(base) != fieldTypes.end() && "DCHG: base not flattened!");
337
- return fieldTypes[base];
338
- }
339
-
340
- // Returns the number of fields in base (length of getFieldTypes).
341
- unsigned getNumFields(const DIType *base)
342
- {
343
- base = getCanonicalType(base);
344
- assert(fieldTypes.find(base) != fieldTypes.end() && "DCHG: base not flattened!");
345
- return fieldTypes[base].size();
346
- }
347
-
348
- /// Returns all the aggregates contained (transitively) in base.
349
- const Set<const DIType *> &getAggs(const DIType *base)
350
- {
351
- base = getCanonicalType(base);
352
- assert(containingAggs.find(base) != containingAggs.end() && "DCHG: aggregates not gathered for base!");
353
- return containingAggs[base];
354
- }
355
-
356
- bool isFirstField(const DIType* f, const DIType* b);
357
-
358
- protected:
359
- /// Whether this CHG is an extended CHG (first-field). Set by buildCHG.
360
- bool extended = false;
361
- /// Maps DITypes to their nodes.
362
- Map<const DIType*, DCHNode*> diTypeToNodeMap;
363
- /// Maps VTables to the DIType associated with them.
364
- Map<const GlobalObjVar*, const DIType*> vtblToTypeMap;
365
- /// Maps types to all children (i.e. CHA).
366
- Map<const DIType*, NodeBS> chaMap;
367
- /// Maps types to all children but also considering first field.
368
- Map<const DIType*, NodeBS> chaFFMap;
369
- /// Maps types to a set with their vtable and all their children's.
370
- Map<const DIType*, VTableSet> vtblCHAMap;
371
- /// Maps callsites to a set of potential virtual functions based on CHA.
372
- Map<const CallICFGNode*, VFunSet> csCHAMap;
373
- /// Maps types to their canonical type (many-to-one).
374
- Map<const DIType*, const DIType*> canonicalTypeMap;
375
- /// Set of all possible canonical types (i.e. values of canonicalTypeMap).
376
- Set<const DIType*> canonicalTypes;
377
- /// Maps types to their flattened fields' types.
378
- Map<const DIType*, std::vector<const DIType*>> fieldTypes;
379
- /// Maps aggregate types to all the aggregate types it transitively contains.
380
- Map<const DIType*, Set<const DIType*>> containingAggs;
381
-
382
- private:
383
- /// Construction helper to process DIBasicTypes.
384
- void handleDIBasicType(const DIBasicType* basicType);
385
- /// Construction helper to process DICompositeTypes.
386
- void handleDICompositeType(const DICompositeType* compositeType);
387
- /// Construction helper to process DIDerivedTypes.
388
- void handleDIDerivedType(const DIDerivedType* derivedType);
389
- /// Construction helper to process DISubroutineTypes.
390
- void handleDISubroutineType(const DISubroutineType* subroutineType);
391
-
392
- /// Finds all defined virtual functions and attaches them to nodes.
393
- void buildVTables();
394
-
395
- /// Returns a set of all children of type (CHA). Also gradually builds chaMap.
396
- const NodeBS& cha(const DIType* type, bool firstField);
397
-
398
- /// Attaches the typedef(s) to the base node.
399
- void handleTypedef(const DIType* typedefType);
400
-
401
- /// Populates fieldTypes for type and all its elements.
402
- void flatten(const DICompositeType* type);
403
-
404
- /// Populates containingAggs for type and all its elements.
405
- void gatherAggs(const DICompositeType* type);
406
-
407
- /// Creates a node from type, or returns it if it exists.
408
- DCHNode* getOrCreateNode(const DIType* type);
409
-
410
- /// Retrieves the metadata associated with a *virtual* callsite.
411
- const DIType* getCSStaticType(CallBase* cs) const;
412
-
413
- const DIType *getCSStaticType(const CallICFGNode* cs) const
414
- {
415
- assert(false && "not supported!");
416
- abort();
417
- }
418
-
419
- /// Checks if a node exists for type.
420
- bool hasNode(const DIType* type)
421
- {
422
- type = getCanonicalType(type);
423
- return diTypeToNodeMap.find(type) != diTypeToNodeMap.end();
424
- }
425
-
426
- /// Returns the node for type (nullptr if it doesn't exist).
427
- DCHNode* getNode(const DIType* type)
428
- {
429
- type = getCanonicalType(type);
430
- if (hasNode(type))
431
- {
432
- return diTypeToNodeMap.at(type);
433
- }
434
-
435
- return nullptr;
436
- }
437
-
438
-
439
- /// Creates an edge between from t1 to t2.
440
- DCHEdge* addEdge(const DIType* t1, const DIType* t2, DCHEdge::GEdgeKind et);
441
- /// Returns the edge between t1 and t2 if it exists, returns nullptr otherwise.
442
- DCHEdge* hasEdge(const DIType* t1, const DIType* t2, DCHEdge::GEdgeKind et);
443
-
444
- /// Number of types (nodes) in the graph.
445
- NodeID numTypes;
446
- };
447
-
448
- } // End namespace SVF
449
-
450
- namespace SVF
451
- {
452
- /* !
453
- * GenericGraphTraits specializations for generic graph algorithms.
454
- * Provide graph traits for traversing from a constraint node using standard graph traversals.
455
- */
456
- template<> struct GenericGraphTraits<SVF::DCHNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::DCHNode,SVF::DCHEdge>* >
457
- {
458
- };
459
-
460
- /// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
461
- template<>
462
- struct GenericGraphTraits<Inverse<SVF::DCHNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::DCHNode,SVF::DCHEdge>* > >
463
- {
464
- };
465
-
466
- template<> struct GenericGraphTraits<SVF::DCHGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::DCHNode,SVF::DCHEdge>* >
467
- {
468
- typedef SVF::DCHNode *NodeRef;
469
- };
470
-
471
- } // End namespace llvm
472
-
473
- #endif /* DCHG_H_ */