[PATCH] D64153: [analyzer] exploded-graph-rewriter: Add a grayscale mode.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 3 12:53:17 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.

Accessibility! I remembered to implement accessibility.

F9454779: Screen Shot 2019-07-03 at 12.51.22 PM.png <https://reviews.llvm.org/F9454779> F9454780: Screen Shot 2019-07-03 at 12.51.03 PM.png <https://reviews.llvm.org/F9454780>


Repository:
  rC Clang

https://reviews.llvm.org/D64153

Files:
  clang/test/Analysis/exploded-graph-rewriter/node_labels.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,24 +384,28 @@
 # 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):
+    def __init__(self, do_diffs, dark_mode, gray_mode):
         super(DotDumpVisitor, self).__init__()
         self._do_diffs = do_diffs
         self._dark_mode = dark_mode
+        self._gray_mode = gray_mode
 
     @staticmethod
     def _dump_raw(s):
         print(s, end='')
 
-    @staticmethod
-    def _dump(s):
-        print(s.replace('&', '&')
-               .replace('{', '\\{')
-               .replace('}', '\\}')
-               .replace('\\<', '<')
-               .replace('\\>', '>')
-               .replace('\\l', '<br />')
-               .replace('|', '\\|'), end='')
+    def _dump(self, s):
+        s = s.replace('&', '&') \
+             .replace('{', '\\{') \
+             .replace('}', '\\}') \
+             .replace('\\<', '<') \
+             .replace('\\>', '>') \
+             .replace('\\l', '<br />') \
+             .replace('|', '\\|')
+        if self._gray_mode:
+            s = re.sub(r'<font color="[a-z0-9]*">', '', s)
+            s = re.sub(r'</font>', '', s)
+        self._dump_raw(s)
 
     @staticmethod
     def _diff_plus_minus(is_added):
@@ -835,6 +839,9 @@
     parser.add_argument('--dark', action='store_const', dest='dark',
                         const=True, default=False,
                         help='dark mode')
+    parser.add_argument('--gray', action='store_const', dest='gray',
+                        const=True, default=False,
+                        help='black-and-white mode')
     args = parser.parse_args()
     logging.basicConfig(level=args.loglevel)
 
@@ -845,7 +852,7 @@
             graph.add_raw_line(raw_line)
 
     explorer = BasicExplorer()
-    visitor = DotDumpVisitor(args.diff, args.dark)
+    visitor = DotDumpVisitor(args.diff, args.dark, args.gray)
     explorer.explore(graph, visitor)
 
 
Index: clang/test/Analysis/exploded-graph-rewriter/node_labels.dot
===================================================================
--- clang/test/Analysis/exploded-graph-rewriter/node_labels.dot
+++ clang/test/Analysis/exploded-graph-rewriter/node_labels.dot
@@ -1,6 +1,11 @@
-// RUN: %exploded_graph_rewriter %s | FileCheck %s -check-prefixes=CHECK,LIGHT
-// RUN: %exploded_graph_rewriter %s --dark | FileCheck %s \
-// RUN:                                         -check-prefixes CHECK,DARK
+// RUN: %exploded_graph_rewriter %s \
+// RUN:     | FileCheck %s -check-prefixes=CHECK,LIGHT,COLOR
+// RUN: %exploded_graph_rewriter %s --dark \
+// RUN:     | FileCheck %s -check-prefixes CHECK,DARK,COLOR
+// RUN: %exploded_graph_rewriter %s --gray \
+// RUN:     | FileCheck %s -check-prefixes=CHECK,LIGHT,GRAY
+// RUN: %exploded_graph_rewriter %s --gray --dark \
+// RUN:     | FileCheck %s -check-prefixes CHECK,DARK,GRAY
 
 // FIXME: Substitution doesn't seem to work on Windows.
 // UNSUPPORTED: system-windows
@@ -23,10 +28,12 @@
 
 // CHECK: Node0x2 [
 // CHECK-SAME: <tr><td>
-// CHECK-SAME:   <font color="red"><b>Bug Report Attached</b></font>
+// COLOR-SAME:   <font color="red"><b>Bug Report Attached</b></font>
+// GRAY-SAME:    <b>Bug Report Attached</b>
 // CHECK-SAME: </td></tr>
 // CHECK-SAME: <tr><td>
-// CHECK-SAME:   <font color="cornflowerblue"><b>Sink Node</b></font>
+// COLOR-SAME:   <font color="cornflowerblue"><b>Sink Node</b></font>
+// GRAY-SAME:    <b>Sink Node</b>
 // CHECK-SAME: </td></tr>
 Node0x2 [shape=record,label=
  "{


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64153.207867.patch
Type: text/x-patch
Size: 3800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190703/efb61be3/attachment.bin>


More information about the cfe-commits mailing list