Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/ProgramState.cpp +++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -10,13 +10,14 @@ // //===----------------------------------------------------------------------===// -#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" #include "clang/Analysis/CFG.h" +#include "clang/Basic/JsonSupport.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h" #include "llvm/Support/raw_ostream.h" using namespace clang; @@ -443,13 +444,16 @@ void ProgramState::print(raw_ostream &Out, const LocationContext *LCtx, const char *NL, const char *Sep, unsigned int Space) const { - // Print the store. ProgramStateManager &Mgr = getStateManager(); - const ASTContext &Context = getStateManager().getContext(); + + Indent(Out, Space) << "\"program_state\": {" << NL; + ++Space; + + // Print the store. Mgr.getStoreManager().print(Out, getStore(), NL, Sep, Space); // Print out the environment. - Env.print(Out, Context, LCtx, NL, Sep, Space); + Env.print(Out, Mgr.getContext(), LCtx, NL, Sep, Space); // Print out the constraints. Mgr.getConstraintManager().print(Out, this, NL, Sep, Space); @@ -459,6 +463,9 @@ // Print checker-specific data. Mgr.getOwningEngine().printState(Out, this, LCtx, NL, Sep, Space); + + --Space; + Indent(Out, Space) << "}"; } void ProgramState::printDOT(raw_ostream &Out, const LocationContext *LCtx, Index: clang/test/Analysis/dump_egraph.cpp =================================================================== --- clang/test/Analysis/dump_egraph.cpp +++ clang/test/Analysis/dump_egraph.cpp @@ -18,9 +18,9 @@ // TODO: Replace that with HTML output. -// CHECK: \"constructing_objects\": \{ \"title\": \"Objects under construction\", \"items\": [\l \{ \"location_context\": \"#0 Call\", \"calling\": \"foo\", \"call_line\": null, \"items\": [\l \{ \"lctx_id\": 1, \"stmt_id\": 1155\", \"kind\": \"construct into local variable\", \"argument_index\": null, \"pretty\": \"T t;\n\", \"value\": \"&t\" +// CHECK: \"constructing_objects\": \{ \"title\": \"Objects under construction\", \"items\": [\l \{ \"location_context\": \"#0 Call\", \"calling\": \"foo\", \"call_line\": null, \"items\": [\l \{ \"lctx_id\": 1, \"stmt_id\": 1155\", \"kind\": \"construct into local variable\", \"argument_index\": null, \"pretty\": \"T t;\n\" -// CHECK: \"constructing_objects\": \{ \"title\": \"Objects under construction\", \"items\": [\l \{ \"location_context\": \"#0 Call\", \"calling\": \"T::T\", \"call_line\": \"16\", \"items\": [\l \{ \"lctx_id\": 2, \"init_id\": 1092\", \"kind\": \"construct into member variable\", \"argument_index\": null, \"pretty\": \"s\", \"value\": \"&t-\>s\" +// CHECK: \"constructing_objects\": \{ \"title\": \"Objects under construction\", \"items\": [\l \{ \"location_context\": \"#0 Call\", \"calling\": \"T::T\", \"call_line\": \"16\", \"items\": [\l \{ \"lctx_id\": 2, \"init_id\": 1092\", \"kind\": \"construct into member variable\", \"argument_index\": null, \"pretty\": \"s\", \"value\": \"&t-\>s\" -// CHECK: \"store\": \{ \"title\": \"Store\", \"items\": [\l \{ \"cluster\": \"t\", \"items\": [\l \{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$3\{int, LC3, no stmt, #1\}\" +// CHECK: \"store\": \{ \"title\": \"Store\", \"items\": [\l \{ \"cluster\": \"t\", \"items\": [\l \{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$3\{int, LC3, no stmt, #1\}\" Index: clang/test/Analysis/expr-inspection.c =================================================================== --- clang/test/Analysis/expr-inspection.c +++ clang/test/Analysis/expr-inspection.c @@ -23,20 +23,22 @@ } } -// CHECK: "store": { "title": "Store", "items": [ -// CHECK-NEXT: { "cluster": "y", "items": [ -// CHECK-NEXT: { "kind": "Direct", "offset": 0, "value": "2 S32b" }, +// CHECK: "program_state": { +// CHECK-NEXT: "store": { "title": "Store", "items": [ +// CHECK-NEXT: { "cluster": "y", "items": [ +// CHECK-NEXT: { "kind": "Direct", "offset": 0, "value": "2 S32b" }, +// CHECK-NEXT: ]}, // CHECK-NEXT: ]}, -// CHECK-NEXT: ]}, -// CHECK-NEXT: "environment": { "title": "Environment", "items": [ -// CHECK-NEXT: { "location_context": "#0 Call", "calling": "foo", "call_line": null, "items": [ -// CHECK-NEXT: { "lctx_id": 1, "stmt_id": 847, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }, +// CHECK-NEXT: "environment": { "title": "Environment", "items": [ +// CHECK-NEXT: { "location_context": "#0 Call", "calling": "foo", "call_line": null, "items": [ +// CHECK-NEXT: { "lctx_id": 1, "stmt_id": 847, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }, +// CHECK-NEXT: ]}, // CHECK-NEXT: ]}, -// CHECK-NEXT: ]}, -// CHECK-NEXT: "constraints": { "title": "Constraints", "items": [ -// CHECK-NEXT: { "name": "reg_$0", "value": "{ [-2147483648, 13] }" }, -// CHECK-NEXT: ]}, -// CHECK-NEXT: "dynamic_types": { "title": "Dynamic types", "items": null }, -// CHECK-NEXT: "constructing_objects": { "title": "Objects under construction", "items": null }, -// CHECK-NEXT: "checker_messages": { "title": "Checker messages", "items": null }, +// CHECK-NEXT: "constraints": { "title": "Constraints", "items": [ +// CHECK-NEXT: { "name": "reg_$0", "value": "{ [-2147483648, 13] }" }, +// CHECK-NEXT: ]}, +// CHECK-NEXT: "dynamic_types": { "title": "Dynamic types", "items": null }, +// CHECK-NEXT: "constructing_objects": { "title": "Objects under construction", "items": null }, +// CHECK-NEXT: "checker_messages": { "title": "Checker messages", "items": null }, +// CHECK-NEXT: }