84 else if (
diType->getRawName() !=
nullptr)
261 assert(
false &&
"not supported");
273 assert(
false &&
"not supported!");
309 if (base->getTag() == dwarf::DW_TAG_union_type)
314 if (base->getTag() == dwarf::DW_TAG_array_type)
317 SVFUtil::dyn_cast<DICompositeType>(base);
319 return cbase->getBaseType();
322 if (!(base->getTag() == dwarf::DW_TAG_class_type ||
323 base->getTag() == dwarf::DW_TAG_structure_type))
330 assert(
fields.size() >
idx &&
"DCHG: idx into struct larger than # fields!");
419 assert(
false &&
"not supported!");
Common base for class hierarchy graph. Only implements what PointerAnalysis needs.
CHGKind getKind(void) const
DCHEdge(DCHNode *src, DCHNode *dst, GEdgeFlag k=0)
u32_t getConstantFieldIdx(void) const
void setOffset(u32_t offset)
GenericNode< DCHNode, DCHEdge >::GEdgeSetTy DCHEdgeSetTy
const DIType * getCSStaticType(CallBase *cs) const
Retrieves the metadata associated with a virtual callsite.
unsigned getNumFields(const DIType *base)
const DIType * getCanonicalType(const DIType *t)
const NodeBS & cha(const DIType *type, bool firstField)
Returns a set of all children of type (CHA). Also gradually builds chaMap.
void buildVTables(const SVFModule &module)
Finds all defined virtual functions and attaches them to nodes.
const Set< const DIType * > & getAggs(const DIType *base)
Returns all the aggregates contained (transitively) in base.
const DIType * getFieldType(const DIType *base, unsigned idx)
Returns the type of field number idx (flattened) in base.
static const DIType * stripQualifiers(const DIType *)
Returns the DIType beneath the qualifiers. Does not strip away "DW_TAG_members".
void handleDIDerivedType(const DIDerivedType *derivedType)
Construction helper to process DIDerivedTypes.
DCHEdge * addEdge(const DIType *t1, const DIType *t2, DCHEdge::GEdgeKind et)
Creates an edge between from t1 to t2.
bool isFirstField(const DIType *f, const DIType *b)
static std::string diTypeToStr(const DIType *)
Returns a human-readable version of the DIType.
void handleDICompositeType(const DICompositeType *compositeType)
Construction helper to process DICompositeTypes.
Map< const CallICFGNode *, VFunSet > csCHAMap
Maps callsites to a set of potential virtual functions based on CHA.
bool hasNode(const DIType *type)
Checks if a node exists for type.
void dump(const std::string &filename)
Map< const DIType *, NodeBS > chaFFMap
Maps types to all children but also considering first field.
DCHNode * getNode(const DIType *type)
Returns the node for type (nullptr if it doesn't exist).
Map< const DIType *, const DIType * > canonicalTypeMap
Maps types to their canonical type (many-to-one).
void handleDISubroutineType(const DISubroutineType *subroutineType)
Construction helper to process DISubroutineTypes.
virtual void getVFnsFromVtbls(const CallICFGNode *cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override
static const DIType * stripArray(const DIType *)
Returns the DIType beneath all qualifiers and arrays.
void handleTypedef(const DIType *typedefType)
Attaches the typedef(s) to the base node.
virtual void buildCHG(bool extend)
virtual bool csHasVFnsBasedonCHA(const CallICFGNode *cs) override
DCHEdge * hasEdge(const DIType *t1, const DIType *t2, DCHEdge::GEdgeKind et)
Returns the edge between t1 and t2 if it exists, returns nullptr otherwise.
NodeID numTypes
Number of types (nodes) in the graph.
DCHGraph(const SVFModule *svfMod)
const SVFModule * svfModule
SVF Module this CHG is built from.
void handleDIBasicType(const DIBasicType *basicType)
Construction helper to process DIBasicTypes.
virtual const VTableSet & getCSVtblsBasedonCHA(const CallICFGNode *cs) override
void gatherAggs(const DICompositeType *type)
Populates containingAggs for type and all its elements.
static bool isAgg(const DIType *t)
DCHNode * getOrCreateNode(const DIType *type)
Creates a node from type, or returns it if it exists.
Map< const DIType *, VTableSet > vtblCHAMap
Maps types to a set with their vtable and all their children's.
bool extended
Whether this CHG is an extended CHG (first-field). Set by buildCHG.
const std::vector< const DIType * > & getFieldTypes(const DIType *base)
Returns a vector of the types of all fields in base.
Map< const DIType *, Set< const DIType * > > containingAggs
Maps aggregate types to all the aggregate types it transitively contains.
virtual bool isBase(const DIType *a, const DIType *b, bool firstField)
void flatten(const DICompositeType *type)
Populates fieldTypes for type and all its elements.
const DIType * getCSStaticType(const CallICFGNode *cs) const
virtual const VFunSet & getCSVFsBasedonCHA(const CallICFGNode *cs) override
static bool teq(const DIType *t1, const DIType *t2)
Map< const DIType *, std::vector< const DIType * > > fieldTypes
Maps types to their flattened fields' types.
Map< const DIType *, NodeBS > chaMap
Maps types to all children (i.e. CHA).
Map< const DIType *, DCHNode * > diTypeToNodeMap
Maps DITypes to their nodes.
virtual bool csHasVtblsBasedonCHA(const CallICFGNode *cs) override
virtual bool isFieldOf(const DIType *f, const DIType *b)
Returns true if f is a field of b (fields from getFieldTypes).
Map< const SVFGlobalValue *, const DIType * > vtblToTypeMap
Maps VTables to the DIType associated with them.
static bool classof(const CommonCHGraph *chg)
Set< const DIType * > canonicalTypes
Set of all possible canonical types (i.e. values of canonicalTypeMap).
virtual bool csHasVtblsBasedonCHA(CallBase *cs)
const DIType * diType
Type of this node.
std::string getName() const
bool isMultiInheritance() const
void setFlag(CLASSATTR mask)
Flags.
std::vector< const Function * > primaryVTable
The virtual functions which this class actually defines/overrides.
bool hasFlag(CLASSATTR mask) const
void setMultiInheritance()
const SVFGlobalValue * getVTable() const
const std::vector< std::vector< const Function * > > & getVfnVectors(void) const
Returns the vector of virtual function vectors.
DCHNode(const DIType *diType, NodeID i=0, GNodeK k=GNodeK::DCHNodeKd)
void addTypedef(const DIDerivedType *diTypedef)
std::vector< const Function * > & getVfnVector(unsigned n)
Return the nth virtual function vector in the vtable.
Set< const DIDerivedType * > typedefs
Typedefs which map to this type.
const DIType * getDIType(void) const
const SVFGlobalValue * vtable
void setVTable(const SVFGlobalValue *vtbl)
const Set< const DIDerivedType * > & getTypedefs(void) const
std::vector< const Function * > FuncVector
bool isPureAbstract() const
std::vector< std::vector< const Function * > > vfnVectors
void setPureAbstract()
Attribute.
DCHNode * dst
destination node
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
const std::string & getName() const
std::ostream & outs()
Overwrite llvm::outs()
llvm::DISubroutineType DISubroutineType
Set< const SVFGlobalValue * > VTableSet
llvm::DIDerivedType DIDerivedType
llvm::IRBuilder IRBuilder
Set< const SVFFunction * > VFunSet
llvm::DIBasicType DIBasicType
llvm::DICompositeType DICompositeType