From: Artem Dergachev Date: Tue, 2 Jul 2019 02:17:53 +0000 (+0000) Subject: [analyzer] exploded-graph-rewriter: Improve program point dumps. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=280606f8a21f756c8ed32ef5573de6e632107bb2;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364881 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/exploded-graph-rewriter/escapes.c b/test/Analysis/exploded-graph-rewriter/escapes.c index 140ec676fb..84de67939c 100644 --- a/test/Analysis/exploded-graph-rewriter/escapes.c +++ b/test/Analysis/exploded-graph-rewriter/escapes.c @@ -17,7 +17,7 @@ void escapes() { // CHECK-SAME: &Element\{"foo",0 S64b,char\} const char *const foo = "\x66\x6f\x6f"; - // CHECK: BinaryOperator + // CHECK: BinaryOperator // CHECK-SAME: 1 \| 2 // CHECK-SAME: 3 S32b int x = 1 | 2; diff --git a/test/Analysis/exploded-graph-rewriter/program_points.dot b/test/Analysis/exploded-graph-rewriter/program_points.dot index 31dcc4adb6..2c03ac92d0 100644 --- a/test/Analysis/exploded-graph-rewriter/program_points.dot +++ b/test/Analysis/exploded-graph-rewriter/program_points.dot @@ -3,18 +3,28 @@ // FIXME: Substitution doesn't seem to work on Windows. // UNSUPPORTED: system-windows -// CHECK: Program point: +// CHECK: Program points: // CHECK-SAME: // CHECK-SAME: // CHECK-SAME: // CHECK-SAME: // CHECK-SAME: // CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: // CHECK-SAME:
// CHECK-SAME: -// CHECK-SAME: Edge +// CHECK-SAME: BlockEdge // CHECK-SAME: // CHECK-SAME: [B0] -> [B1] // CHECK-SAME:
+// CHECK-SAME: +// CHECK-SAME: BlockEntrance +// CHECK-SAME: +// CHECK-SAME: [B1] +// CHECK-SAME:
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):4:5: // CHECK-SAME: // CHECK-SAME: -// CHECK-SAME: DeclRefExpr +// CHECK-SAME: DeclRefExpr +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: PreStmt // CHECK-SAME: // CHECK-SAME: x // CHECK-SAME: // CHECK-SAME: // CHECK-SAME: // CHECK-SAME: -// CHECK-SAME: +// CHECK-SAME: // CHECK-SAME: Tag: // CHECK-SAME: ExprEngine : Clean Node // CHECK-SAME: @@ -57,6 +78,7 @@ Node0x2 [shape=record,label= { "kind": "Statement", "stmt_kind": "DeclRefExpr", + "stmt_point_kind": "PreStmt", "stmd_id": 3, "pointer": "0x3", "pretty": "x", diff --git a/utils/analyzer/exploded-graph-rewriter.py b/utils/analyzer/exploded-graph-rewriter.py index 7278c70803..c5b9507123 100755 --- a/utils/analyzer/exploded-graph-rewriter.py +++ b/utils/analyzer/exploded-graph-rewriter.py @@ -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('' '%s:%s:%s:' '' - '%s%s' + '%s' + '%s' + '%s' % (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('' 'Invalid Source Location:' '' - '%s%s' - % (color, p.stmt_kind, p.pretty)) + '%s' + '%s' + '%s' + % (color, p.stmt_kind, + stmt_color, p.stmt_point_kind, + p.pretty if not skip_pretty else '')) elif p.kind == 'Edge': self._dump('' '' '%s' '[B%d] -\\> [B%d]' - % (color, p.kind, p.src_id, p.dst_id)) + % (color, 'BlockEdge', p.src_id, p.dst_id)) + elif p.kind == 'BlockEntrance': + self._dump('' + '' + '%s' + '[B%d]' + % (color, p.kind, p.block_id)) else: # TODO: Print more stuff for other kinds of points. self._dump('' @@ -406,7 +425,7 @@ class DotDumpVisitor(object): if p.tag is not None: self._dump('' - '' + '' 'Tag: ' '%s' % p.tag)