Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hard-coded checked declarations from 3C regression tests. #576

Merged
merged 11 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions clang/test/3C/3d-allocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#include <stdio.h>
#include <stdlib.h>

extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);

int ***malloc3d(int y, int x, int z) {
//CHECK_NOALL: int ***malloc3d(int y, int x, int z) : itype(_Ptr<int **>) {
//CHECK_ALL: _Array_ptr<_Array_ptr<_Array_ptr<int>>> malloc3d(int y, int x, int z) : count(y) {
Expand Down
3 changes: 1 addition & 2 deletions clang/test/3C/add_bounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ void biz(){
//CHECK_ALL: _Array_ptr<int> b : count(10) = a;
}

#include<stddef.h>
_Itype_for_any(T) void *malloc(size_t size) : itype(_Array_ptr<T>) byte_count(size);
#include <stdlib.h>
_Array_ptr<int> faz(void) {
//CHECK_ALL: _Array_ptr<int> faz(void) : count(100) {
int *c = malloc(100 * sizeof(int));
Expand Down
10 changes: 1 addition & 9 deletions clang/test/3C/alloc_type_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
// RUN: 3c -base-dir=%S -output-dir=%t.checked -alltypes %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/alloc_type_param.c -- | diff %t.checked/alloc_type_param.c -

#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
#include <stdlib.h>

/* Check basic behavior with the three alloc functions */
void foo() {
Expand Down
5 changes: 1 addition & 4 deletions clang/test/3C/allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
// RUN: 3c -base-dir=%t.checked %t.checked/allocator.c -- | diff %t.checked/allocator.c -
// expected-no-diagnostics
//
#include <stddef.h>
_Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
_Itype_for_any(T) void free(void *pointer : itype(_Array_ptr<T>) byte_count(0));
#include <stdlib.h>

void dosomething(void) {
int a = 0;
Expand Down
13 changes: 1 addition & 12 deletions clang/test/3C/arrboundsbasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,7 @@
Basic array bounds tests (without any data-flow analysis).
*/

#include <stddef.h>

extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
#include <stdlib.h>

struct bar {
char *a;
Expand Down
5 changes: 1 addition & 4 deletions clang/test/3C/arrboundsbasicinfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
Basic array bounds tests (without any data-flow analysis).
*/

#include <stddef.h>

extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
#include <stdlib.h>

struct bar {
char *a;
Expand Down
16 changes: 8 additions & 8 deletions clang/test/3C/arrboundsbyte.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
Array bounds (byte_bound) tests with data-flow analysis.
*/

#include <stddef.h>
_Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
int *memcpy(int *restrict dest
: itype(restrict _Array_ptr<int>) byte_count(n),
const int *restrict src
: itype(restrict _Array_ptr<const int>) byte_count(n), size_t n)
#include <stdlib.h>
// This test needs a custom version of memcpy where src and dest are `int *`.
int *memcpy_int(int *restrict dest
: itype(restrict _Array_ptr<int>) byte_count(n),
const int *restrict src
: itype(restrict _Array_ptr<const int>) byte_count(n), size_t n)
: itype(_Array_ptr<int>) byte_count(n);

struct foo {
int *y;
int l;
Expand All @@ -22,7 +22,7 @@ struct foo {
void bar(int *x, int c) {
struct foo f = {x, c};
int *q = malloc(sizeof(int) * c);
memcpy(q, f.y, c);
memcpy_int(q, f.y, c);
}
//CHECK: void bar(_Array_ptr<int> x : byte_count(c), int c) {
//CHECK: _Array_ptr<int> q : count(c) = malloc<int>(sizeof(int) * c);
4 changes: 1 addition & 3 deletions clang/test/3C/arrboundsheuristics.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

int *glob;
int lenplusone;
#include <stddef.h>
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
#include <stdlib.h>
//CHECK_ALL: _Array_ptr<int> glob = ((void *)0);
//CHECK_NOALL: int *glob;

Expand Down
4 changes: 1 addition & 3 deletions clang/test/3C/arrboundsinfer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
Basic array bounds tests (without any data-flow analysis).
*/

#include <stddef.h>
#include <stdlib.h>

extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern void ext_func(_Array_ptr<int> arr : count(len), unsigned len);

struct bar {
Expand Down
4 changes: 1 addition & 3 deletions clang/test/3C/arrctxsenbounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
/*
Context-sensitive array-bounds inference.
*/
typedef long size_t;
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
#include <stdlib.h>
struct foo {
int *x;
unsigned olol;
Expand Down
12 changes: 2 additions & 10 deletions clang/test/3C/arrtests_xfail.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,8 @@
Various array bounds tests.
*/

#include <stddef.h>
void *memset(void *dest
: byte_count(n), int c, size_t n)
: bounds(dest, (_Array_ptr<char>)dest + n);
_Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
_Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
#include <stdlib.h>
#include <string.h>

int *g; // array : count is 100; see the call to foo
void foo(void) {
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b10_allsafepointerstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b10_allsafepointerstruct.c -- | diff %t.checked/b10_allsafepointerstruct.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b11_calleestructnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b11_calleestructnp.c -- | diff %t.checked/b11_calleestructnp.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b12_callerstructnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b12_callerstructnp.c -- | diff %t.checked/b12_callerstructnp.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b13_calleestructp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b13_calleestructp.c -- | diff %t.checked/b13_calleestructp.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b14_callerstructp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b14_callerstructp.c -- | diff %t.checked/b14_callerstructp.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b15_calleepointerstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b15_calleepointerstruct.c -- | diff %t.checked/b15_calleepointerstruct.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b16_callerpointerstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b16_callerpointerstruct.c -- | diff %t.checked/b16_callerpointerstruct.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b17_bothstructnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b17_bothstructnp.c -- | diff %t.checked/b17_bothstructnp.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
17 changes: 3 additions & 14 deletions clang/test/3C/b_tests/b18_bothstructp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@
// RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s --
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/b18_bothstructp.c -- | diff %t.checked/b18_bothstructp.c -
#include <stddef.h>
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size)
: itype(_Array_ptr<T>) byte_count(nmemb * size);
extern _Itype_for_any(T) void free(void *pointer
: itype(_Array_ptr<T>) byte_count(0));
extern _Itype_for_any(T) void *malloc(size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern _Itype_for_any(T) void *realloc(void *pointer
: itype(_Array_ptr<T>) byte_count(1),
size_t size)
: itype(_Array_ptr<T>) byte_count(size);
extern int printf(const char *restrict format
: itype(restrict _Nt_array_ptr<const char>), ...);
extern _Unchecked char *strcpy(char *restrict dest, const char *restrict src
: itype(restrict _Nt_array_ptr<const char>));
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct np {
int x;
Expand Down
Loading