]> granicus.if.org Git - clang/commitdiff
Don't warn about null characters in Objective-C format string literals.
authorTed Kremenek <kremenek@apple.com>
Tue, 15 Mar 2011 21:18:48 +0000 (21:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 15 Mar 2011 21:18:48 +0000 (21:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127703 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp

index ea14b4bbb1e8ee1d1fe1c9f455e5ab1d0a651976..24cf23bf436def522d41e9b2d5c5528133b8100c 100644 (file)
@@ -1218,10 +1218,12 @@ void CheckFormatHandler::HandleZeroPosition(const char *startPos,
 }
 
 void CheckFormatHandler::HandleNullChar(const char *nullCharacter) {
-  // The presence of a null character is likely an error.
-  S.Diag(getLocationOfByte(nullCharacter),
-         diag::warn_printf_format_string_contains_null_char)
-    << getFormatStringRange();
+  if (!IsObjCLiteral) {
+    // The presence of a null character is likely an error.
+    S.Diag(getLocationOfByte(nullCharacter),
+           diag::warn_printf_format_string_contains_null_char)
+      << getFormatStringRange();
+  }
 }
 
 const Expr *CheckFormatHandler::getDataArg(unsigned i) const {