Skip to content

Commit 3bb7b2e

Browse files
committed
[analyzer] Fix JSON dumps for dynamic type information.
They're now valid JSON. Differential Revision: https://reviews.llvm.org/D62716 llvm-svn: 363894
1 parent 4482063 commit 3bb7b2e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clang/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State,
7272
Out << "{ \"region\": \"" << MR << "\", \"dyn_type\": ";
7373
if (DTI.isValid()) {
7474
Out << '\"' << DTI.getType()->getPointeeType().getAsString()
75-
<< "\" \"sub_classable\": "
75+
<< "\", \"sub_classable\": "
7676
<< (DTI.canBeASubClass() ? "true" : "false");
7777
} else {
7878
Out << "null"; // Invalid type info
7979
}
80-
Out << "\" }";
80+
Out << "}";
8181

8282
if (std::next(I) != DTM.end())
8383
Out << ',';

clang/test/Analysis/dump_egraph.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ struct T {
1414
void foo() {
1515
// Test that dumping symbols conjured on null statements doesn't crash.
1616
T t;
17+
18+
new S;
1719
}
1820

1921
// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"foo\", \"call_line\": null, \"items\": [\l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\{ \"lctx_id\": 1, \"stmt_id\": {{[0-9]+}}, \"kind\": \"construct into local variable\", \"argument_index\": null, \"pretty\": \"T t;\", \"value\": \"&t\"
2022

2123
// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"T::T\", \"call_line\": \"16\", \"items\": [\l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\{ \"lctx_id\": 2, \"init_id\": {{[0-9]+}}, \"kind\": \"construct into member variable\", \"argument_index\": null, \"pretty\": \"s\", \"value\": \"&t-\>s\"
2224

23-
// CHECK: \"cluster\": \"t\", \"items\": [\l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$3\{int, LC3, no stmt, #1\}\"
25+
// CHECK: \"cluster\": \"t\", \"items\": [\l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
2426

27+
// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false\}\l

0 commit comments

Comments
 (0)