Skip to content

Commit 3e78be2

Browse files
author
Andrew Ruef
authored
Infer and insert bounds safe interfaces (checkedc#492)
Insert bounds safe interfaces on function declarations, where appropriate.
1 parent f50666e commit 3e78be2

File tree

8 files changed

+583
-248
lines changed

8 files changed

+583
-248
lines changed

test/CheckedCRewriter/allocator.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ void dosomething(void) {
2020
void foo(void) {
2121
int *a = (int *) malloc(sizeof(int));
2222
*a = 0;
23-
free(a);
23+
free((void *)a);
2424
return;
2525
}
2626
//CHECK: void foo(void) {
27-
//CHECK-NEXT: _Ptr<int> a = (int *) malloc(sizeof(int));
27+
//CHECK-NEXT: int *a = (int *) malloc(sizeof(int));
2828
//CHECK-NEXT: *a = 0;
29-
//CHECK-NEXT: free((void *)a);
3029

3130
typedef struct _listelt {
3231
struct _listelt *next;

test/CheckedCRewriter/boundary_tests.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ void do_something(int *a, int b) {
1010
//CHECK: void do_something(_Ptr<int> a, int b) {
1111

1212
void mut(int *a, int b);
13+
//CHECK: void mut(int *a : itype(_Ptr<int> ) , int b);
1314

1415
void mut(int *a, int b) {
1516
*a += b;
1617
}
18+
//CHECK: void mut(int *a : itype(_Ptr<int> ) , int b) {
1719

18-
/*void bad_ctx(void) {
20+
void bad_ctx(void) {
1921
mut((int*)0x8001000, 1);
2022
}
2123

2224
void good_ctx(void) {
2325
int u = 0;
2426
mut(&u, 1);
25-
}*/
27+
}

test/CheckedCRewriter/bounds_interface.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern void bar(int *q : itype(_Ptr<int>));
1010
//CHECK: extern void bar(int* q : itype(_Ptr<int>));
1111

1212
extern void bar2(int *q : itype(_Ptr<int>), int *z : itype(_Ptr<int>));
13-
//CHEcK: extern void bar2(int* q : itype(_Ptr<int>), int* z : itype(_Ptr<int>));
13+
//CHECK: extern void bar2(int* q : itype(_Ptr<int>), int* z : itype(_Ptr<int>));
1414

1515
extern int *baz(void) : itype(_Ptr<int>);
1616
//CHECK: extern int* baz(void) : itype(_Ptr<int>);

0 commit comments

Comments
 (0)