[PATCH] D64264: [analyzer] exploded-graph-rewriter: Implement a topology-only mode.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 5 13:25:37 PDT 2019


NoQ created this revision.
NoQ added a reviewer: Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

In this mode the rewriter will only rewrite program points and omit program states. Useful for understanding the rough topology of the graph.

F9470109: Screen Shot 2019-07-05 at 1.20.29 PM.png <https://reviews.llvm.org/F9470109>


Repository:
  rC Clang

https://reviews.llvm.org/D64264

Files:
  clang/test/Analysis/exploded-graph-rewriter/topology.dot
  clang/utils/analyzer/exploded-graph-rewriter.py


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===================================================================
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -384,11 +384,12 @@
 # A visitor that dumps the ExplodedGraph into a DOT file with fancy HTML-based
 # syntax highlighing.
 class DotDumpVisitor(object):
-    def __init__(self, do_diffs, dark_mode, gray_mode):
+    def __init__(self, do_diffs, dark_mode, gray_mode, topo_mode):
         super(DotDumpVisitor, self).__init__()
         self._do_diffs = do_diffs
         self._dark_mode = dark_mode
         self._gray_mode = gray_mode
+        self._topo_mode = topo_mode
 
     @staticmethod
     def _dump_raw(s):
@@ -777,7 +778,7 @@
             self.visit_program_point(p)
         self._dump('</table></td></tr>')
 
-        if node.state is not None:
+        if node.state is not None and not self._topo_mode:
             prev_s = None
             # Do diffs only when we have a unique predecessor.
             # Don't do diffs on the leaf nodes because they're
@@ -868,6 +869,9 @@
     parser.add_argument('-d', '--diff', action='store_const', dest='diff',
                         const=True, default=False,
                         help='display differences between states')
+    parser.add_argument('-t', '--topology', action='store_const',
+                        dest='topology', const=True, default=False,
+                        help='only display program points, omit states')
     parser.add_argument('-s', '--single-path', action='store_const',
                         dest='single_path', const=True, default=False,
                         help='only display the leftmost path in the graph '
@@ -889,7 +893,7 @@
             graph.add_raw_line(raw_line)
 
     explorer = SinglePathExplorer() if args.single_path else BasicExplorer()
-    visitor = DotDumpVisitor(args.diff, args.dark, args.gray)
+    visitor = DotDumpVisitor(args.diff, args.dark, args.gray, args.topology)
 
     explorer.explore(graph, visitor)
 
Index: clang/test/Analysis/exploded-graph-rewriter/topology.dot
===================================================================
--- /dev/null
+++ clang/test/Analysis/exploded-graph-rewriter/topology.dot
@@ -0,0 +1,30 @@
+// RUN: %exploded_graph_rewriter %s \
+// RUN:     | FileCheck -check-prefixes=NORMAL %s
+// RUN: %exploded_graph_rewriter -t %s \
+// RUN:     | FileCheck -check-prefixes=TOPOLOGY %s
+
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
+// NORMAL: Checker State:
+// TOPOLOGY-NOT: Checker State:
+Node0x1 [shape=record,label=
+ "{
+    { "node_id": 1,
+      "pointer": "0x1",
+      "has_report": false,
+      "is_sink": false,
+      "state_id": 2,
+      "program_points": [],
+      "program_state": {
+        "environment": null,
+        "constraints": null,
+        "dynamic_types": null,
+        "constructing_objects": null,
+        "checker_messages": [
+          { "checker": "foo", "messages": ["bar"] }
+        ],
+        "store": null
+      }
+    }
+\l}"];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64264.208224.patch
Type: text/x-patch
Size: 3119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190705/3817e0f6/attachment.bin>


More information about the cfe-commits mailing list