diff options
Diffstat (limited to 'clang/test/Analysis')
| -rw-r--r-- | clang/test/Analysis/bstring.c | 13 | ||||
| -rw-r--r-- | clang/test/Analysis/null-deref-ps-region.c | 2 | ||||
| -rw-r--r-- | clang/test/Analysis/pr22954.c | 4 | ||||
| -rw-r--r-- | clang/test/Analysis/string.c | 10 |
4 files changed, 22 insertions, 7 deletions
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c index 0fb807dc55a..f472a3e0111 100644 --- a/clang/test/Analysis/bstring.c +++ b/clang/test/Analysis/bstring.c @@ -72,7 +72,10 @@ void memcpy2 () { char src[] = {1, 2, 3, 4}; char dst[1]; - memcpy(dst, src, 4); // expected-warning{{Memory copy function overflows destination buffer}} + memcpy(dst, src, 4); // expected-warning{{Memory copy function overflows destination buffer}} +#ifndef VARIANT + // expected-warning@-2{{memcpy' will always overflow; destination buffer has size 1, but size argument is 4}} +#endif } void memcpy3 () { @@ -94,6 +97,9 @@ void memcpy5() { char dst[3]; memcpy(dst+2, src+2, 2); // expected-warning{{Memory copy function overflows destination buffer}} +#ifndef VARIANT + // expected-warning@-2{{memcpy' will always overflow; destination buffer has size 1, but size argument is 2}} +#endif } void memcpy6() { @@ -351,7 +357,10 @@ void memmove2 () { char src[] = {1, 2, 3, 4}; char dst[1]; - memmove(dst, src, 4); // expected-warning{{overflow}} + memmove(dst, src, 4); // expected-warning{{Memory copy function overflows destination buffer}} +#ifndef VARIANT + // expected-warning@-2{{memmove' will always overflow; destination buffer has size 1, but size argument is 4}} +#endif } //===----------------------------------------------------------------------=== diff --git a/clang/test/Analysis/null-deref-ps-region.c b/clang/test/Analysis/null-deref-ps-region.c index f5e6956ff72..2bc338cd3f2 100644 --- a/clang/test/Analysis/null-deref-ps-region.c +++ b/clang/test/Analysis/null-deref-ps-region.c @@ -51,7 +51,7 @@ void testHeapSymbol() { void testStackArrayOutOfBound() { char buf[1]; - memset(buf, 0, 1024); // expected-warning {{Memory set function accesses out-of-bound array element}} + memset(buf, 0, 1024); // expected-warning {{Memory set function accesses out-of-bound array element}} expected-warning {{'memset' will always overflow; destination buffer has size 1, but size argument is 1024}} } void testHeapSymbolOutOfBound() { diff --git a/clang/test/Analysis/pr22954.c b/clang/test/Analysis/pr22954.c index 6d5b04417a1..e88acdc29d3 100644 --- a/clang/test/Analysis/pr22954.c +++ b/clang/test/Analysis/pr22954.c @@ -303,7 +303,7 @@ int f18() { i18.j = 11; i18.s2 = strdup("hello"); char input[100] = {3}; - memcpy(i18.s1, input, 100); + memcpy(i18.s1, input, 100); // expected-warning {{'memcpy' will always overflow; destination buffer has size 24, but size argument is 100}} clang_analyzer_eval(i18.s1[0] == 1); // expected-warning{{UNKNOWN}}\ expected-warning{{Potential leak of memory pointed to by 'i18.s2'}} clang_analyzer_eval(i18.s1[1] == 2); // expected-warning{{UNKNOWN}} @@ -534,7 +534,7 @@ int f262() { struct aa a262 = {{1, 2, 3, 4}, 0}; a262.s2 = strdup("hello"); char input[] = {'a', 'b', 'c', 'd'}; - memcpy(a262.s1, input, -1); + memcpy(a262.s1, input, -1); // expected-warning{{'memcpy' will always overflow; destination buffer has size 16, but size argument is 18446744073709551615}} clang_analyzer_eval(a262.s1[0] == 1); // expected-warning{{UNKNOWN}}\ expected-warning{{Potential leak of memory pointed to by 'a262.s2'}} clang_analyzer_eval(a262.s1[1] == 1); // expected-warning{{UNKNOWN}} diff --git a/clang/test/Analysis/string.c b/clang/test/Analysis/string.c index 024e224a2b5..4cb2e6c7875 100644 --- a/clang/test/Analysis/string.c +++ b/clang/test/Analysis/string.c @@ -517,12 +517,18 @@ void strncpy_overflow(char *y) { char x[4]; if (strlen(y) == 4) strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}} +#ifndef VARIANT + // expected-warning@-2{{size argument is too large; destination buffer has size 4, but size argument is 5}} +#endif } void strncpy_no_overflow(char *y) { char x[4]; if (strlen(y) == 3) strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}} +#ifndef VARIANT + // expected-warning@-2{{size argument is too large; destination buffer has size 4, but size argument is 5}} +#endif } void strncpy_no_overflow2(char *y, int n) { @@ -1247,7 +1253,7 @@ void memset6_char_array_nonnull() { void memset8_char_array_nonnull() { char str[5] = "abcd"; clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TRUE}} - memset(str, '0', 10); + memset(str, '0', 10); // expected-warning{{'memset' will always overflow; destination buffer has size 5, but size argument is 10}} clang_analyzer_eval(str[0] != '0'); // expected-warning{{UNKNOWN}} clang_analyzer_eval(strlen(str) >= 10); // expected-warning{{TRUE}} clang_analyzer_eval(strlen(str) < 10); // expected-warning{{FALSE}} @@ -1284,7 +1290,7 @@ void memset12_struct_field() { struct POD_memset pod; pod.num = 1; pod.c = '1'; - memset(&pod.c, 0, sizeof(struct POD_memset)); + memset(&pod.c, 0, sizeof(struct POD_memset)); // expected-warning {{'memset' will always overflow; destination buffer has size 4, but size argument is 8}} clang_analyzer_eval(pod.num == 0); // expected-warning{{UNKNOWN}} clang_analyzer_eval(pod.c == 0); // expected-warning{{UNKNOWN}} } |

