Skip to content

Commit

Permalink
[analyzer] exploded-graph-rewriter: Initial commit.
Browse files Browse the repository at this point in the history
This is a utility to improve readability and generally manipulate
GraphViz dumps of the analysis graph. Such dumps are often huge and
not only hard to read, but also often hang the viewer apps with their
mere size. Such script should significantly improve debugging experience.

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

llvm-svn: 362340
  • Loading branch information
haoNoQ committed Jun 2, 2019
1 parent fde26d2 commit 1623607
Show file tree
Hide file tree
Showing 7 changed files with 584 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clang/test/Analysis/exploded-graph-rewriter/edge.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s

Node0x1 [shape=record,label=
"{{ "node_id": 1, "pointer": "0x1",
"program_state": null, "program_points": []}\l}"];

// CHECK: Node0x1 -> Node0x2;
Node0x1 -> Node0x2;

Node0x2 [shape=record,label=
"{{ "node_id": 2, "pointer": "0x2",
"program_state": null, "program_points": []}\l}"];
9 changes: 9 additions & 0 deletions clang/test/Analysis/exploded-graph-rewriter/empty.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s

digraph "Exploded Graph" {
label="Exploded Graph";
}

// CHECK: digraph "ExplodedGraph" {
// CHECK-NEXT: label="";
// CHECK-NEXT: }
50 changes: 50 additions & 0 deletions clang/test/Analysis/exploded-graph-rewriter/environment.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s

// CHECK: <b>Environment: </b>
// CHECK-SAME: <table border="0">
// CHECK-SAME: <tr>
// CHECK-SAME: <td align="left">
// CHECK-SAME: <b>#0 Call</b>
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: <font color="grey60">foo </font>(line 4)
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: <tr>
// CHECK-SAME: <td align="left">
// CHECK-SAME: <i>S5</i>
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: bar()
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: Unknown
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: </table>
Node0x1 [shape=record,label=
"{
{ "node_id": 1,
"pointer": "0x1",
"state_id": 2,
"program_points": [],
"program_state": {
"store": null,
"environment": [
{
"location_context": "#0 Call",
"lctx_id": 3,
"calling": "foo",
"call_line": 4,
"items": [
{
"stmt_id": 5,
"pretty": "bar()",
"value": "Unknown"
}
]
}
]
}
}
\l}"];
13 changes: 13 additions & 0 deletions clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import lit.util
import lit.formats
import os

use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
config.test_format = lit.formats.ShTest(use_lit_shell == "0")

config.substitutions.append(('%exploded_graph_rewriter',
lit.util.which('exploded-graph-rewriter.py',
os.path.join(config.clang_src_dir,
'utils', 'analyzer'))))

config.suffixes = ['.dot']
60 changes: 60 additions & 0 deletions clang/test/Analysis/exploded-graph-rewriter/program_points.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s

// CHECK: <b>Program point:</b>
// CHECK-SAME: <table border="0" align="left" width="0">
// CHECK-SAME: <tr>
// CHECK-SAME: <td width="0">
// CHECK-SAME: -
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left" width="0">
// CHECK-SAME: <font color="gold3">Edge</font>
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: [B0] -&gt; [B1]
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: </table>
Node0x1 [shape=record,label=
"{
{ "node_id": 1, "pointer": "0x1",
"program_state": null, "program_points": [
{
"kind": "Edge",
"src_id": 0,
"dst_id": 1,
"terminator": null,
"term_kind": null,
"tag": null }
]}
\l}"];

// CHECK-NEXT: <b>Program point:</b>
// CHECK-SAME: <table border="0" align="left" width="0">
// CHECK-SAME: <tr>
// CHECK-SAME: <td align="left" width="0">
// 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: </td>
// CHECK-SAME: <td>x</td>
// CHECK-SAME: </tr>
// CHECK-SAME: </table>
Node0x2 [shape=record,label=
"{
{ "node_id": 2, "pointer": "0x2",
"program_state": null, "program_points": [
{
"kind": "Statement",
"stmt_kind": "DeclRefExpr",
"stmd_id": 3,
"pointer": "0x3",
"pretty": "x",
"location": {
"line": 4,
"column": 5
},
"tag": null
}
]}
\l}"];
42 changes: 42 additions & 0 deletions clang/test/Analysis/exploded-graph-rewriter/store.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s

// CHECK: <b>Store: </b>
// CHECK-SAME: <table border="0">
// CHECK-SAME: <tr>
// CHECK-SAME: <td align="left">
// CHECK-SAME: x
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: 0
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: (<i>Default</i>)
// CHECK-SAME: </td>
// CHECK-SAME: <td align="left">
// CHECK-SAME: Undefined
// CHECK-SAME: </td>
// CHECK-SAME: </tr>
// CHECK-SAME: </table>
Node0x1 [shape=record,label=
"{
{ "node_id": 1,
"pointer": "0x1",
"state_id": 2,
"program_points": [],
"program_state": {
"environment": null,
"store": [
{
"cluster": "x",
"items": [
{
"kind": "Default",
"offset": 0,
"value": "Undefined"
}
]
}
]
}
}
\l}"];
Loading

0 comments on commit 1623607

Please sign in to comment.