Commit 2b4f6df9 authored by Artem Dergachev's avatar Artem Dergachev
Browse files

[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.

llvm-svn: 375281
parent b3e34e04
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 {
+1 −1
Original line number Diff line number Diff line
@@ -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\}\"

+1 −1
Original line number Diff line number Diff line
@@ -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;
}
+10 −1
Original line number Diff line number Diff line
@@ -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}}
}