]> granicus.if.org Git - clang/commitdiff
Removing strncpy() checking in CString checker for now. Some significant changes...
authorLenny Maiorani <lenny@colorado.edu>
Tue, 3 May 2011 16:34:26 +0000 (16:34 +0000)
committerLenny Maiorani <lenny@colorado.edu>
Tue, 3 May 2011 16:34:26 +0000 (16:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130758 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/CStringChecker.cpp
test/Analysis/string.c

index f4b9a3e90ca6ec6e8d58ea51ae8f596bf3c833b8..8eb6d46f8d84323318c33ebb9a3292274091f09e 100644 (file)
@@ -1241,7 +1241,7 @@ bool CStringChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
     .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)
index 40afacc4388e242830c6d1c3ef57039763c21aab..e6baf51c474cf80c189738d0d2b3c2fa9a0388c6 100644 (file)
@@ -327,74 +327,6 @@ void strcpy_no_overflow(char *y) {
     strcpy(x, y); // no-warning
 }
 
-//===----------------------------------------------------------------------===
-// 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()
 //===----------------------------------------------------------------------===