[cfe-commits] r130758 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/CStringChecker.cpp test/Analysis/string.c

Lenny Maiorani lenny at colorado.edu
Tue May 3 09:34:26 PDT 2011


Author: lenny
Date: Tue May  3 11:34:26 2011
New Revision: 130758

URL: http://llvm.org/viewvc/llvm-project?rev=130758&view=rev
Log:
Removing strncpy() checking in CString checker for now. Some significant changes need to be made to properly support modeling of it since it potentially leaves strings non-null terminated.


Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
    cfe/trunk/test/Analysis/string.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=130758&r1=130757&r2=130758&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Tue May  3 11:34:26 2011
@@ -1241,7 +1241,7 @@
     .Cases("memcmp", "bcmp", &CStringChecker::evalMemcmp)
     .Cases("memmove", "__memmove_chk", &CStringChecker::evalMemmove)
     .Cases("strcpy", "__strcpy_chk", &CStringChecker::evalStrcpy)
-    .Cases("strncpy", "__strncpy_chk", &CStringChecker::evalStrncpy)
+    //.Cases("strncpy", "__strncpy_chk", &CStringChecker::evalStrncpy)
     .Cases("stpcpy", "__stpcpy_chk", &CStringChecker::evalStpcpy)
     .Cases("strcat", "__strcat_chk", &CStringChecker::evalStrcat)
     .Cases("strncat", "__strncat_chk", &CStringChecker::evalStrncat)

Modified: cfe/trunk/test/Analysis/string.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/string.c?rev=130758&r1=130757&r2=130758&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/string.c (original)
+++ cfe/trunk/test/Analysis/string.c Tue May  3 11:34:26 2011
@@ -328,74 +328,6 @@
 }
 
 //===----------------------------------------------------------------------===
-// strncpy()
-//===----------------------------------------------------------------------===
-
-#ifdef VARIANT
-
-#define __strncpy_chk BUILTIN(__strncpy_chk)
-char *__strncpy_chk(char *restrict s1, const char *restrict s2, size_t n, size_t destlen);
-
-#define strncpy(a,b,c) __strncpy_chk(a,b,c, (size_t)-1)
-
-#else /* VARIANT */
-
-#define strncpy BUILTIN(strncpy)
-char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
-
-#endif /* VARIANT */
-
-
-void strncpy_null_dst(char *x) {
-  strncpy(NULL, x, 1); // expected-warning{{Null pointer argument in call to byte string function}}
-}
-
-void strncpy_null_src(char *x) {
-  strncpy(x, NULL, 1); // expected-warning{{Null pointer argument in call to byte string function}}
-}
-
-void strncpy_fn(char *x) {
-  strncpy(x, (char*)&strncpy_fn, 1); // expected-warning{{Argument to byte string function is the address of the function 'strncpy_fn', which is not a null-terminated string}}
-}
-
-void strncpy_effects(char *x, char *y) {
-  char a = x[0];
-
-  if (strncpy(x, y, strlen(y)) != x)
-    (void)*(char*)0; // no-warning
-
-  if (strlen(x) != strlen(y))
-    (void)*(char*)0; // no-warning
-
-  if (a != x[0])
-    (void)*(char*)0; // expected-warning{{null}}
-}
-
-void strncpy_overflow(char *y) {
-  char x[4];
-  if (strlen(y) == 4)
-    strncpy(x, y, strlen(y)); // expected-warning{{Byte string function overflows destination buffer}}
-}
-
-void strncpy_len_overflow(char *y) {
-  char x[4];
-  if (strlen(y) == 3)
-    strncpy(x, y, sizeof(x)); // no-warning
-}
-
-void strncpy_no_overflow(char *y) {
-  char x[4];
-  if (strlen(y) == 3)
-    strncpy(x, y, strlen(y)); // no-warning
-}
-
-void strncpy_no_len_overflow(char *y) {
-  char x[4];
-  if (strlen(y) == 4)
-    strncpy(x, y, sizeof(x)-1); // no-warning
-}
-
-//===----------------------------------------------------------------------===
 // stpcpy()
 //===----------------------------------------------------------------------===
 





More information about the cfe-commits mailing list