r285065 - Fix diagnostic format string for err_os_log_argument_to_big

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 05:39:28 PDT 2016


Author: d0k
Date: Tue Oct 25 07:39:28 2016
New Revision: 285065

URL: http://llvm.org/viewvc/llvm-project?rev=285065&view=rev
Log:
Fix diagnostic format string for err_os_log_argument_to_big

Patch by Sam McCall, test case by me.

Differential Revision: https://reviews.llvm.org/D25936

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/SemaObjC/format-strings-oslog.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285065&r1=285064&r2=285065&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 25 07:39:28 2016
@@ -7570,7 +7570,7 @@ def warn_cfstring_truncated : Warning<
 def err_os_log_format_not_string_constant : Error<
   "os_log() format argument is not a string constant">;
 def err_os_log_argument_too_big : Error<
-  "os_log() argument %d is too big (%d bytes, max %d)">;
+  "os_log() argument %0 is too big (%1 bytes, max %2)">;
 def warn_os_log_format_narg : Error<
  "os_log() '%%n' format specifier is not allowed">, DefaultError;
 

Modified: cfe/trunk/test/SemaObjC/format-strings-oslog.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-oslog.m?rev=285065&r1=285064&r2=285065&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/format-strings-oslog.m (original)
+++ cfe/trunk/test/SemaObjC/format-strings-oslog.m Tue Oct 25 07:39:28 2016
@@ -36,6 +36,9 @@ void test_os_log_format(const char *pc,
   wchar_t wcs[] = {'a', 0};
   __builtin_os_log_format(buf, "%S", wcs);
   printf("%S", wcs);
+
+  struct { char data[0x100]; } toobig;
+  __builtin_os_log_format(buf, "%s", toobig); // expected-error {{os_log() argument 2 is too big (256 bytes, max 255)}}
 }
 
 // Test os_log_format primitive with ObjC string literal format argument.




More information about the cfe-commits mailing list