[PATCH] D64104: [analyzer] exploded-graph-rewriter: Collapse large statement pretty-prints.

2019-07-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364990: [analyzer] exploded-graph-rewriter: Collapse very 
long statement pretty-prints. (authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64104?vs=207631=207689#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64104

Files:
  cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
  cfe/trunk/utils/analyzer/exploded-graph-rewriter.py


Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
===
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
@@ -90,3 +90,27 @@
   }
 ]}
 \l}"];
+
+// Test collapsing large pretty prints with braces.
+
+// CHECK-NEXT: Program point:
+// CHECK-SAME: \{ ... \}
+Node0x3 [shape=record,label=
+ "{
+{ "node_id": 3, "pointer": "0x3",
+  "program_state": null, "program_points": [
+  {
+"kind": "Statement",
+"stmt_kind": "CompoundStmt",
+"stmt_point_kind": "PostStmt",
+"stmd_id": 6,
+"pointer": "0x6",
+"pretty": "{ very very very very very very long pretty print }",
+"location": {
+  "line": 7,
+  "column": 8
+},
+"tag": "ExprEngine : Clean Node"
+  }
+]}
+\l}"];
Index: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
===
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
@@ -398,6 +398,21 @@
 return '+'
 return '-'
 
+@staticmethod
+def _short_pretty(s):
+if s is None:
+return None
+if len(s) < 20:
+return s
+left = s.find('{')
+right = s.rfind('}')
+if left == -1 or right == -1 or left >= right:
+return s
+candidate = s[0:left + 1] + ' ... ' + s[right:]
+if len(candidate) >= len(s):
+return s
+return candidate
+
 def visit_begin_graph(self, graph):
 self._graph = graph
 self._dump_raw('digraph "ExplodedGraph" {\n')
@@ -433,7 +448,8 @@
% (p.loc.filename, p.loc.line,
   p.loc.col, color, p.stmt_kind,
   stmt_color, p.stmt_point_kind,
-  p.pretty if not skip_pretty else ''))
+  self._short_pretty(p.pretty)
+  if not skip_pretty else ''))
 else:
 self._dump(''
'Invalid Source Location:'
@@ -443,7 +459,8 @@
'%s'
% (color, p.stmt_kind,
   stmt_color, p.stmt_point_kind,
-  p.pretty if not skip_pretty else ''))
+  self._short_pretty(p.pretty)
+  if not skip_pretty else ''))
 elif p.kind == 'Edge':
 self._dump(''
''
@@ -496,7 +513,7 @@
   'lavender' if self._dark_mode else 'darkgreen',
   ('(%s)' % b.kind) if b.kind is not None else ' '
   ),
-  b.pretty, f.bindings[b]))
+  self._short_pretty(b.pretty), f.bindings[b]))
 
 frames_updated = e.diff_frames(prev_e) if prev_e is not None else None
 if frames_updated:


Index: cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
===
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
@@ -90,3 +90,27 @@
   }
 ]}
 \l}"];
+
+// Test collapsing large pretty prints with braces.
+
+// CHECK-NEXT: Program point:
+// CHECK-SAME: \{ ... \}
+Node0x3 [shape=record,label=
+ "{
+{ "node_id": 3, "pointer": "0x3",
+  "program_state": null, "program_points": [
+  {
+"kind": "Statement",
+"stmt_kind": "CompoundStmt",
+"stmt_point_kind": "PostStmt",
+"stmd_id": 6,
+"pointer": "0x6",
+"pretty": "{ very very very very very very long pretty print }",
+"location": {
+  "line": 7,
+  "column": 8
+},
+"tag": "ExprEngine : Clean Node"
+  }
+]}
+\l}"];
Index: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
===
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
+++ 

[PATCH] D64104: [analyzer] exploded-graph-rewriter: Collapse large statement pretty-prints.

2019-07-02 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D64104#1567326 , @NoQ wrote:

> In D64104#1567317 , @Charusso wrote:
>
> > I like it! What about `BlockEdge` with the long terminators? (c.f. 
> > `Edge.getSrc()->printTerminatorJson()`)
>
>
> We don't process these yet >.< But it should be trivial to cover them in a 
> similar manner once we implement them.


Yes, great patch, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D64104



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64104: [analyzer] exploded-graph-rewriter: Collapse large statement pretty-prints.

2019-07-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D64104#1567317 , @Charusso wrote:

> I like it! What about `BlockEdge` with the long terminators? (c.f. 
> `Edge.getSrc()->printTerminatorJson()`)


We don't process these yet >.< But it should be trivial to cover them in a 
similar manner once we implement them.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64104



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64104: [analyzer] exploded-graph-rewriter: Collapse large statement pretty-prints.

2019-07-02 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added a comment.
This revision is now accepted and ready to land.

I like it! What about `BlockEdge` with the long terminators? (c.f. 
`Edge.getSrc()->printTerminatorJson()`)


Repository:
  rC Clang

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

https://reviews.llvm.org/D64104



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64104: [analyzer] exploded-graph-rewriter: Collapse large statement pretty-prints.

2019-07-02 Thread Artem Dergachev via Phabricator via cfe-commits
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.

When printing various statements that include braces (compound statements, 
lambda expressions, statement-expressions, etc.), replace the code between 
braces with '...'.

I don't mind losing some information here because it's easily recoverable by 
looking at the source code.

Before:
F9450332: Screen Shot 2019-07-02 at 2.25.39 PM.png 


After:
F9450331: Screen Shot 2019-07-02 at 2.25.46 PM.png 



Repository:
  rC Clang

https://reviews.llvm.org/D64104

Files:
  clang/test/Analysis/exploded-graph-rewriter/program_points.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
@@ -398,6 +398,21 @@
 return '+'
 return '-'
 
+@staticmethod
+def _short_pretty(s):
+if s is None:
+return None
+if len(s) < 20:
+return s
+left = s.find('{')
+right = s.rfind('}')
+if left == -1 or right == -1 or left >= right:
+return s
+candidate = s[0:left + 1] + ' ... ' + s[right:]
+if len(candidate) >= len(s):
+return s
+return candidate
+
 def visit_begin_graph(self, graph):
 self._graph = graph
 self._dump_raw('digraph "ExplodedGraph" {\n')
@@ -433,7 +448,8 @@
% (p.loc.filename, p.loc.line,
   p.loc.col, color, p.stmt_kind,
   stmt_color, p.stmt_point_kind,
-  p.pretty if not skip_pretty else ''))
+  self._short_pretty(p.pretty)
+  if not skip_pretty else ''))
 else:
 self._dump(''
'Invalid Source Location:'
@@ -443,7 +459,8 @@
'%s'
% (color, p.stmt_kind,
   stmt_color, p.stmt_point_kind,
-  p.pretty if not skip_pretty else ''))
+  self._short_pretty(p.pretty)
+  if not skip_pretty else ''))
 elif p.kind == 'Edge':
 self._dump(''
''
@@ -496,7 +513,7 @@
   'lavender' if self._dark_mode else 'darkgreen',
   ('(%s)' % b.kind) if b.kind is not None else ' '
   ),
-  b.pretty, f.bindings[b]))
+  self._short_pretty(b.pretty), f.bindings[b]))
 
 frames_updated = e.diff_frames(prev_e) if prev_e is not None else None
 if frames_updated:
Index: clang/test/Analysis/exploded-graph-rewriter/program_points.dot
===
--- clang/test/Analysis/exploded-graph-rewriter/program_points.dot
+++ clang/test/Analysis/exploded-graph-rewriter/program_points.dot
@@ -90,3 +90,27 @@
   }
 ]}
 \l}"];
+
+// Test collapsing large pretty prints with braces.
+
+// CHECK-NEXT: Program point:
+// CHECK-SAME: \{ ... \}
+Node0x3 [shape=record,label=
+ "{
+{ "node_id": 3, "pointer": "0x3",
+  "program_state": null, "program_points": [
+  {
+"kind": "Statement",
+"stmt_kind": "CompoundStmt",
+"stmt_point_kind": "PostStmt",
+"stmd_id": 6,
+"pointer": "0x6",
+"pretty": "{ very very very very very very long pretty print }",
+"location": {
+  "line": 7,
+  "column": 8
+},
+"tag": "ExprEngine : Clean Node"
+  }
+]}
+\l}"];


Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -398,6 +398,21 @@
 return '+'
 return '-'
 
+@staticmethod
+def _short_pretty(s):
+if s is None:
+return None
+if len(s) < 20:
+return s
+left = s.find('{')
+right = s.rfind('}')
+if left == -1 or right == -1 or left >= right:
+return s
+candidate = s[0:left + 1] + ' ... ' + s[right:]
+if len(candidate) >= len(s):
+return s
+return candidate
+
 def visit_begin_graph(self, graph):
 self._graph = graph
 self._dump_raw('digraph "ExplodedGraph" {\n')
@@ -433,7 +448,8 @@
% (p.loc.filename, p.loc.line,