[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 16:02:40 PDT 2019


NoQ added inline comments.


================
Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:151
+        super(ExplodedGraph, self).__init__()
+        self.nodes = collections.defaultdict(ExplodedNode)
+        self.root_id = None
----------------
Charusso wrote:
> `nodes` -> `graph`
Mm, why would i have a field called "graph" in an object called "graph".


================
Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:191
+                                .replace('\\>', '\\\\>') \
+                                .rstrip(',')
+            logging.debug(raw_json)
----------------
Charusso wrote:
> I have removed the trailing `,` from the end yesterday so `rstrip(',')` is not needed.
> 
> It would be cool to name the `result[]`, like: `pred_id = result[1]` and `succ_id = result[2]` or current/previous ID, or something like that.
> 
> I also would put the regexes into a function and you could write:
> `pred_id, succ_id = parse_edge()` or something more simpler.
> 
> What is `result[0]` btw? That confused me a little-bit.
> `pred_id, succ_id = parse_edge()`

Not really, i'd also have to return whether the match was successful, which kinda makes it as bad as before.

> What is `result[0]` btw? That confused me a little-bit.

That's the entire match. https://docs.python.org/3/library/re.html#match-objects


================
Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:233
+        else:
+            color = 'cyan3'
+
----------------
Charusso wrote:
> It would be cool to put it into a "switch-statement" (https://stackoverflow.com/questions/60208/replacements-for-switch-statement-in-python).
I don't want to list the same color many times for each key that maps into it.


================
Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:237
+            if p.sloc is not None:
+                self._dump('<tr><td align="left" width="0">'
+                           '%s:<b>%s</b>:<b>%s</b>:</td>'
----------------
Charusso wrote:
> I think tables are left aligned by default, so you could remove your left alignments.
Unfortunately in GraphViz they're centered by default.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62638/new/

https://reviews.llvm.org/D62638





More information about the cfe-commits mailing list