Skip to content

Commit 7195089

Browse files
CheckedRegionFinder: "void" does not contain an unchecked pointer. (#426)
1 parent 5300cf8 commit 7195089

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

clang/lib/3C/CheckedRegions.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,6 @@ bool CheckedRegionFinder::containsUncheckedPtrAcc(QualType Qt,
379379
if (Ct->isVoidPointerType()) {
380380
return true;
381381
}
382-
if (Ct->isVoidType()) {
383-
return true;
384-
}
385382
if (Ct->isPointerType()) {
386383
return containsUncheckedPtrAcc(Ct->getPointeeType(), Seen);
387384
}

clang/test/3C/base_subdir/canwrite_constraints.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
int *bar(int *q) {
2929
// CHECK_LOWER: int *bar(int *q : itype(_Ptr<int>)) : itype(_Ptr<int>) {
30-
// CHECK_HIGHER: _Ptr<int> bar(_Ptr<int> q) {
30+
// CHECK_HIGHER: _Ptr<int> bar(_Ptr<int> q) _Checked {
3131
foo(q);
3232
return foo_var;
3333
}

clang/test/3C/graphs.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,41 +99,63 @@ int pop(struct Stack*);
9999
int main()
100100

101101
{
102+
//CHECK_NOALL: {
103+
//CHECK_ALL: _Checked {
102104

103105
int vertices,edges,i,src,dst;
104106

105107
printf("Enter the number of vertices\n");
108+
//CHECK_NOALL: printf("Enter the number of vertices\n");
109+
//CHECK_ALL: _Unchecked { printf("Enter the number of vertices\n"); };
106110

107111
scanf("%d",&vertices);
112+
//CHECK_NOALL: scanf("%d",&vertices);
113+
//CHECK_ALL: _Unchecked { scanf("%d",&vertices); };
108114

109115
struct Graph* graph = createGraph(vertices);
110116
//CHECK: _Ptr<struct Graph> graph = createGraph(vertices);
111117

112118
printf("Enter the number of edges\n");
119+
//CHECK_NOALL: printf("Enter the number of edges\n");
120+
//CHECK_ALL: _Unchecked { printf("Enter the number of edges\n"); };
113121

114122
scanf("%d",&edges);
123+
//CHECK_NOALL: scanf("%d",&edges);
124+
//CHECK_ALL: _Unchecked { scanf("%d",&edges); };
115125

116126
for(i=0; i<edges; i++)
117127

118128
{
119129

120130
printf("Edge %d \nEnter source: ",i+1);
131+
//CHECK_NOALL: printf("Edge %d \nEnter source: ",i+1);
132+
//CHECK_ALL: _Unchecked { printf("Edge %d \nEnter source: ",i+1); };
121133

122134
scanf("%d",&src);
135+
//CHECK_NOALL: scanf("%d",&src);
136+
//CHECK_ALL: _Unchecked { scanf("%d",&src); };
123137

124138
printf("Enter destination: ");
139+
//CHECK_NOALL: printf("Enter destination: ");
140+
//CHECK_ALL: _Unchecked { printf("Enter destination: "); };
125141

126142
scanf("%d",&dst);
143+
//CHECK_NOALL: scanf("%d",&dst);
144+
//CHECK_ALL: _Unchecked { scanf("%d",&dst); };
127145

128146
addEdge(graph, src, dst);
129147

130148
}
131149

132150
printf("One topological sort order is:\n");
151+
//CHECK_NOALL: printf("One topological sort order is:\n");
152+
//CHECK_ALL: _Unchecked { printf("One topological sort order is:\n"); };
133153

134154
topologicalSort(graph);
135155

136156
printf("\n");
157+
//CHECK_NOALL: printf("\n");
158+
//CHECK_ALL: _Unchecked { printf("\n"); };
137159

138160

139161

@@ -151,10 +173,14 @@ int main()
151173
addEdge(graph2, 2, 3);
152174

153175
printf("One topological sort is:\n");
176+
//CHECK_NOALL: printf("One topological sort is:\n");
177+
//CHECK_ALL: _Unchecked { printf("One topological sort is:\n"); };
154178

155179
topologicalSort(graph2);
156180

157181
printf("\n");
182+
//CHECK_NOALL: printf("\n");
183+
//CHECK_ALL: _Unchecked { printf("\n"); };
158184

159185
return 0;
160186

@@ -185,8 +211,6 @@ void topologicalSortHelper(int vertex, struct Graph* graph, struct Stack* stack)
185211
int connectedVertex = temp->vertex;
186212

187213
if(graph->visited[connectedVertex] == 0) {
188-
//CHECK_NOALL: if(graph->visited[connectedVertex] == 0) {
189-
//CHECK_ALL: if(graph->visited[connectedVertex] == 0) _Unchecked {
190214

191215
topologicalSortHelper(connectedVertex, graph, stack);
192216

@@ -227,8 +251,6 @@ void topologicalSort(struct Graph* graph)
227251
if(graph->visited[i]==0)
228252

229253
{
230-
//CHECK_NOALL: {
231-
//CHECK_ALL: _Unchecked {
232254

233255
topologicalSortHelper(i,graph,stack);
234256

clang/test/3C/subtyp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void take(int *p : itype(_Nt_array_ptr<int>));
99
//CHECK: void take(int *p : itype(_Nt_array_ptr<int>));
1010
int *foo(int *x) {
1111
//CHECK_NOALL: int *foo(int *x : itype(_Ptr<int>)) : itype(_Ptr<int>) {
12-
//CHECK_ALL: _Nt_array_ptr<int> foo(_Nt_array_ptr<int> x) {
12+
//CHECK_ALL: _Nt_array_ptr<int> foo(_Nt_array_ptr<int> x) _Checked {
1313
take(x);
1414
return x;
1515
}

clang/test/3C/supernested.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ do_sanity_checks(void)
4141
{
4242
//CHECK: _Checked {
4343
{
44-
//CHECK: _Unchecked {
44+
//CHECK: {
4545
struct vsf_sysutil_statbuf* p_statbuf = 0;
4646
//CHECK: _Ptr<struct vsf_sysutil_statbuf> p_statbuf = 0;
4747
vsf_sysutil_fstat(VSFTP_COMMAND_FD, &p_statbuf);
@@ -56,28 +56,28 @@ do_sanity_checks(void)
5656
{
5757
if (tunable_local_enable)
5858
{
59-
//CHECK: _Unchecked {
59+
//CHECK: {
6060
die("vsftpd: security: 'one_process_model' is anonymous only");
6161
}
6262
if (!vsf_sysdep_has_capabilities_as_non_root())
6363
{
64-
//CHECK: _Unchecked {
64+
//CHECK: {
6565
die("vsftpd: security: 'one_process_model' needs a better OS");
6666
}
6767
}
6868
if (!tunable_local_enable && !tunable_anonymous_enable)
6969
{
70-
//CHECK: _Unchecked {
70+
//CHECK: {
7171
die("vsftpd: both local and anonymous access disabled!");
7272
}
7373
if (!tunable_ftp_enable && !tunable_http_enable)
7474
{
75-
//CHECK: _Unchecked {
75+
//CHECK: {
7676
die("vsftpd: both FTP and HTTP disabled!");
7777
}
7878
if (tunable_http_enable && !tunable_one_process_model)
7979
{
80-
//CHECK: _Unchecked {
80+
//CHECK: {
8181
die("vsftpd: HTTP needs 'one_process_model' for now");
8282
}
8383
}

0 commit comments

Comments
 (0)