Skip to content

Commit 78ce857

Browse files
committed
C++: Add consistency test and accept consistency failures.
1 parent e0a5efe commit 78ce857

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,122 @@
11
astTypeBugs
22
irTypeBugs
3+
incorrectBaseType
4+
| BarrierGuard.cpp:75:15:75:17 | *buf | Expected 'Node.getType()' to be const int, but it was int |
5+
| clang.cpp:18:8:18:19 | *sourceArray1 | Expected 'Node.getType()' to be const int, but it was int |
6+
| clang.cpp:22:8:22:20 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
7+
| clang.cpp:23:17:23:29 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
8+
| clang.cpp:52:8:52:17 | *stackArray | Expected 'Node.getType()' to be const int, but it was int |
9+
| dispatch.cpp:60:3:60:14 | *globalBottom | Expected 'Node.getType()' to be Top, but it was Top * |
10+
| dispatch.cpp:61:3:61:14 | *globalMiddle | Expected 'Node.getType()' to be Top, but it was Top * |
11+
| example.c:19:6:19:6 | *b | Expected 'Node.getType()' to be MyBool, but it was (unnamed class/struct/union) |
12+
| example.c:26:18:26:24 | *& ... | Expected 'Node.getType()' to be MyCoords, but it was (unnamed class/struct/union) |
13+
| file://:0:0:0:0 | *this | Expected 'Node.getType()' to be const lambda [] type at line 13, col. 11, but it was decltype([...](...){...}) |
14+
| flowOut.cpp:50:14:50:15 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
15+
| flowOut.cpp:67:21:67:21 | *p | Expected 'Node.getType()' to be const char, but it was char |
16+
| flowOut.cpp:84:9:84:10 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
17+
| flowOut.cpp:101:13:101:14 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
18+
| flowOut.cpp:111:34:111:34 | *p | Expected 'Node.getType()' to be const void, but it was void |
19+
| flowOut.cpp:139:30:139:30 | *p | Expected 'Node.getType()' to be const char *, but it was char * |
20+
| flowOut.cpp:154:30:154:30 | *p | Expected 'Node.getType()' to be const char *, but it was char * |
21+
| flowOut.cpp:168:3:168:10 | ** ... | Expected 'Node.getType()' to be char, but it was char * |
22+
| flowOut.cpp:176:30:176:30 | *p | Expected 'Node.getType()' to be const char *, but it was char * |
23+
| flowOut.cpp:193:30:193:30 | *p | Expected 'Node.getType()' to be const char *, but it was char * |
24+
| lambdas.cpp:14:3:14:6 | *this | Expected 'Node.getType()' to be const lambda [] type at line 13, col. 11, but it was decltype([...](...){...}) |
25+
| lambdas.cpp:15:3:15:6 | *this | Expected 'Node.getType()' to be const lambda [] type at line 13, col. 11, but it was decltype([...](...){...}) |
26+
| lambdas.cpp:21:3:21:6 | *this | Expected 'Node.getType()' to be const lambda [] type at line 20, col. 11, but it was decltype([...](...){...}) |
27+
| lambdas.cpp:22:3:22:6 | *this | Expected 'Node.getType()' to be const lambda [] type at line 20, col. 11, but it was decltype([...](...){...}) |
28+
| lambdas.cpp:23:3:23:14 | *this | Expected 'Node.getType()' to be const lambda [] type at line 20, col. 11, but it was decltype([...](...){...}) |
29+
| lambdas.cpp:29:3:29:6 | *this | Expected 'Node.getType()' to be const lambda [] type at line 28, col. 11, but it was decltype([...](...){...}) |
30+
| lambdas.cpp:30:3:30:6 | *this | Expected 'Node.getType()' to be const lambda [] type at line 28, col. 11, but it was decltype([...](...){...}) |
31+
| self_parameter_flow.cpp:8:8:8:9 | *& ... | Expected 'Node.getType()' to be unsigned char, but it was unsigned char * |
32+
| test.cpp:67:28:67:37 | (reference dereference) | Expected 'Node.getType()' to be const int, but it was int * |
33+
| test.cpp:67:28:67:37 | *call to move | Expected 'Node.getType()' to be const int, but it was int |
34+
| test.cpp:70:19:70:33 | *x3 | Expected 'Node.getType()' to be const int, but it was int |
35+
| test.cpp:71:8:71:9 | *x4 | Expected 'Node.getType()' to be const int, but it was int |
36+
| test.cpp:384:16:384:23 | *& ... | Expected 'Node.getType()' to be const void, but it was void |
37+
| test.cpp:391:16:391:23 | *& ... | Expected 'Node.getType()' to be const void, but it was void |
38+
| test.cpp:400:16:400:22 | *& ... | Expected 'Node.getType()' to be const void, but it was void |
39+
| test.cpp:407:16:407:22 | *& ... | Expected 'Node.getType()' to be const void, but it was void |
40+
| test.cpp:526:3:526:4 | ** ... | Expected 'Node.getType()' to be const int *, but it was int * |
41+
| test.cpp:526:3:526:4 | ** ... | Expected 'Node.getType()' to be const int, but it was int * |
42+
| test.cpp:526:8:526:9 | *& ... | Expected 'Node.getType()' to be const int, but it was int |
43+
| test.cpp:531:39:531:40 | *& ... | Expected 'Node.getType()' to be const int *, but it was int * |
44+
| test.cpp:531:39:531:40 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
45+
| test.cpp:562:5:562:13 | *globalInt | Expected 'Node.getType()' to be int, but it was int * |
46+
| test.cpp:576:5:576:13 | *globalInt | Expected 'Node.getType()' to be int, but it was int * |
47+
| test.cpp:584:3:584:3 | *x | Expected 'Node.getType()' to be int, but it was int * |
48+
| test.cpp:596:3:596:7 | *access to array | Expected 'Node.getType()' to be int, but it was int * |
49+
| test.cpp:615:13:615:21 | *& ... | Expected 'Node.getType()' to be int, but it was void |
50+
| test.cpp:704:22:704:25 | *& ... | Expected 'Node.getType()' to be int, but it was int * |
51+
| test.cpp:715:24:715:25 | *& ... | Expected 'Node.getType()' to be unsigned char, but it was unsigned char * |
52+
| test.cpp:727:3:727:3 | *p | Expected 'Node.getType()' to be int, but it was int * |
53+
| test.cpp:797:31:797:39 | *content | Expected 'Node.getType()' to be const int, but it was int |
54+
| test.cpp:808:5:808:21 | ** ... | Expected 'Node.getType()' to be int, but it was int * |
55+
| test.cpp:832:5:832:17 | *global_direct | Expected 'Node.getType()' to be int *, but it was int ** |
56+
| test.cpp:848:23:848:25 | (reference dereference) | Expected 'Node.getType()' to be int, but it was int * |
57+
| test.cpp:854:10:854:36 | * ... | Expected 'Node.getType()' to be const int, but it was int |
58+
| test.cpp:860:54:860:59 | *call to source | Expected 'Node.getType()' to be const int, but it was int |
59+
| test.cpp:861:10:861:37 | *static_local_pointer_dynamic | Expected 'Node.getType()' to be const int, but it was int |
60+
| test.cpp:867:10:867:30 | * ... | Expected 'Node.getType()' to be const int, but it was int |
61+
| test.cpp:872:46:872:51 | *call to source | Expected 'Node.getType()' to be const int, but it was int |
62+
| test.cpp:875:10:875:31 | *global_pointer_dynamic | Expected 'Node.getType()' to be const int, but it was int |
63+
| test.cpp:882:10:882:34 | *static_local_array_static | Expected 'Node.getType()' to be const char, but it was char |
64+
| test.cpp:883:10:883:45 | *static_local_array_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
65+
| test.cpp:884:19:884:54 | *static_local_array_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
66+
| test.cpp:885:10:885:45 | *static_local_array_static_indirect_2 | Expected 'Node.getType()' to be const char, but it was char |
67+
| test.cpp:886:19:886:54 | *static_local_array_static_indirect_2 | Expected 'Node.getType()' to be const char, but it was char |
68+
| test.cpp:890:54:890:61 | *source | Expected 'Node.getType()' to be const char, but it was char |
69+
| test.cpp:891:65:891:84 | *indirect_source(1) | Expected 'Node.getType()' to be const char, but it was char |
70+
| test.cpp:892:65:892:84 | *indirect_source(2) | Expected 'Node.getType()' to be const char, but it was char |
71+
| test.cpp:893:10:893:36 | *static_local_pointer_static | Expected 'Node.getType()' to be const char, but it was char |
72+
| test.cpp:894:10:894:47 | *static_local_pointer_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
73+
| test.cpp:895:19:895:56 | *static_local_pointer_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
74+
| test.cpp:896:10:896:47 | *static_local_pointer_static_indirect_2 | Expected 'Node.getType()' to be const char, but it was char |
75+
| test.cpp:897:19:897:56 | *static_local_pointer_static_indirect_2 | Expected 'Node.getType()' to be const char, but it was char |
76+
| test.cpp:905:10:905:28 | *global_array_static | Expected 'Node.getType()' to be const char, but it was char |
77+
| test.cpp:907:10:907:39 | *global_array_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
78+
| test.cpp:909:19:909:37 | *global_array_static | Expected 'Node.getType()' to be const char, but it was char |
79+
| test.cpp:910:19:910:48 | *global_array_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
80+
| test.cpp:911:19:911:48 | *global_array_static_indirect_2 | Expected 'Node.getType()' to be const char, but it was char |
81+
| test.cpp:914:46:914:53 | *source | Expected 'Node.getType()' to be const char, but it was char |
82+
| test.cpp:915:57:915:76 | *indirect_source(1) | Expected 'Node.getType()' to be const char, but it was char |
83+
| test.cpp:916:57:916:76 | *indirect_source(2) | Expected 'Node.getType()' to be const char, but it was char |
84+
| test.cpp:919:10:919:30 | *global_pointer_static | Expected 'Node.getType()' to be const char, but it was char |
85+
| test.cpp:920:10:920:41 | *global_pointer_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
86+
| test.cpp:921:19:921:50 | *global_pointer_static_indirect_1 | Expected 'Node.getType()' to be const char, but it was char |
87+
| test.cpp:922:10:922:41 | *global_pointer_static_indirect_2 | Expected 'Node.getType()' to be const char, but it was char |
88+
| test.cpp:923:19:923:50 | *global_pointer_static_indirect_2 | Expected 'Node.getType()' to be const char, but it was char |
89+
| test.cpp:931:5:931:18 | *global_pointer | Expected 'Node.getType()' to be int, but it was int * |
90+
| test.cpp:952:32:952:35 | *data | Expected 'Node.getType()' to be const char, but it was char |
91+
| test.cpp:959:32:959:35 | *data | Expected 'Node.getType()' to be const char, but it was char |
92+
| test.cpp:967:33:967:38 | *domain | Expected 'Node.getType()' to be const char, but it was char |
93+
| test.cpp:967:41:967:44 | *data | Expected 'Node.getType()' to be const char, but it was char |
94+
| test.cpp:975:33:975:38 | *domain | Expected 'Node.getType()' to be const char, but it was char |
95+
| test.cpp:975:41:975:44 | *data | Expected 'Node.getType()' to be const char, but it was char |
96+
| test.cpp:984:33:984:36 | *data | Expected 'Node.getType()' to be const char, but it was char |
97+
| test.cpp:984:39:984:40 | *np | Expected 'Node.getType()' to be const char, but it was char |
98+
| test.cpp:988:5:988:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
99+
| test.cpp:988:27:988:28 | *np | Expected 'Node.getType()' to be const char, but it was char |
100+
| test.cpp:988:31:988:34 | *data | Expected 'Node.getType()' to be const char, but it was char |
101+
| test.cpp:997:33:997:36 | *data | Expected 'Node.getType()' to be const char, but it was char |
102+
| test.cpp:997:39:997:40 | *np | Expected 'Node.getType()' to be const char, but it was char |
103+
| test.cpp:1001:5:1001:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
104+
| test.cpp:1001:27:1001:28 | *np | Expected 'Node.getType()' to be const char, but it was char |
105+
| test.cpp:1001:31:1001:34 | *data | Expected 'Node.getType()' to be const char, but it was char |
106+
| test.cpp:1011:34:1011:39 | *domain | Expected 'Node.getType()' to be const char, but it was char |
107+
| test.cpp:1011:42:1011:45 | *data | Expected 'Node.getType()' to be const char, but it was char |
108+
| test.cpp:1011:48:1011:49 | *np | Expected 'Node.getType()' to be const char, but it was char |
109+
| test.cpp:1015:5:1015:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
110+
| test.cpp:1015:28:1015:33 | *domain | Expected 'Node.getType()' to be const char, but it was char |
111+
| test.cpp:1015:36:1015:37 | *np | Expected 'Node.getType()' to be const char, but it was char |
112+
| test.cpp:1015:40:1015:43 | *data | Expected 'Node.getType()' to be const char, but it was char |
113+
| test.cpp:1025:34:1025:39 | *domain | Expected 'Node.getType()' to be const char, but it was char |
114+
| test.cpp:1025:42:1025:45 | *data | Expected 'Node.getType()' to be const char, but it was char |
115+
| test.cpp:1025:48:1025:49 | *np | Expected 'Node.getType()' to be const char, but it was char |
116+
| test.cpp:1029:5:1029:14 | *translated | Expected 'Node.getType()' to be char, but it was char * |
117+
| test.cpp:1029:28:1029:33 | *domain | Expected 'Node.getType()' to be const char, but it was char |
118+
| test.cpp:1029:36:1029:37 | *np | Expected 'Node.getType()' to be const char, but it was char |
119+
| test.cpp:1029:40:1029:43 | *data | Expected 'Node.getType()' to be const char, but it was char |
120+
| test.cpp:1036:33:1036:38 | *domain | Expected 'Node.getType()' to be const char, but it was char |
121+
| test.cpp:1036:41:1036:47 | *0 | Expected 'Node.getType()' to be const char, but it was char |
3122
failures

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ module IrTest {
2525
n != 1
2626
)
2727
}
28+
29+
query predicate incorrectBaseType(Node n, string msg) {
30+
exists(PointerType pointerType, Type nodeType, Type baseType |
31+
not n.isGLValue() and
32+
pointerType = n.asIndirectExpr(1).getActualType() and
33+
baseType = pointerType.getBaseType() and
34+
nodeType = n.getType() and
35+
nodeType != baseType and
36+
msg = "Expected 'Node.getType()' to be " + baseType + ", but it was " + nodeType
37+
)
38+
}
2839
}
2940

3041
import IrTest

0 commit comments

Comments
 (0)