diff --git a/clang/lib/Analysis/ProgramPoint.cpp b/clang/lib/Analysis/ProgramPoint.cpp index 97e90965d007..0783fbed5315 100644 --- a/clang/lib/Analysis/ProgramPoint.cpp +++ b/clang/lib/Analysis/ProgramPoint.cpp @@ -188,7 +188,11 @@ void ProgramPoint::printJson(llvm::raw_ostream &Out, const char *NL) const { Out << "Statement\", \"stmt_kind\": \"" << S->getStmtClassName() << "\", \"stmt_id\": " << S->getID(Context) - << ", \"pointer\": \"" << (const void *)S << "\", \"pretty\": "; + << ", \"pointer\": \"" << (const void *)S << "\", "; + if (const auto *CS = dyn_cast(S)) + Out << "\"cast_kind\": \"" << CS->getCastKindName() << "\", "; + + Out << "\"pretty\": "; S->printJson(Out, nullptr, PP, AddQuotes); diff --git a/clang/test/Analysis/exploded-graph-rewriter/program_points.dot b/clang/test/Analysis/exploded-graph-rewriter/program_points.dot index 2f49d7f75ef0..c27c230ebfb3 100644 --- a/clang/test/Analysis/exploded-graph-rewriter/program_points.dot +++ b/clang/test/Analysis/exploded-graph-rewriter/program_points.dot @@ -116,3 +116,51 @@ Node0x3 [shape=record,label= } ]} \l}"]; + +// CHECK-NEXT: Program point: +// 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: main.cpp:8:9: +// CHECK-SAME: +// CHECK-SAME: +// CHECK-SAME: ImplicitCastExpr (LValueToRValue) +// CHECK-SAME: +// CHECK-SAME: S5 +// CHECK-SAME: PreStmt +// CHECK-SAME: y
+// CHECK-SAME: +// CHECK-SAME: Tag: +// CHECK-SAME: ExprEngine : Clean Node +// CHECK-SAME:
+Node0x4 [shape=record,label= + "{ + { "node_id": 4, "pointer": "0x4", "has_report": false, "is_sink": false, + "program_state": null, "program_points": [ + { + "kind": "Statement", + "stmt_kind": "ImplicitCastExpr", + "cast_kind": "LValueToRValue", + "stmt_point_kind": "PreStmt", + "stmt_id": 5, + "pointer": "0x6", + "pretty": "y", + "location": { + "file": "main.cpp", + "line": 8, + "column": 9 + }, + "tag": "ExprEngine : Clean Node" + } + ]} +\l}"]; diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py index 05b01b3f9502..77da7392e360 100755 --- a/clang/utils/analyzer/exploded-graph-rewriter.py +++ b/clang/utils/analyzer/exploded-graph-rewriter.py @@ -73,6 +73,8 @@ class ProgramPoint(object): elif self.kind == 'Statement': logging.debug(json_pp) self.stmt_kind = json_pp['stmt_kind'] + self.cast_kind = json_pp['cast_kind'] \ + if 'cast_kind' in json_pp else None self.stmt_point_kind = json_pp['stmt_point_kind'] self.stmt_id = json_pp['stmt_id'] self.pointer = json_pp['pointer'] @@ -497,7 +499,9 @@ class DotDumpVisitor(object): 'S%s' '%s' '%s' - % (self._make_sloc(p.loc), color, p.stmt_kind, + % (self._make_sloc(p.loc), color, + '%s (%s)' % (p.stmt_kind, p.cast_kind) + if p.cast_kind is not None else p.stmt_kind, p.stmt_id, stmt_color, p.stmt_point_kind, self._short_pretty(p.pretty) if not skip_pretty else ''))