summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-06-19 23:33:48 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-06-19 23:33:48 +0000
commitf9f6cdb1a8d05585256f6f2285aa684e557e5676 (patch)
tree280c24cf5efd46d1367f614dfe0c278ed51a55fe
parent3bb7b2ec7f7bcb913dc4a44fdbe14af508acefb7 (diff)
downloadbcm5719-llvm-f9f6cdb1a8d05585256f6f2285aa684e557e5676.tar.gz
bcm5719-llvm-f9f6cdb1a8d05585256f6f2285aa684e557e5676.zip
[analyzer] Fix JSON dumps for location contexts.
Location context ID is a property of the location context, not of an item within it. It's useful to know the id even when there are no items in the context, eg. for the purposes of figuring out how did contents of the Environment for the same location context changed across states. Differential Revision: https://reviews.llvm.org/D62754 llvm-svn: 363895
-rw-r--r--clang/lib/Analysis/AnalysisDeclContext.cpp5
-rw-r--r--clang/lib/StaticAnalyzer/Core/Environment.cpp3
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngine.cpp3
-rw-r--r--clang/test/Analysis/dump_egraph.cpp4
-rw-r--r--clang/test/Analysis/expr-inspection.c4
5 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp
index ba1f8375124..28d308132fd 100644
--- a/clang/lib/Analysis/AnalysisDeclContext.cpp
+++ b/clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -527,7 +527,8 @@ void LocationContext::printJson(raw_ostream &Out, const char *NL,
unsigned Frame = 0;
for (const LocationContext *LCtx = this; LCtx; LCtx = LCtx->getParent()) {
- Indent(Out, Space, IsDot) << "{ \"location_context\": \"";
+ Indent(Out, Space, IsDot)
+ << "{ \"lctx_id\": " << LCtx->getID() << ", \"location_context\": \"";
switch (LCtx->getKind()) {
case StackFrame:
Out << '#' << Frame << " Call\", \"calling\": \"";
@@ -541,7 +542,7 @@ void LocationContext::printJson(raw_ostream &Out, const char *NL,
if (const Stmt *S = cast<StackFrameContext>(LCtx)->getCallSite()) {
Out << '\"';
printLocation(Out, SM, S->getBeginLoc());
- Out << '\"';
+ Out << '\"';
} else {
Out << "null";
}
diff --git a/clang/lib/StaticAnalyzer/Core/Environment.cpp b/clang/lib/StaticAnalyzer/Core/Environment.cpp
index 94cc4d6dbb2..0ca3f778f1b 100644
--- a/clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -261,8 +261,7 @@ void Environment::printJson(raw_ostream &Out, const ASTContext &Ctx,
const Stmt *S = I->first.getStmt();
Indent(Out, InnerSpace, IsDot)
- << "{ \"lctx_id\": " << LC->getID()
- << ", \"stmt_id\": " << S->getID(Ctx) << ", \"pretty\": ";
+ << "{ \"stmt_id\": " << S->getID(Ctx) << ", \"pretty\": ";
S->printJson(Out, nullptr, PP, /*AddQuotes=*/true);
Out << ", \"value\": ";
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index b2178893904..2cef99157c7 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -149,9 +149,6 @@ public:
if (!S)
I = getItem().getCXXCtorInitializer();
- // IDs
- Out << "\"lctx_id\": " << getLocationContext()->getID() << ", ";
-
if (S)
Out << "\"stmt_id\": " << S->getID(getASTContext());
else
diff --git a/clang/test/Analysis/dump_egraph.cpp b/clang/test/Analysis/dump_egraph.cpp
index d74009589f0..3609420198f 100644
--- a/clang/test/Analysis/dump_egraph.cpp
+++ b/clang/test/Analysis/dump_egraph.cpp
@@ -18,9 +18,9 @@ void foo() {
new S;
}
-// 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\"
+// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"foo\", \"call_line\": null, \"items\": [\l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\{ \"stmt_id\": {{[0-9]+}}, \"kind\": \"construct into local variable\", \"argument_index\": null, \"pretty\": \"T t;\", \"value\": \"&t\"
-// 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\"
+// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"T::T\", \"call_line\": \"16\", \"items\": [\l&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\{ \"init_id\": {{[0-9]+}}, \"kind\": \"construct into member variable\", \"argument_index\": null, \"pretty\": \"s\", \"value\": \"&t-\>s\"
// 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\}\"
diff --git a/clang/test/Analysis/expr-inspection.c b/clang/test/Analysis/expr-inspection.c
index a1fd952b26d..230ee5007c0 100644
--- a/clang/test/Analysis/expr-inspection.c
+++ b/clang/test/Analysis/expr-inspection.c
@@ -30,8 +30,8 @@ void foo(int x) {
// CHECK-NEXT: ]}
// CHECK-NEXT: ],
// CHECK-NEXT: "environment": [
-// CHECK-NEXT: { "location_context": "#0 Call", "calling": "foo", "call_line": null, "items": [
-// CHECK-NEXT: { "lctx_id": 1, "stmt_id": {{[0-9]+}}, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
+// 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: "constraints": [
OpenPOWER on IntegriCloud