8000 [analyzer] Fix FieldRegion dumps. · haoNoQ/llvm-project@2b4f6df · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b4f6df

Browse files
committed
[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
1 parent b3e34e0 commit 2b4f6df

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void ElementRegion::dumpToStream(raw_ostream &os) const {
506506
}
507507

508508
void FieldRegion::dumpToStream(raw_ostream &os) const {
509-
os << superRegion << "->" << *getDecl();
509+
os << superRegion << "." << *getDecl();
510510
}
511511

512512
void ObjCIvarRegion::dumpToStream(raw_ostream &os) const {

clang/test/Analysis/dump_egraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void foo() {
2020

2121
// 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\"
2222

23-
// 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\"
23+
// 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\"
2424

2525
// 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\}\"
2626

clang/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ struct B {
2020
void test() {
2121
// CHECK: (construct into member variable)
2222
// CHECK-SAME: <td align="left">a</td>
23-
// CHECK-SAME: <td align="left">&amp;b-&gt;a</td>
23+
// CHECK-SAME: <td align="left">&amp;b.a</td>
2424
B b;
2525
}

clang/test/Analysis/expr-inspection.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Self-tests for the debug.ExprInspection checker.
66

77
void clang_analyzer_dump(int x);
8+
void clang_analyzer_dump_pointer(int *p);
89
void clang_analyzer_printState();
910
void clang_analyzer_numTimesReached();
1011

@@ -30,7 +31,7 @@ void foo(int x) {
3031
// CHECK-NEXT: ]}
3132
// CHECK-NEXT: ]},
3233
// CHECK-NEXT: "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [
33-
// CHECK-NEXT: { "lctx_id": 1, "location_context": "#0 Call", "calling": "foo", "location": null, "items": [
34+
// CHECK-NEXT: { "lctx_id": {{[0-9]+}}, "location_context": "#0 Call", "calling": "foo", "location": null, "items": [
3435
// CHECK-NEXT: { "stmt_id": {{[0-9]+}}, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
3536
// CHECK-NEXT: ]}
3637
// CHECK-NEXT: ]},
@@ -43,3 +44,11 @@ void foo(int x) {
4344
// CHECK-NEXT: "checker_messages": null
4445
// CHECK-NEXT: }
4546

47+
struct S {
48+
int x, y;
49+
};
50+
51+
void test_field_dumps(struct S s, struct S *p) {
52+
clang_analyzer_dump_pointer(&s.x); // expected-warning{{&s.x}}
53+
clang_analyzer_dump_pointer(&p->x); // expected-warning{{&SymRegion{reg_$0<struct S * p>}.x}}
54+
}

0 commit comments

Comments
 (0)
0