Skip to content

Commit 5fcf92e

Browse files
committed
[analyzer] exploded-graph-rewriter: NFC: Add more comments.
llvm-svn: 364991
1 parent 48a5c83 commit 5fcf92e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

clang/utils/analyzer/exploded-graph-rewriter.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
import re
2020

2121

22+
#===-----------------------------------------------------------------------===#
23+
# These data structures represent a deserialized ExplodedGraph.
24+
#===-----------------------------------------------------------------------===#
25+
26+
2227
# A helper function for finding the difference between two dictionaries.
2328
def diff_dicts(curr, prev):
2429
removed = [k for k in prev if k not in curr or curr[k] != prev[k]]
@@ -368,6 +373,12 @@ def add_raw_line(self, raw_line):
368373
logging.debug('Skipping.')
369374

370375

376+
#===-----------------------------------------------------------------------===#
377+
# Visitors traverse a deserialized ExplodedGraph and do different things
378+
# with every node and edge.
379+
#===-----------------------------------------------------------------------===#
380+
381+
371382
# A visitor that dumps the ExplodedGraph into a DOT file with fancy HTML-based
372383
# syntax highlighing.
373384
class DotDumpVisitor(object):
@@ -775,11 +786,17 @@ def visit_end_of_graph(self):
775786
self._dump_raw('}\n')
776787

777788

789+
#===-----------------------------------------------------------------------===#
790+
# Explorers know how to traverse the ExplodedGraph in a certain order.
791+
# They would invoke a Visitor on every node or edge they encounter.
792+
#===-----------------------------------------------------------------------===#
793+
794+
778795
# A class that encapsulates traversal of the ExplodedGraph. Different explorer
779796
# kinds could potentially traverse specific sub-graphs.
780-
class Explorer(object):
797+
class BasicExplorer(object):
781798
def __init__(self):
782-
super(Explorer, self).__init__()
799+
super(BasicExplorer, self).__init__()
783800

784801
def explore(self, graph, visitor):
785802
visitor.visit_begin_graph(graph)
@@ -792,6 +809,11 @@ def explore(self, graph, visitor):
792809
visitor.visit_end_of_graph()
793810

794811

812+
#===-----------------------------------------------------------------------===#
813+
# The entry point to the script.
814+
#===-----------------------------------------------------------------------===#
815+
816+
795817
def main():
796818
parser = argparse.ArgumentParser()
797819
parser.add_argument('filename', type=str)
@@ -814,7 +836,7 @@ def main():
814836
raw_line = raw_line.strip()
815837
graph.add_raw_line(raw_line)
816838

817-
explorer = Explorer()
839+
explorer = BasicExplorer()
818840
visitor = DotDumpVisitor(args.diff, args.dark)
819841
explorer.explore(graph, visitor)
820842

0 commit comments

Comments
 (0)