#ifdef USE_BUILTINS
# define BUILTIN(f) __builtin_ ## f
#else
# define BUILTIN(f) f
#endif
typedef typeof(sizeof(int)) size_t;
void clang_analyzer_eval(int);
#ifdef VARIANT
#define __memcpy_chk BUILTIN(__memcpy_chk)
void *__memcpy_chk(void *restrict s1, const void *restrict s2, size_t n,
size_t destlen);
#define memcpy(a,b,c) __memcpy_chk(a,b,c,(size_t)-1)
#else
#define memcpy BUILTIN(memcpy)
void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
#endif
void memcpy0 (void) {
char src[] = {1, 2, 3, 4};
char dst[4] = {0};
memcpy(dst, src, 4);
clang_analyzer_eval(memcpy(dst, src, 4) == dst);
clang_analyzer_eval(dst[0] != 0); }
void memcpy1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
memcpy(dst, src, 5); }
void memcpy2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];
memcpy(dst, src, 4); #ifndef VARIANT
#endif
}
void memcpy3 (void) {
char src[] = {1, 2, 3, 4};
char dst[3];
memcpy(dst+1, src+2, 2); }
void memcpy4 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
memcpy(dst+2, src+2, 3); }
void memcpy5(void) {
char src[] = {1, 2, 3, 4};
char dst[3];
memcpy(dst + 2, src + 2, 2); #ifndef VARIANT
#endif
}
void memcpy6(void) {
int a[4] = {0};
memcpy(a, a, 8); }
void memcpy7(void) {
int a[4] = {0};
memcpy(a+2, a+1, 8); }
void memcpy8(void) {
int a[4] = {0};
memcpy(a+1, a+2, 8); }
void memcpy9(void) {
int a[4] = {0};
memcpy(a+2, a+1, 4); memcpy(a+1, a+2, 4); }
void memcpy10(void) {
char a[4] = {0};
memcpy(0, a, 4); }
void memcpy11(void) {
char a[4] = {0};
memcpy(a, 0, 4); }
void memcpy12(void) {
char a[4] = {0};
memcpy(0, a, 0); }
void memcpy13(void) {
char a[4] = {0};
memcpy(a, 0, 0); }
void memcpy_unknown_size (size_t n) {
char a[4], b[4] = {1};
clang_analyzer_eval(memcpy(a, b, n) == a); }
void memcpy_unknown_size_warn (size_t n) {
char a[4];
void *result = memcpy(a, 0, n); clang_analyzer_eval(result == a); }
#ifdef VARIANT
#define __mempcpy_chk BUILTIN(__mempcpy_chk)
void *__mempcpy_chk(void *restrict s1, const void *restrict s2, size_t n,
size_t destlen);
#define mempcpy(a,b,c) __mempcpy_chk(a,b,c,(size_t)-1)
#else
#define mempcpy BUILTIN(mempcpy)
void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
#endif
void mempcpy0 (void) {
char src[] = {1, 2, 3, 4};
char dst[5] = {0};
mempcpy(dst, src, 4);
clang_analyzer_eval(mempcpy(dst, src, 4) == &dst[4]);
clang_analyzer_eval(dst[0] != 0); }
void mempcpy1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
mempcpy(dst, src, 5); }
void mempcpy2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];
mempcpy(dst, src, 4); #ifndef VARIANT
#endif
}
void mempcpy3 (void) {
char src[] = {1, 2, 3, 4};
char dst[3];
mempcpy(dst+1, src+2, 2); }
void mempcpy4 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
mempcpy(dst+2, src+2, 3); }
void mempcpy5(void) {
char src[] = {1, 2, 3, 4};
char dst[3];
mempcpy(dst + 2, src + 2, 2); #ifndef VARIANT
#endif
}
void mempcpy6(void) {
int a[4] = {0};
mempcpy(a, a, 8); }
void mempcpy7(void) {
int a[4] = {0};
mempcpy(a+2, a+1, 8); }
void mempcpy8(void) {
int a[4] = {0};
mempcpy(a+1, a+2, 8); }
void mempcpy9(void) {
int a[4] = {0};
mempcpy(a+2, a+1, 4); mempcpy(a+1, a+2, 4); }
void mempcpy10(void) {
char a[4] = {0};
mempcpy(0, a, 4); }
void mempcpy11(void) {
char a[4] = {0};
mempcpy(a, 0, 4); }
void mempcpy12(void) {
char a[4] = {0};
mempcpy(0, a, 0); }
void mempcpy13(void) {
char a[4] = {0};
mempcpy(a, 0, 0); }
void mempcpy14(void) {
int src[] = {1, 2, 3, 4};
int dst[5] = {0};
int *p;
p = mempcpy(dst, src, 4 * sizeof(int));
clang_analyzer_eval(p == &dst[4]); }
struct st {
int i;
int j;
};
void mempcpy15(void) {
struct st s1 = {0};
struct st s2;
struct st *p1;
struct st *p2;
p1 = (&s2) + 1;
p2 = mempcpy(&s2, &s1, sizeof(struct st));
clang_analyzer_eval(p1 == p2); }
void mempcpy16(void) {
struct st s1[10] = {{0}};
struct st s2[10];
struct st *p1;
struct st *p2;
p1 = (&s2[0]) + 5;
p2 = mempcpy(&s2[0], &s1[0], 5 * sizeof(struct st));
clang_analyzer_eval(p1 == p2); }
void mempcpy_unknown_size_warn (size_t n) {
char a[4];
void *result = mempcpy(a, 0, n); clang_analyzer_eval(result == a); }
void mempcpy_unknownable_size (char *src, float n) {
char a[4];
mempcpy(a, src, (size_t)n);
}
#ifdef VARIANT
#define __memmove_chk BUILTIN(__memmove_chk)
void *__memmove_chk(void *s1, const void *s2, size_t n, size_t destlen);
#define memmove(a,b,c) __memmove_chk(a,b,c,(size_t)-1)
#else
#define memmove BUILTIN(memmove)
void *memmove(void *s1, const void *s2, size_t n);
#endif
void memmove0 (void) {
char src[] = {1, 2, 3, 4};
char dst[4] = {0};
memmove(dst, src, 4);
clang_analyzer_eval(memmove(dst, src, 4) == dst);
clang_analyzer_eval(dst[0] != 0); }
void memmove1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
memmove(dst, src, 5); }
void memmove2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];
memmove(dst, src, 4); #ifndef VARIANT
#endif
}
#ifdef VARIANT
#define bcmp BUILTIN(bcmp)
int bcmp(const void *s1, const void *s2, size_t n);
#define memcmp bcmp
#else
#define memcmp BUILTIN(memcmp)
int memcmp(const void *s1, const void *s2, size_t n);
#endif
void memcmp0 (void) {
char a[] = {1, 2, 3, 4};
char b[4] = { 0 };
memcmp(a, b, 4); }
void memcmp1 (void) {
char a[] = {1, 2, 3, 4};
char b[10] = { 0 };
memcmp(a, b, 5); }
void memcmp2 (void) {
char a[] = {1, 2, 3, 4};
char b[1] = { 0 };
memcmp(a, b, 4); }
void memcmp3 (void) {
char a[] = {1, 2, 3, 4};
clang_analyzer_eval(memcmp(a, a, 4) == 0); }
void memcmp4 (char *input) {
char a[] = {1, 2, 3, 4};
clang_analyzer_eval(memcmp(a, input, 4) == 0); }
void memcmp5 (char *input) {
char a[] = {1, 2, 3, 4};
clang_analyzer_eval(memcmp(a, 0, 0) == 0); clang_analyzer_eval(memcmp(0, a, 0) == 0); clang_analyzer_eval(memcmp(a, input, 0) == 0); }
void memcmp6 (char *a, char *b, size_t n) {
int result = memcmp(a, b, n);
if (result != 0)
clang_analyzer_eval(n != 0);
}
int memcmp7 (char *a, size_t x, size_t y, size_t n) {
return memcmp(a, &a[x*y], n) +
memcmp(&a[x*y], a, n);
}
int memcmp8(char *a, size_t n) {
char *b = 0;
return memcmp(a, b, n); }
#define bcopy BUILTIN(bcopy)
void bcopy( void *s1, void *s2, size_t n);
void bcopy0 (void) {
char src[] = {1, 2, 3, 4};
char dst[4] = {0};
bcopy(src, dst, 4);
clang_analyzer_eval(dst[0] != 0); }
void bcopy1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
bcopy(src, dst, 5); }
void bcopy2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];
bcopy(src, dst, 4); }
void *malloc(size_t);
void free(void *);
char radar_11125445_memcopythenlogfirstbyte(const char *input, size_t length) {
char *bytes = malloc(sizeof(char) * (length + 1));
memcpy(bytes, input, length);
char x = bytes[0]; free(bytes);
return x;
}
struct S {
char f;
};
void nocrash_on_locint_offset(void *addr, void* from, struct S s) {
size_t iAdd = (size_t) addr;
memcpy(((void *) &(s.f)), from, iAdd);
}