Skip to content

Commit 7cddf9c

Browse files
committed
[analyzer] Dump the environment entry kind as well
By this change the `exploded-graph-rewriter` will display the class kind of the expression of the environment entry. It makes easier to decide if the given entry corresponds to the lvalue or to the rvalue of some expression. It turns out the rewriter already had support for visualizing it, but probably was never actually used? Reviewed By: martong Differential Revision: https://reviews.llvm.org/D132109
1 parent 955e6ac commit 7cddf9c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/StaticAnalyzer/Core/Environment.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ void Environment::printJson(raw_ostream &Out, const ASTContext &Ctx,
274274

275275
const Stmt *S = I->first.getStmt();
276276
Indent(Out, InnerSpace, IsDot)
277-
<< "{ \"stmt_id\": " << S->getID(Ctx) << ", \"pretty\": ";
277+
<< "{ \"stmt_id\": " << S->getID(Ctx) << ", \"kind\": \""
278+
<< S->getStmtClassName() << "\", \"pretty\": ";
278279
S->printJson(Out, nullptr, PP, /*AddQuotes=*/true);
279280

280281
Out << ", \"value\": ";

clang/test/Analysis/expr-inspection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void foo(int x) {
3636
// CHECK-NEXT: ]},
3737
// CHECK-NEXT: "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [
3838
// CHECK-NEXT: { "lctx_id": {{[0-9]+}}, "location_context": "#0 Call", "calling": "foo", "location": null, "items": [
39-
// CHECK-NEXT: { "stmt_id": {{[0-9]+}}, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
39+
// CHECK-NEXT: { "stmt_id": {{[0-9]+}}, "kind": "ImplicitCastExpr", "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
4040
// CHECK-NEXT: ]}
4141
// CHECK-NEXT: ]},
4242
// CHECK-NEXT: "constraints": [

0 commit comments

Comments
 (0)