Index: clang/lib/StaticAnalyzer/Core/Environment.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/Environment.cpp +++ clang/lib/StaticAnalyzer/Core/Environment.cpp @@ -204,13 +204,13 @@ const LocationContext *LCtx, const char *NL, unsigned int Space, bool IsDot) const { Indent(Out, Space, IsDot) << "\"environment\": "; - ++Space; if (ExprBindings.isEmpty()) { Out << "null," << NL; return; } + ++Space; if (!LCtx) { // Find the freshest location context. llvm::SmallPtrSet FoundContexts; @@ -227,7 +227,8 @@ assert(LCtx); - Out << '[' << NL; // Start of Environment. + Out << "{ \"pointer\": \"" << (const void *)LCtx->getStackFrame() + << "\", \"items\": [" << NL; PrintingPolicy PP = Ctx.getPrintingPolicy(); LCtx->printJson(Out, NL, Space, IsDot, [&](const LocationContext *LC) { @@ -280,5 +281,5 @@ Out << "null "; }); - Indent(Out, --Space, IsDot) << "]," << NL; // End of Environment. + Indent(Out, --Space, IsDot) << "]}," << NL; } Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -2640,7 +2640,7 @@ return; } - Out << '[' << NL; - Bindings.printJson(Out, NL, ++Space, IsDot); - Indent(Out, --Space, IsDot) << "]," << NL; + Out << "{ \"pointer\": \"" << Bindings.asStore() << "\", \"items\": [" << NL; + Bindings.printJson(Out, NL, Space + 1, IsDot); + Indent(Out, Space, IsDot) << "]}," << NL; } Index: clang/test/Analysis/exploded-graph-rewriter/environment.dot =================================================================== --- clang/test/Analysis/exploded-graph-rewriter/environment.dot +++ clang/test/Analysis/exploded-graph-rewriter/environment.dot @@ -33,21 +33,24 @@ "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" - } - ] - } - ] + "environment": { + "pointer": "0x2", + "items": [ + { + "location_context": "#0 Call", + "lctx_id": 3, + "calling": "foo", + "call_line": 4, + "items": [ + { + "stmt_id": 5, + "pretty": "bar()", + "value": "Unknown" + } + ] + } + ] + } } } \l}"]; Index: clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot =================================================================== --- clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot +++ clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot @@ -12,21 +12,24 @@ "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" - } - ] - } - ] + "environment": { + "pointer": "0x2", + "items": [ + { + "location_context": "#0 Call", + "lctx_id": 3, + "calling": "foo", + "call_line": 4, + "items": [ + { + "stmt_id": 5, + "pretty": "bar()", + "value": "Unknown" + } + ] + } + ] + } } } \l}"]; @@ -54,21 +57,24 @@ "program_points": [], "program_state": { "store": null, - "environment": [ - { - "location_context": "#0 Call", - "lctx_id": 3, - "calling": "foo", - "call_line": 4, - "items": [ - { - "stmt_id": 9, - "pretty": "baz()", - "value": "Undefined" - } - ] - } - ] + "environment": { + "pointer": "0x2", + "items": [ + { + "location_context": "#0 Call", + "lctx_id": 3, + "calling": "foo", + "call_line": 4, + "items": [ + { + "stmt_id": 9, + "pretty": "baz()", + "value": "Undefined" + } + ] + } + ] + } } } \l}"]; @@ -90,21 +96,24 @@ "program_points": [], "program_state": { "store": null, - "environment": [ - { - "location_context": "#0 Call", - "lctx_id": 3, - "calling": "foo", - "call_line": 4, - "items": [ - { - "stmt_id": 9, - "pretty": "baz()", - "value": "Undefined" - } - ] - } - ] + "environment": { + "pointer": "0x2", + "items": [ + { + "location_context": "#0 Call", + "lctx_id": 3, + "calling": "foo", + "call_line": 4, + "items": [ + { + "stmt_id": 9, + "pretty": "baz()", + "value": "Undefined" + } + ] + } + ] + } } } \l}"]; Index: clang/test/Analysis/exploded-graph-rewriter/store.dot =================================================================== --- clang/test/Analysis/exploded-graph-rewriter/store.dot +++ clang/test/Analysis/exploded-graph-rewriter/store.dot @@ -28,19 +28,22 @@ "program_points": [], "program_state": { "environment": null, - "store": [ - { - "cluster": "x", - "pointer": "0x3", - "items": [ - { - "kind": "Default", - "offset": 0, - "value": "Undefined" - } - ] - } - ] + "store": { + "pointer": "0x2", + "items": [ + { + "cluster": "x", + "pointer": "0x3", + "items": [ + { + "kind": "Default", + "offset": 0, + "value": "Undefined" + } + ] + } + ] + } } } \l}"]; Index: clang/test/Analysis/exploded-graph-rewriter/store_diff.dot =================================================================== --- clang/test/Analysis/exploded-graph-rewriter/store_diff.dot +++ clang/test/Analysis/exploded-graph-rewriter/store_diff.dot @@ -11,19 +11,22 @@ "program_points": [], "program_state": { "environment": null, - "store": [ - { - "cluster": "x", - "pointer": "0x3", - "items": [ - { - "kind": "Default", - "offset": 0, - "value": "Undefined" - } - ] - } - ] + "store": { + "pointer": "0x2", + "items": [ + { + "cluster": "x", + "pointer": "0x3", + "items": [ + { + "kind": "Default", + "offset": 0, + "value": "Undefined" + } + ] + } + ] + } } } \l}"]; @@ -52,19 +55,22 @@ "program_points": [], "program_state": { "environment": null, - "store": [ - { - "cluster": "x", - "pointer": "0x3", - "items": [ - { - "kind": "Default", - "offset": 0, - "value": "Unknown" - } - ] - } - ] + "store": { + "pointer": "0x5", + "items": [ + { + "cluster": "x", + "pointer": "0x3", + "items": [ + { + "kind": "Default", + "offset": 0, + "value": "Unknown" + } + ] + } + ] + } } } \l}"]; Index: clang/test/Analysis/expr-inspection.c =================================================================== --- clang/test/Analysis/expr-inspection.c +++ clang/test/Analysis/expr-inspection.c @@ -24,16 +24,16 @@ } // CHECK: "program_state": { -// CHECK-NEXT: "store": [ +// CHECK-NEXT: "store": { "pointer": "{{0x[0-9a-f]+}}", "items": [ // CHECK-NEXT: { "cluster": "y", "pointer": "{{0x[0-9a-f]+}}", "items": [ // CHECK-NEXT: { "kind": "Direct", "offset": 0, "value": "2 S32b" } // CHECK-NEXT: ]} -// CHECK-NEXT: ], -// CHECK-NEXT: "environment": [ +// CHECK-NEXT: ]}, +// CHECK-NEXT: "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [ // CHECK-NEXT: { "lctx_id": 1, "location_context": "#0 Call", "calling": "foo", "call_line": null, "items": [ // CHECK-NEXT: { "stmt_id": {{[0-9]+}}, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" } // CHECK-NEXT: ]} -// CHECK-NEXT: ], +// CHECK-NEXT: ]}, // CHECK-NEXT: "constraints": [ // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" } // CHECK-NEXT: ], Index: clang/utils/analyzer/exploded-graph-rewriter.py =================================================================== --- clang/utils/analyzer/exploded-graph-rewriter.py +++ clang/utils/analyzer/exploded-graph-rewriter.py @@ -113,7 +113,8 @@ class Environment(object): def __init__(self, json_e): super(Environment, self).__init__() - self.frames = [EnvironmentFrame(f) for f in json_e] + self.ptr = json_e['pointer'] + self.frames = [EnvironmentFrame(f) for f in json_e['items']] def diff_frames(self, prev): # TODO: It's difficult to display a good diff when frame numbers shift. @@ -177,8 +178,9 @@ class Store(object): def __init__(self, json_s): super(Store, self).__init__() + self.ptr = json_s['pointer'] self.clusters = collections.OrderedDict( - [(c['pointer'], StoreCluster(c)) for c in json_s]) + [(c['pointer'], StoreCluster(c)) for c in json_s['items']]) def diff_clusters(self, prev): removed = [k for k in prev.clusters if k not in self.clusters]