Skip to content

Commit bc9eeea

Browse files
authored
Merge pull request #1848 from mbarbar/graph-shape
Correct shapes for DOT graph nodes
2 parents 4c6e1ff + 6bfe1bf commit bc9eeea

8 files changed

Lines changed: 88 additions & 81 deletions

File tree

svf/include/Graphs/CDG.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,35 +420,35 @@ struct DOTGraphTraits<SVF::CDG *> : public DOTGraphTraits<SVF::PAG *>
420420
std::stringstream rawstr(str);
421421
const SVF::ICFGNode *icfgNode = node->getICFGNode();
422422

423+
rawstr << "shape=record";
424+
423425
if (SVF::SVFUtil::isa<SVF::IntraICFGNode>(icfgNode))
424426
{
425-
rawstr << "color=black";
427+
rawstr << ",color=black";
426428
}
427429
else if (SVF::SVFUtil::isa<SVF::FunEntryICFGNode>(icfgNode))
428430
{
429-
rawstr << "color=yellow";
431+
rawstr << ",color=yellow";
430432
}
431433
else if (SVF::SVFUtil::isa<SVF::FunExitICFGNode>(icfgNode))
432434
{
433-
rawstr << "color=green";
435+
rawstr << ",color=green";
434436
}
435437
else if (SVF::SVFUtil::isa<SVF::CallICFGNode>(icfgNode))
436438
{
437-
rawstr << "color=red";
439+
rawstr << ",color=red";
438440
}
439441
else if (SVF::SVFUtil::isa<SVF::RetICFGNode>(icfgNode))
440442
{
441-
rawstr << "color=blue";
443+
rawstr << ",color=blue";
442444
}
443445
else if (SVF::SVFUtil::isa<SVF::GlobalICFGNode>(icfgNode))
444446
{
445-
rawstr << "color=purple";
447+
rawstr << ",color=purple";
446448
}
447449
else
448450
assert(false && "no such kind of node!!");
449451

450-
rawstr << "";
451-
452452
return rawstr.str();
453453
}
454454

@@ -479,4 +479,4 @@ struct DOTGraphTraits<SVF::CDG *> : public DOTGraphTraits<SVF::PAG *>
479479
};
480480

481481
} // End namespace SVF
482-
#endif //SVF_CONTROLDG_H
482+
#endif //SVF_CONTROLDG_H

svf/include/Graphs/GraphWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class GraphWriter
171171
{
172172
std::string NodeAttributes = DTraits.getNodeAttributes(Node, G);
173173

174-
O << "\tNode" << static_cast<const void*>(Node) << " [shape=record,";
174+
O << "\tNode" << static_cast<const void*>(Node) << " [";
175175
if (!NodeAttributes.empty()) O << NodeAttributes << ",";
176176
O << "label=\"{";
177177

svf/lib/Graphs/CallGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ struct DOTGraphTraits<CallGraph*> : public DefaultDOTGraphTraits
449449
const FunObjVar* fun = node->getFunction();
450450
if (!SVFUtil::isExtCall(fun))
451451
{
452-
return "shape=box";
452+
return "shape=record";
453453
}
454454
else
455455
return "shape=Mrecord";

svf/lib/Graphs/ICFG.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,35 +516,35 @@ struct DOTGraphTraits<ICFG*> : public DOTGraphTraits<SVFIR*>
516516
std::string str;
517517
std::stringstream rawstr(str);
518518

519+
rawstr << "shape=record";
520+
519521
if(SVFUtil::isa<IntraICFGNode>(node))
520522
{
521-
rawstr << "color=black";
523+
rawstr << ",color=black";
522524
}
523525
else if(SVFUtil::isa<FunEntryICFGNode>(node))
524526
{
525-
rawstr << "color=yellow";
527+
rawstr << ",color=yellow";
526528
}
527529
else if(SVFUtil::isa<FunExitICFGNode>(node))
528530
{
529-
rawstr << "color=green";
531+
rawstr << ",color=green";
530532
}
531533
else if(SVFUtil::isa<CallICFGNode>(node))
532534
{
533-
rawstr << "color=red";
535+
rawstr << ",color=red";
534536
}
535537
else if(SVFUtil::isa<RetICFGNode>(node))
536538
{
537-
rawstr << "color=blue";
539+
rawstr << ",color=blue";
538540
}
539541
else if(SVFUtil::isa<GlobalICFGNode>(node))
540542
{
541-
rawstr << "color=purple";
543+
rawstr << ",color=purple";
542544
}
543545
else
544546
assert(false && "no such kind of node!!");
545547

546-
rawstr << "";
547-
548548
return rawstr.str();
549549
}
550550

svf/lib/Graphs/IRGraph.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -440,71 +440,79 @@ struct DOTGraphTraits<IRGraph*> : public DefaultDOTGraphTraits
440440
template<class EdgeIter>
441441
static std::string getEdgeAttributes(SVFVar*, EdgeIter EI, IRGraph*)
442442
{
443+
std::string str;
444+
std::stringstream rawstr(str);
445+
446+
rawstr << "shape=record";
447+
443448
const SVFStmt* edge = *(EI.getCurrent());
444449
assert(edge && "No edge found!!");
445450
if (SVFUtil::isa<AddrStmt>(edge))
446451
{
447-
return "color=green";
452+
rawstr << ",color=green";
448453
}
449454
else if (SVFUtil::isa<CopyStmt>(edge))
450455
{
451-
return "color=black";
456+
rawstr << ",color=black";
452457
}
453458
else if (SVFUtil::isa<GepStmt>(edge))
454459
{
455-
return "color=purple";
460+
rawstr << ",color=purple";
456461
}
457462
else if (SVFUtil::isa<StoreStmt>(edge))
458463
{
459-
return "color=blue";
464+
rawstr << ",color=blue";
460465
}
461466
else if (SVFUtil::isa<LoadStmt>(edge))
462467
{
463-
return "color=red";
468+
rawstr << ",color=red";
464469
}
465470
else if (SVFUtil::isa<PhiStmt>(edge))
466471
{
467-
return "color=grey";
472+
rawstr << ",color=grey";
468473
}
469474
else if (SVFUtil::isa<SelectStmt>(edge))
470475
{
471-
return "color=grey";
476+
rawstr << ",color=grey";
472477
}
473478
else if (SVFUtil::isa<CmpStmt>(edge))
474479
{
475-
return "color=grey";
480+
rawstr << ",color=grey";
476481
}
477482
else if (SVFUtil::isa<BinaryOPStmt>(edge))
478483
{
479-
return "color=grey";
484+
rawstr << ",color=grey";
480485
}
481486
else if (SVFUtil::isa<UnaryOPStmt>(edge))
482487
{
483-
return "color=grey";
488+
rawstr << ",color=grey";
484489
}
485490
else if (SVFUtil::isa<BranchStmt>(edge))
486491
{
487-
return "color=grey";
492+
rawstr << ",color=grey";
488493
}
489494
else if (SVFUtil::isa<TDForkPE>(edge))
490495
{
491-
return "color=Turquoise";
496+
rawstr << ",color=Turquoise";
492497
}
493498
else if (SVFUtil::isa<TDJoinPE>(edge))
494499
{
495-
return "color=Turquoise";
500+
rawstr << ",color=Turquoise";
496501
}
497502
else if (SVFUtil::isa<CallPE>(edge))
498503
{
499-
return "color=black,style=dashed";
504+
rawstr << ",color=black,style=dashed";
500505
}
501506
else if (SVFUtil::isa<RetPE>(edge))
502507
{
503-
return "color=black,style=dotted";
508+
rawstr << ",color=black,style=dotted";
509+
}
510+
else
511+
{
512+
assert(false && "No such kind edge!!");
504513
}
505514

506-
assert(false && "No such kind edge!!");
507-
exit(1);
515+
return rawstr.str();
508516
}
509517

510518
template<class EdgeIter>

svf/lib/Graphs/SVFG.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,98 +1010,99 @@ struct DOTGraphTraits<SVFG*> : public DOTGraphTraits<SVFIR*>
10101010
std::string str;
10111011
std::stringstream rawstr(str);
10121012

1013+
rawstr << "shape=record";
1014+
10131015
if(StmtSVFGNode* stmtNode = SVFUtil::dyn_cast<StmtSVFGNode>(node))
10141016
{
10151017
const SVFStmt* edge = stmtNode->getSVFStmt();
10161018
if (SVFUtil::isa<AddrStmt>(edge))
10171019
{
1018-
rawstr << "color=green";
1020+
rawstr << ",color=green";
10191021
}
10201022
else if (SVFUtil::isa<CopyStmt>(edge))
10211023
{
1022-
rawstr << "color=black";
1024+
rawstr << ",color=black";
10231025
}
10241026
else if (SVFUtil::isa<RetPE>(edge))
10251027
{
1026-
rawstr << "color=black,style=dotted";
1028+
rawstr << ",color=black,style=dotted";
10271029
}
10281030
else if (SVFUtil::isa<GepStmt>(edge))
10291031
{
1030-
rawstr << "color=purple";
1032+
rawstr << ",color=purple";
10311033
}
10321034
else if (SVFUtil::isa<StoreStmt>(edge))
10331035
{
1034-
rawstr << "color=blue";
1036+
rawstr << ",color=blue";
10351037
}
10361038
else if (SVFUtil::isa<LoadStmt>(edge))
10371039
{
1038-
rawstr << "color=red";
1040+
rawstr << ",color=red";
10391041
}
10401042
else
10411043
{
10421044
assert(0 && "No such kind edge!!");
10431045
}
1044-
rawstr << "";
10451046
}
10461047
else if(SVFUtil::isa<MSSAPHISVFGNode>(node))
10471048
{
1048-
rawstr << "color=black";
1049+
rawstr << ",color=black";
10491050
}
10501051
else if(SVFUtil::isa<PHISVFGNode>(node))
10511052
{
1052-
rawstr << "color=black";
1053+
rawstr << ",color=black";
10531054
}
10541055
else if(SVFUtil::isa<NullPtrSVFGNode>(node))
10551056
{
1056-
rawstr << "color=grey";
1057+
rawstr << ",color=grey";
10571058
}
10581059
else if(SVFUtil::isa<FormalINSVFGNode>(node))
10591060
{
1060-
rawstr << "color=yellow,penwidth=2";
1061+
rawstr << ",color=yellow,penwidth=2";
10611062
}
10621063
else if(SVFUtil::isa<FormalOUTSVFGNode>(node))
10631064
{
1064-
rawstr << "color=yellow,penwidth=2";
1065+
rawstr << ",color=yellow,penwidth=2";
10651066
}
10661067
else if(SVFUtil::isa<FormalParmSVFGNode>(node))
10671068
{
1068-
rawstr << "color=yellow,penwidth=2";
1069+
rawstr << ",color=yellow,penwidth=2";
10691070
}
10701071
else if(SVFUtil::isa<ActualINSVFGNode>(node))
10711072
{
1072-
rawstr << "color=yellow,penwidth=2";
1073+
rawstr << ",color=yellow,penwidth=2";
10731074
}
10741075
else if(SVFUtil::isa<ActualOUTSVFGNode>(node))
10751076
{
1076-
rawstr << "color=yellow,penwidth=2";
1077+
rawstr << ",color=yellow,penwidth=2";
10771078
}
10781079
else if(SVFUtil::isa<ActualParmSVFGNode>(node))
10791080
{
1080-
rawstr << "color=yellow,penwidth=2";
1081+
rawstr << ",color=yellow,penwidth=2";
10811082
}
10821083
else if (SVFUtil::isa<ActualRetSVFGNode>(node))
10831084
{
1084-
rawstr << "color=yellow,penwidth=2";
1085+
rawstr << ",color=yellow,penwidth=2";
10851086
}
10861087
else if (SVFUtil::isa<FormalRetSVFGNode>(node))
10871088
{
1088-
rawstr << "color=yellow,penwidth=2";
1089+
rawstr << ",color=yellow,penwidth=2";
10891090
}
10901091
else if (SVFUtil::isa<BinaryOPVFGNode>(node))
10911092
{
1092-
rawstr << "color=black,penwidth=2";
1093+
rawstr << ",color=black,penwidth=2";
10931094
}
10941095
else if (SVFUtil::isa<CmpVFGNode>(node))
10951096
{
1096-
rawstr << "color=black,penwidth=2";
1097+
rawstr << ",color=black,penwidth=2";
10971098
}
10981099
else if (SVFUtil::isa<UnaryOPVFGNode>(node))
10991100
{
1100-
rawstr << "color=black,penwidth=2";
1101+
rawstr << ",color=black,penwidth=2";
11011102
}
11021103
else if (SVFUtil::isa<BranchVFGNode>(node))
11031104
{
1104-
rawstr << "color=gold,penwidth=2";
1105+
rawstr << ",color=gold,penwidth=2";
11051106
}
11061107
else
11071108
assert(false && "no such kind of node!!");
@@ -1122,8 +1123,6 @@ struct DOTGraphTraits<SVFG*> : public DOTGraphTraits<SVFIR*>
11221123
else if(graph->getStat()->inForwardSlice(node))
11231124
rawstr << ",style=filled, fillcolor=gray";
11241125

1125-
rawstr << "";
1126-
11271126
return rawstr.str();
11281127
}
11291128

0 commit comments

Comments
 (0)