3030
3131#include < llvm/IR/Constants.h>
3232#include < llvm/IR/Function.h>
33+ #include < llvm/IR/GlobalVariable.h>
3334#include < llvm/IR/InstIterator.h>
3435#include < llvm/IR/Instructions.h>
3536#include < llvm/IR/Module.h>
@@ -61,8 +62,11 @@ const std::string LLVMTypeHierarchy::TypeInfoPrefixDemang = "typeinfo for ";
6162
6263LLVMTypeHierarchy::VertexProperties::VertexProperties (
6364 const llvm::StructType *Type)
64- : Type(Type), TypeName(Type->getStructName ().str()), VFT(),
65- ReachableTypes({Type}) {}
65+ : Type(Type), ReachableTypes({Type}) {}
66+
67+ std::string LLVMTypeHierarchy::VertexProperties::getTypeName () const {
68+ return Type->getStructName ().str ();
69+ }
6670
6771LLVMTypeHierarchy::LLVMTypeHierarchy (ProjectIRDB &IRDB) {
6872 PAMM_GET_INSTANCE;
@@ -337,18 +341,16 @@ bool LLVMTypeHierarchy::empty() const { return size() == 0; }
337341
338342void LLVMTypeHierarchy::print (std::ostream &OS) const {
339343 OS << " Type Hierarchy:\n " ;
340- boost::print_graph (TypeGraph,
341- boost::get (&VertexProperties::TypeName, TypeGraph), OS);
342- // vertex_iterator_t ui, ui_end;
343- // for (boost::tie(ui, ui_end) = boost::vertices(TypeGraph); ui != ui_end;
344- // ++ui) {
345- // OS << TypeGraph[*ui].TypeName << " --> ";
346- // out_edge_iterator_t ei, ei_end;
347- // for (boost::tie(ei, ei_end) = boost::out_edges(*ui, TypeGraph); ei !=
348- // ei_end; ++ei)
349- // OS << TypeGraph[target(*ei, TypeGraph)].TypeName << " ";
350- // OS << '\n';
351- // }
344+ vertex_iterator_t ui, ui_end;
345+ for (boost::tie (ui, ui_end) = boost::vertices (TypeGraph); ui != ui_end;
346+ ++ui) {
347+ OS << TypeGraph[*ui].getTypeName () << " --> " ;
348+ out_edge_iterator_t ei, ei_end;
349+ for (boost::tie (ei, ei_end) = boost::out_edges (*ui, TypeGraph);
350+ ei != ei_end; ++ei)
351+ OS << TypeGraph[target (*ei, TypeGraph)].getTypeName () << " " ;
352+ OS << ' \n ' ;
353+ }
352354 OS << " VFTables:\n " ;
353355 for (const auto &[Ty, VFT] : TypeVFTMap) {
354356 OS << " Virtual function table for: " << Ty->getName ().str () << ' \n ' ;
@@ -365,12 +367,12 @@ nlohmann::json LLVMTypeHierarchy::getAsJson() const {
365367 // iterate all graph vertices
366368 for (boost::tie (vi_v, vi_v_end) = boost::vertices (TypeGraph);
367369 vi_v != vi_v_end; ++vi_v) {
368- J[PhasarConfig::JsonTypeHierarchyID ()][TypeGraph[*vi_v].TypeName ];
370+ J[PhasarConfig::JsonTypeHierarchyID ()][TypeGraph[*vi_v].getTypeName () ];
369371 // iterate all out edges of vertex vi_v
370372 for (boost::tie (ei, ei_end) = boost::out_edges (*vi_v, TypeGraph);
371373 ei != ei_end; ++ei) {
372- J[PhasarConfig::JsonTypeHierarchyID ()][TypeGraph[*vi_v].TypeName ] +=
373- TypeGraph[boost::target (*ei, TypeGraph)].TypeName ;
374+ J[PhasarConfig::JsonTypeHierarchyID ()][TypeGraph[*vi_v].getTypeName () ] +=
375+ TypeGraph[boost::target (*ei, TypeGraph)].getTypeName () ;
374376 }
375377 }
376378 return J;
@@ -424,8 +426,7 @@ nlohmann::json LLVMTypeHierarchy::getAsJson() const {
424426
425427void LLVMTypeHierarchy::printAsDot (std::ostream &OS) const {
426428 boost::write_graphviz (OS, TypeGraph,
427- boost::make_label_writer (boost::get (
428- &VertexProperties::TypeName, TypeGraph)));
429+ makeTypeHierarchyVertexWriter (TypeGraph));
429430}
430431
431432// void LLVMTypeHierarchy::printGraphAsDot(ostream &out) {
0 commit comments