================
@@ -0,0 +1,23 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core  
-analyzer-checker=unix.cstring  -analyzer-checker=alpha.unix.cstring  
-analyzer-checker=debug.ExprInspection -verify %s 
+
+
+typedef __SIZE_TYPE__ size_t;
+
+void *memset_explicit(void *s, int c, size_t n);
+void clang_analyzer_eval(int);
+
+void test_memset_explicit_null(void) {
+  char *p = 0;
+  memset_explicit(p, 0, 10); // expected-warning{{Null pointer passed as 1st 
argument to memory set function}}
+}
+ 
+void test_memset_explicit_oob(void) {
+  char buf[5];
+  memset_explicit(buf, 0, 10); // expected-warning{{Memory set function 
overflows the destination buffer}}
+}
+ 
+void test_memset_explicit_eval(void) {
+  char buf[5];
+  memset_explicit(buf, 0, 5);
+  clang_analyzer_eval(buf[0] == 0); // expected-warning{{TRUE}}
+}
----------------
steakhal wrote:

Could you move these tests near existing exicit_member/explicit_bzero tests in 
`string.c`?

https://github.com/llvm/llvm-project/pull/219701
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to