[cfe-commits] r127704 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/builtins.c test/SemaObjC/exprs.m

Ted Kremenek kremenek at apple.com
Tue Mar 15 14:18:52 PDT 2011


Author: kremenek
Date: Tue Mar 15 16:18:52 2011
New Revision: 127704

URL: http://llvm.org/viewvc/llvm-project?rev=127704&view=rev
Log:
Remove warning for null characters in CFString literals.  Clang handles them just fine, and GCC 4.2 doesn't warn here either.

We added this warning back in 2007 when we were comparing against GCC 4.0.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/Sema/builtins.c
    cfe/trunk/test/SemaObjC/exprs.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=127704&r1=127703&r2=127704&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 15 16:18:52 2011
@@ -3607,8 +3607,6 @@
 // CFString checking
 def err_cfstring_literal_not_string_constant : Error<
   "CFString literal is not a string constant">;
-def warn_cfstring_literal_contains_nul_character : Warning<
-  "CFString literal contains NUL character">;
 def warn_cfstring_truncated : Warning<
   "input conversion stopped due to an input byte that does not "
   "belong to the input codeset UTF-8">;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=127704&r1=127703&r2=127704&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 15 16:18:52 2011
@@ -552,12 +552,6 @@
     return true;
   }
 
-  size_t NulPos = Literal->getString().find('\0');
-  if (NulPos != llvm::StringRef::npos) {
-    Diag(getLocationOfStringLiteralByte(Literal, NulPos),
-         diag::warn_cfstring_literal_contains_nul_character)
-      << Arg->getSourceRange();
-  }
   if (Literal->containsNonAsciiOrNull()) {
     llvm::StringRef String = Literal->getString();
     unsigned NumBytes = String.size();

Modified: cfe/trunk/test/Sema/builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins.c?rev=127704&r1=127703&r2=127704&view=diff
==============================================================================
--- cfe/trunk/test/Sema/builtins.c (original)
+++ cfe/trunk/test/Sema/builtins.c Tue Mar 15 16:18:52 2011
@@ -27,7 +27,7 @@
 void test7() {
   const void *X;
   X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
-  X = CFSTR("\0"); // expected-warning {{ CFString literal contains NUL character }}
+  X = CFSTR("\0"); // no-warning
   X = CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible integer to pointer conversion}}
   X = CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
 }

Modified: cfe/trunk/test/SemaObjC/exprs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/exprs.m?rev=127704&r1=127703&r2=127704&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/exprs.m (original)
+++ cfe/trunk/test/SemaObjC/exprs.m Tue Mar 15 16:18:52 2011
@@ -9,12 +9,12 @@
 // rdar://6079877
 void test2() {
   id str = @"foo" 
-          "bar\0"    // expected-warning {{literal contains NUL character}}
+          "bar\0"    // no-warning
           @"baz"  " blarg";
   id str2 = @"foo" 
             "bar"
            @"baz"
-           " b\0larg";  // expected-warning {{literal contains NUL character}}
+           " b\0larg";  // no-warning
 
   
   if (@encode(int) == "foo") { }  // expected-warning {{result of comparison against @encode is unspecified}}





More information about the cfe-commits mailing list