summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-10-18 20:15:39 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-10-18 20:15:39 +0000
commit15e9d0493a9f62d0a6b68178627dda057d14bbd1 (patch)
treee165b2ed2a1d00fad157dfae4557a8fef0cb1b87
parentd1127baaf9c936305883eac6e16fee7de406c627 (diff)
downloadclang-15e9d0493a9f62d0a6b68178627dda057d14bbd1.tar.gz
[analyzer] Fix FieldRegion dumps.
The '->' thing has always been confusing; the actual operation '->' translates to a pointer dereference together with adding a FieldRegion, but FieldRegion on its own doesn't imply an additional pointer dereference. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375281 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/StaticAnalyzer/Core/MemRegion.cpp2
-rw-r--r--test/Analysis/dump_egraph.cpp2
-rw-r--r--test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp2
-rw-r--r--test/Analysis/expr-inspection.c11
4 files changed, 13 insertions, 4 deletions
diff --git a/lib/StaticAnalyzer/Core/MemRegion.cpp b/lib/StaticAnalyzer/Core/MemRegion.cpp
index c7b280adcd..a10d7e69ad 100644
--- a/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -506,7 +506,7 @@ void ElementRegion::dumpToStream(raw_ostream &os) const {
}
void FieldRegion::dumpToStream(raw_ostream &os) const {
- os << superRegion << "->" << *getDecl();
+ os << superRegion << "." << *getDecl();
}
void ObjCIvarRegion::dumpToStream(raw_ostream &os) const {
diff --git a/test/Analysis/dump_egraph.cpp b/test/Analysis/dump_egraph.cpp
index a56f061949..9b87d1a90f 100644
--- a/test/Analysis/dump_egraph.cpp
+++ b/test/Analysis/dump_egraph.cpp
@@ -20,7 +20,7 @@ void foo() {
// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"foo\", \"location\": 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\", \"location\": \{ \"line\": 16, \"column\": 5, \"file\": \"{{.*}}dump_egraph.cpp\" \}, \"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: \"location_context\": \"#0 Call\", \"calling\": \"T::T\", \"location\": \{ \"line\": 16, \"column\": 5, \"file\": \"{{.*}}dump_egraph.cpp\" \}, \"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\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"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/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp b/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
index 472627ef61..96df69f857 100644
--- a/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
+++ b/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
@@ -20,6 +20,6 @@ struct B {
void test() {
// CHECK: (construct into member variable)
// CHECK-SAME: <td align="left">a</td>
- // CHECK-SAME: <td align="left">&amp;b-&gt;a</td>
+ // CHECK-SAME: <td align="left">&amp;b.a</td>
B b;
}
diff --git a/test/Analysis/expr-inspection.c b/test/Analysis/expr-inspection.c
index 6d9ea4bb26..7c5d9e5c49 100644
--- a/test/Analysis/expr-inspection.c
+++ b/test/Analysis/expr-inspection.c
@@ -5,6 +5,7 @@
// Self-tests for the debug.ExprInspection checker.
void clang_analyzer_dump(int x);
+void clang_analyzer_dump_pointer(int *p);
void clang_analyzer_printState();
void clang_analyzer_numTimesReached();
@@ -30,7 +31,7 @@ void foo(int x) {
// CHECK-NEXT: ]}
// CHECK-NEXT: ]},
// CHECK-NEXT: "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [
-// CHECK-NEXT: { "lctx_id": 1, "location_context": "#0 Call", "calling": "foo", "location": null, "items": [
+// CHECK-NEXT: { "lctx_id": {{[0-9]+}}, "location_context": "#0 Call", "calling": "foo", "location": null, "items": [
// CHECK-NEXT: { "stmt_id": {{[0-9]+}}, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
// CHECK-NEXT: ]}
// CHECK-NEXT: ]},
@@ -43,3 +44,11 @@ void foo(int x) {
// CHECK-NEXT: "checker_messages": null
// CHECK-NEXT: }
+struct S {
+ int x, y;
+};
+
+void test_field_dumps(struct S s, struct S *p) {
+ clang_analyzer_dump_pointer(&s.x); // expected-warning{{&s.x}}
+ clang_analyzer_dump_pointer(&p->x); // expected-warning{{&SymRegion{reg_$0<struct S * p>}.x}}
+}