r364882 - [analyzer] exploded-graph-rewriter: Implement a dark color scheme.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 1 19:17:56 PDT 2019
Author: dergachev
Date: Mon Jul 1 19:17:56 2019
New Revision: 364882
URL: http://llvm.org/viewvc/llvm-project?rev=364882&view=rev
Log:
[analyzer] exploded-graph-rewriter: Implement a dark color scheme.
Addresses a popular request. Activated via --dark.
Differential Revision: https://reviews.llvm.org/D64056
Added:
cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot
Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot?rev=364882&r1=364881&r2=364882&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot Mon Jul 1 19:17:56 2019
@@ -1,4 +1,5 @@
-// RUN: %exploded_graph_rewriter %s | FileCheck %s
+// RUN: %exploded_graph_rewriter %s | FileCheck %s -check-prefix=LIGHT
+// RUN: %exploded_graph_rewriter --dark %s | FileCheck %s -check-prefixes=DARK
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
@@ -7,7 +8,8 @@ Node0x1 [shape=record,label=
"{{ "node_id": 1, "pointer": "0x1",
"program_state": null, "program_points": []}\l}"];
-// CHECK: Node0x1 -> Node0x2;
+// LIGHT: Node0x1 -> Node0x2;
+// DARK: Node0x1 -> Node0x2 [color="white"];
Node0x1 -> Node0x2;
Node0x2 [shape=record,label=
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot?rev=364882&r1=364881&r2=364882&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/empty.dot Mon Jul 1 19:17:56 2019
@@ -1,4 +1,6 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s
+// RUN: %exploded_graph_rewriter --dark %s | FileCheck %s \
+// RUN: -check-prefixes=CHECK,DARK
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
@@ -8,5 +10,6 @@ digraph "Exploded Graph" {
}
// CHECK: digraph "ExplodedGraph" {
+// DARK-NEXT: bgcolor="gray10";
// CHECK-NEXT: label="";
// CHECK-NEXT: }
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot?rev=364882&r1=364881&r2=364882&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot Mon Jul 1 19:17:56 2019
@@ -10,7 +10,7 @@
// CHECK-SAME: <b>#0 Call</b>
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left" colspan="2">
-// CHECK-SAME: <font color="grey60">foo </font>(line 4)
+// CHECK-SAME: <font color="gray60">foo </font>(line 4)
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: <tr>
Added: cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot?rev=364882&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot (added)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot Mon Jul 1 19:17:56 2019
@@ -0,0 +1,22 @@
+// RUN: %exploded_graph_rewriter %s | FileCheck %s -check-prefixes=CHECK,LIGHT
+// RUN: %exploded_graph_rewriter %s --dark | FileCheck %s \
+// RUN: -check-prefixes CHECK,DARK
+
+// FIXME: Substitution doesn't seem to work on Windows.
+// UNSUPPORTED: system-windows
+
+// LIGHT: Node0x1 [shape=record,label=<
+// DARK: Node0x1 [shape=record,color="white",fontcolor="gray80",label=<
+// CHECK-SAME: <tr>
+// LIGHT-SAME: <td bgcolor="gray">
+// DARK-SAME: <td bgcolor="gray20">
+// CHECK-SAME: <b>Node 1 (0x1) - State Unspecified</b>
+// CHECK-SAME: </td>
+// CHECK-SAME: </tr>
+Node0x1 [shape=record,label=
+ "{
+ { "node_id": 1, "pointer": "0x1",
+ "program_state": null,
+ "program_points": []
+ }
+\l}"];
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp?rev=364882&r1=364881&r2=364882&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp Mon Jul 1 19:17:56 2019
@@ -17,7 +17,7 @@ void test() {
// CHECK-SAME: <tr>
// CHECK-SAME: <td align="left"><b>#0 Call</b></td>
// CHECK-SAME: <td align="left" colspan="2">
- // CHECK-SAME: <font color="grey60">test </font>
+ // CHECK-SAME: <font color="gray60">test </font>
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: <tr>
Modified: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/exploded-graph-rewriter.py?rev=364882&r1=364881&r2=364882&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py (original)
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py Mon Jul 1 19:17:56 2019
@@ -334,9 +334,10 @@ class ExplodedGraph(object):
# A visitor that dumps the ExplodedGraph into a DOT file with fancy HTML-based
# syntax highlighing.
class DotDumpVisitor(object):
- def __init__(self, do_diffs):
+ def __init__(self, do_diffs, dark_mode):
super(DotDumpVisitor, self).__init__()
self._do_diffs = do_diffs
+ self._dark_mode = dark_mode
@staticmethod
def _dump_raw(s):
@@ -363,6 +364,8 @@ class DotDumpVisitor(object):
def visit_begin_graph(self, graph):
self._graph = graph
self._dump_raw('digraph "ExplodedGraph" {\n')
+ if self._dark_mode:
+ self._dump_raw('bgcolor="gray10";\n')
self._dump_raw('label="";\n')
def visit_program_point(self, p):
@@ -372,7 +375,7 @@ class DotDumpVisitor(object):
'PostStmtPurgeDeadSymbols']:
color = 'red'
elif p.kind in ['CallEnter', 'CallExitBegin', 'CallExitEnd']:
- color = 'blue'
+ color = 'dodgerblue' if self._dark_mode else 'blue'
elif p.kind in ['Statement']:
color = 'cyan4'
else:
@@ -436,7 +439,7 @@ class DotDumpVisitor(object):
self._dump('<tr><td>%s</td>'
'<td align="left"><b>%s</b></td>'
'<td align="left" colspan="2">'
- '<font color="grey60">%s </font>'
+ '<font color="gray60">%s </font>'
'%s</td></tr>'
% (self._diff_plus_minus(is_added),
lc.caption, lc.decl,
@@ -451,9 +454,11 @@ class DotDumpVisitor(object):
'<td align="left">%s</td></tr>'
% (self._diff_plus_minus(is_added),
b.stmt_id,
- '<td align="left"><font color="darkgreen"><i>'
- '(%s)</i></font></td>' % b.kind
- if b.kind is not None else '',
+ '<td align="left"><font color="%s"><i>'
+ '%s</i></font></td>' % (
+ 'lavender' if self._dark_mode else 'darkgreen',
+ ('(%s)' % b.kind) if b.kind is not None else ' '
+ ),
b.pretty, f.bindings[b]))
frames_updated = e.diff_frames(prev_e) if prev_e is not None else None
@@ -615,12 +620,16 @@ class DotDumpVisitor(object):
s, prev_s)
def visit_node(self, node):
- self._dump('%s [shape=record,label=<<table border="0">'
+ self._dump('%s [shape=record,'
% (node.node_name()))
+ if self._dark_mode:
+ self._dump('color="white",fontcolor="gray80",')
+ self._dump('label=<<table border="0">')
- self._dump('<tr><td bgcolor="grey"><b>Node %d (%s) - '
+ self._dump('<tr><td bgcolor="%s"><b>Node %d (%s) - '
'State %s</b></td></tr>'
- % (node.node_id, node.ptr, node.state.state_id
+ % ("gray20" if self._dark_mode else "gray",
+ node.node_id, node.ptr, node.state.state_id
if node.state is not None else 'Unspecified'))
self._dump('<tr><td align="left" width="0">')
if len(node.points) > 1:
@@ -645,7 +654,10 @@ class DotDumpVisitor(object):
self._dump_raw('</table>>];\n')
def visit_edge(self, pred, succ):
- self._dump_raw('%s -> %s;\n' % (pred.node_name(), succ.node_name()))
+ self._dump_raw('%s -> %s%s;\n' % (
+ pred.node_name(), succ.node_name(),
+ ' [color="white"]' if self._dark_mode else ''
+ ))
def visit_end_of_graph(self):
self._dump_raw('}\n')
@@ -678,6 +690,9 @@ def main():
parser.add_argument('-d', '--diff', action='store_const', dest='diff',
const=True, default=False,
help='display differences between states')
+ parser.add_argument('--dark', action='store_const', dest='dark',
+ const=True, default=False,
+ help='dark mode')
args = parser.parse_args()
logging.basicConfig(level=args.loglevel)
@@ -688,7 +703,7 @@ def main():
graph.add_raw_line(raw_line)
explorer = Explorer()
- visitor = DotDumpVisitor(args.diff)
+ visitor = DotDumpVisitor(args.diff, args.dark)
explorer.explore(graph, visitor)
More information about the cfe-commits
mailing list