[analyzer] exploded-graph-rewriter: Improve program point dumps.

- Take advantage of the stmt_point_kind.
- Dump block IDs for BlockEntrance nodes.
- Don't dump huge compound statements on PurgeDeadSymbols nodes.
- Rename Edge to BlockEdge for consistency.
- Tweak colors.

Differential Revision: https://reviews.llvm.org/D64051

llvm-svn: 364881
This commit is contained in:
Artem Dergachev 2019-07-02 02:17:53 +00:00
parent 0a77d9192a
commit 2ca5355712
3 changed files with 54 additions and 13 deletions

View File

@ -17,7 +17,7 @@ void escapes() {
// CHECK-SAME: <td align="left">&amp;Element\{"foo",0 S64b,char\}</td>
const char *const foo = "\x66\x6f\x6f";
// CHECK: <font color="cyan3">BinaryOperator</font>
// CHECK: <font color="cyan4">BinaryOperator</font>
// CHECK-SAME: <td align="left">1 \| 2</td>
// CHECK-SAME: <td align="left">3 S32b</td>
int x = 1 | 2;

View File

@ -3,18 +3,28 @@
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// CHECK: <b>Program point:</b>
// CHECK: <b>Program points:</b>
// CHECK-SAME: <table border="0" align="left" width="0">
// CHECK-SAME: <tr>
// CHECK-SAME: <td width="0">
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left" width="0">
// CHECK-SAME: <font color="gold3">Edge</font>
// CHECK-SAME: <font color="gold3">BlockEdge</font>
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: [B0] -&gt; [B1]
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: <tr>
// CHECK-SAME: <td width="0">
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left" width="0">
// CHECK-SAME: <font color="gold3">BlockEntrance</font>
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: [B1]
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: </table>
Node0x1 [shape=record,label=
"{
@ -26,7 +36,15 @@ Node0x1 [shape=record,label=
"dst_id": 1,
"terminator": null,
"term_kind": null,
"tag": null }
"tag": null
},
{
"kind": "BlockEntrance",
"block_id": 1,
"terminator": null,
"term_kind": null,
"tag": null
}
]}
\l}"];
@ -37,14 +55,17 @@ Node0x1 [shape=record,label=
// CHECK-SAME: (main file):<b>4</b>:<b>5</b>:
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left" width="0">
// CHECK-SAME: <font color="cyan3">DeclRefExpr</font>
// CHECK-SAME: <font color="cyan4">DeclRefExpr</font>
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: <font color="cyan3">PreStmt</font>
// CHECK-SAME: </td>
// CHECK-SAME: <td>x</td>
// CHECK-SAME: </tr>
// CHECK-SAME: <tr>
// CHECK-SAME: <td width="0">
// CHECK-SAME: </td>
// CHECK-SAME: <td colspan="2" align="left">
// CHECK-SAME: <td colspan="3" align="left">
// CHECK-SAME: <b>Tag: </b>
// CHECK-SAME: <font color="crimson">ExprEngine : Clean Node</font>
// CHECK-SAME: </td>
@ -57,6 +78,7 @@ Node0x2 [shape=record,label=
{
"kind": "Statement",
"stmt_kind": "DeclRefExpr",
"stmt_point_kind": "PreStmt",
"stmd_id": 3,
"pointer": "0x3",
"pretty": "x",

View File

@ -59,6 +59,7 @@ class ProgramPoint(object):
self.dst_id = json_pp['dst_id']
elif self.kind == 'Statement':
self.stmt_kind = json_pp['stmt_kind']
self.stmt_point_kind = json_pp['stmt_point_kind']
self.pointer = json_pp['pointer']
self.pretty = json_pp['pretty']
self.loc = SourceLocation(json_pp['location']) \
@ -373,30 +374,48 @@ class DotDumpVisitor(object):
elif p.kind in ['CallEnter', 'CallExitBegin', 'CallExitEnd']:
color = 'blue'
elif p.kind in ['Statement']:
color = 'cyan3'
color = 'cyan4'
else:
color = 'forestgreen'
if p.kind == 'Statement':
# This avoids pretty-printing huge statements such as CompoundStmt.
# Such statements show up only at [Pre|Post]StmtPurgeDeadSymbols
skip_pretty = 'PurgeDeadSymbols' in p.stmt_point_kind
stmt_color = 'cyan3'
if p.loc is not None:
self._dump('<tr><td align="left" width="0">'
'%s:<b>%s</b>:<b>%s</b>:</td>'
'<td align="left" width="0"><font color="%s">'
'%s</font></td><td>%s</td></tr>'
'%s</font></td>'
'<td align="left"><font color="%s">%s</font></td>'
'<td>%s</td></tr>'
% (p.loc.filename, p.loc.line,
p.loc.col, color, p.stmt_kind, p.pretty))
p.loc.col, color, p.stmt_kind,
stmt_color, p.stmt_point_kind,
p.pretty if not skip_pretty else ''))
else:
self._dump('<tr><td align="left" width="0">'
'<i>Invalid Source Location</i>:</td>'
'<td align="left" width="0">'
'<font color="%s">%s</font></td><td>%s</td></tr>'
% (color, p.stmt_kind, p.pretty))
'<font color="%s">%s</font></td>'
'<td align="left"><font color="%s">%s</font></td>'
'<td>%s</td></tr>'
% (color, p.stmt_kind,
stmt_color, p.stmt_point_kind,
p.pretty if not skip_pretty else ''))
elif p.kind == 'Edge':
self._dump('<tr><td width="0"></td>'
'<td align="left" width="0">'
'<font color="%s">%s</font></td><td align="left">'
'[B%d] -\\> [B%d]</td></tr>'
% (color, p.kind, p.src_id, p.dst_id))
% (color, 'BlockEdge', p.src_id, p.dst_id))
elif p.kind == 'BlockEntrance':
self._dump('<tr><td width="0"></td>'
'<td align="left" width="0">'
'<font color="%s">%s</font></td>'
'<td align="left">[B%d]</td></tr>'
% (color, p.kind, p.block_id))
else:
# TODO: Print more stuff for other kinds of points.
self._dump('<tr><td width="0"></td>'
@ -406,7 +425,7 @@ class DotDumpVisitor(object):
if p.tag is not None:
self._dump('<tr><td width="0"></td>'
'<td colspan="2" align="left">'
'<td colspan="3" align="left">'
'<b>Tag: </b> <font color="crimson">'
'%s</font></td></tr>' % p.tag)