Skip to content

Commit 1dfddaf

Browse files
committed
C++: Also mark indirections of glvalue instructions as glvalue nodes.
1 parent 4d01a93 commit 1dfddaf

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ private module RawIndirectNodes {
999999

10001000
override Declaration getEnclosingCallable() { result = this.getFunction() }
10011001

1002+
override predicate isGLValue() { this.getOperand().isGLValue() }
1003+
10021004
override DataFlowType getType() {
10031005
exists(int sub, DataFlowType type, boolean isGLValue |
10041006
type = getOperandType(this.getOperand(), isGLValue) and
@@ -1041,6 +1043,8 @@ private module RawIndirectNodes {
10411043

10421044
override Declaration getEnclosingCallable() { result = this.getFunction() }
10431045

1046+
override predicate isGLValue() { this.getInstruction().isGLValue() }
1047+
10441048
override DataFlowType getType() {
10451049
exists(int sub, DataFlowType type, boolean isGLValue |
10461050
type = getInstructionType(this.getInstruction(), isGLValue) and

cpp/ql/test/library-tests/dataflow/dataflow-tests/type-bugs.expected

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,16 @@ irTypeBugs
33
incorrectBaseType
44
| clang.cpp:22:8:22:20 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
55
| clang.cpp:23:17:23:29 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
6-
| dispatch.cpp:60:3:60:14 | *globalBottom | Expected 'Node.getType()' to be Top, but it was Top * |
7-
| dispatch.cpp:61:3:61:14 | *globalMiddle | Expected 'Node.getType()' to be Top, but it was Top * |
86
| flowOut.cpp:50:14:50:15 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
97
| flowOut.cpp:84:9:84:10 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
108
| flowOut.cpp:101:13:101:14 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
11-
| flowOut.cpp:168:3:168:10 | ** ... | Expected 'Node.getType()' to be char, but it was char * |
129
| self_parameter_flow.cpp:8:8:8:9 | *& ... | Expected 'Node.getType()' to be unsigned char, but it was unsigned char * |
1310
| test.cpp:67:28:67:37 | (reference dereference) | Expected 'Node.getType()' to be const int, but it was int * |
14-
| test.cpp:526:3:526:4 | ** ... | Expected 'Node.getType()' to be const int, but it was const int * |
1511
| test.cpp:531:39:531:40 | *& ... | Expected 'Node.getType()' to be int, but it was const int * |
16-
| test.cpp:562:5:562:13 | *globalInt | Expected 'Node.getType()' to be int, but it was int * |
17-
| test.cpp:576:5:576:13 | *globalInt | Expected 'Node.getType()' to be int, but it was int * |
18-
| test.cpp:584:3:584:3 | *x | Expected 'Node.getType()' to be int, but it was int * |
19-
| test.cpp:596:3:596:7 | *access to array | Expected 'Node.getType()' to be int, but it was int * |
2012
| test.cpp:615:13:615:21 | *& ... | Expected 'Node.getType()' to be int, but it was void |
2113
| test.cpp:704:22:704:25 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
2214
| test.cpp:715:24:715:25 | *& ... | Expected 'Node.getType()' to be unsigned char, but it was unsigned char * |
23-
| test.cpp:727:3:727:3 | *p | Expected 'Node.getType()' to be int, but it was int * |
24-
| test.cpp:808:5:808:21 | ** ... | Expected 'Node.getType()' to be int, but it was int * |
25-
| test.cpp:832:5:832:17 | *global_direct | Expected 'Node.getType()' to be int *, but it was int ** |
2615
| test.cpp:848:23:848:25 | (reference dereference) | Expected 'Node.getType()' to be int, but it was int * |
2716
| test.cpp:854:10:854:36 | * ... | Expected 'Node.getType()' to be const int, but it was int |
2817
| test.cpp:867:10:867:30 | * ... | Expected 'Node.getType()' to be const int, but it was int |
29-
| test.cpp:931:5:931:18 | *global_pointer | Expected 'Node.getType()' to be int, but it was int * |
30-
| test.cpp:988:5:988:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
31-
| test.cpp:1001:5:1001:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
32-
| test.cpp:1015:5:1015:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
33-
| test.cpp:1029:5:1029:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
3418
failures

0 commit comments

Comments
 (0)