Add 'restrict' support to the C++ test cases.

This commit is contained in:
Ziemowit Laski
2019-03-14 12:12:45 -07:00
parent 586aa0ae41
commit 2d5bdc85b0
4 changed files with 32 additions and 13 deletions

View File

@@ -1,8 +1,8 @@
| AllocaInLoop1.cpp:25:18:25:23 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1.cpp:16:2:33:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1.cpp:49:19:49:24 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1.cpp:39:2:58:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1.cpp:74:19:74:24 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1.cpp:65:3:82:3 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1ms.cpp:22:18:22:24 | call to _alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1ms.cpp:13:2:30:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1ms.cpp:46:19:46:26 | call to _malloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1ms.cpp:36:2:57:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1ms.cpp:73:19:73:25 | call to _alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1ms.cpp:64:3:81:3 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1.cpp:31:18:31:23 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1.cpp:22:2:39:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1.cpp:55:19:55:24 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1.cpp:45:2:64:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1.cpp:80:19:80:24 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1.cpp:71:3:88:3 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1ms.cpp:28:18:28:24 | call to _alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1ms.cpp:19:2:36:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1ms.cpp:52:19:52:26 | call to _malloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1ms.cpp:42:2:63:2 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop1ms.cpp:79:19:79:25 | call to _alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop1ms.cpp:70:3:87:3 | for(...;...;...) ... | for(...;...;...) ... |
| AllocaInLoop2.c:39:30:39:35 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop2.c:29:5:48:19 | do (...) ... | do (...) ... |
| AllocaInLoop3.cpp:38:23:38:28 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop3.cpp:36:2:42:19 | do (...) ... | do (...) ... |
| AllocaInLoop3.cpp:45:23:45:28 | call to __builtin_alloca | Stack allocation is inside a $@ and could lead to stack overflow. | AllocaInLoop3.cpp:43:2:49:19 | do (...) ... | do (...) ... |

View File

@@ -4,12 +4,18 @@ struct vtype {
};
extern int w1, w2;
#ifdef _MSC_VER
#define restrict __restrict
#else
#define restrict __restrict__
#endif
void *__builtin_alloca(int sz);
#define alloca __builtin_alloca
typedef unsigned long size_t;
int printf(const char *format, ...);
void *memcpy(void *dst, const void *src, size_t len);
int printf(const char *restrict format, ...);
void *memcpy(void *restrict dst, const void *restrict src, size_t len);
// case 1: alloca directly contained in an unbounded loop
void foo(const struct vtype* vec, int count) {

View File

@@ -5,8 +5,14 @@ struct vtype {
};
extern int w1, w2;
int printf(const char *format, ...);
void *memcpy(void *dst, const void *src, size_t len);
#ifdef _MSC_VER
#define restrict __restrict
#else
#define restrict __restrict__
#endif
int printf(const char *restrict format, ...);
void *memcpy(void *restrict dst, const void *restrict src, size_t len);
// case 1: _alloca directly contained in an unbounded loop
void foo(const struct vtype* vec, int count) {

View File

@@ -1,6 +1,13 @@
// semmle-extractor-options: --clang
int sprintf(char *buf, const char *format, ...);
char * strdup(const char *str1);
#ifdef _MSC_VER
#define restrict __restrict
#else
#define restrict __restrict__
#endif
int sprintf(char *restrict buf, const char *restrict format, ...);
char * strdup(const char *restrict str1);
void *__builtin_alloca(int sz);
#define alloca __builtin_alloca