[PATCH] D19552: Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4

Sunil Srivastava via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 26 12:51:09 PDT 2016


Sunil_Srivastava created this revision.
Sunil_Srivastava added a reviewer: dim.
Sunil_Srivastava added a subscriber: cfe-commits.
Herald added a subscriber: emaste.

This is an addendum to r229921.


http://reviews.llvm.org/D19552

Files:
  lib/Analysis/FormatString.cpp
  test/Sema/format-strings-freebsd.c

Index: test/Sema/format-strings-freebsd.c
===================================================================
--- test/Sema/format-strings-freebsd.c
+++ test/Sema/format-strings-freebsd.c
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s
 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-scei-ps4 %s
 
 // Test FreeBSD kernel printf extensions.
 int freebsd_kernel_printf(const char *, ...) __attribute__((__format__(__freebsd_kprintf__, 1, 2)));
 
-void check_freebsd_kernel_extensions(int i, long l, char *s)
+void check_freebsd_kernel_extensions(int i, long l, char *s, short h)
 {
   // %b expects an int and a char *
   freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning
@@ -32,6 +33,10 @@
   freebsd_kernel_printf("%lr", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
   freebsd_kernel_printf("%lr", l); // no-warning
 
+  // h modifier expects a short
+  freebsd_kernel_printf("%hr", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}}
+  freebsd_kernel_printf("%hr", h); // no-warning
+
   // %y expects an int
   freebsd_kernel_printf("%y", i); // no-warning
   freebsd_kernel_printf("%y", l); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
Index: lib/Analysis/FormatString.cpp
===================================================================
--- lib/Analysis/FormatString.cpp
+++ lib/Analysis/FormatString.cpp
@@ -694,7 +694,7 @@
           return true;
         case ConversionSpecifier::FreeBSDrArg:
         case ConversionSpecifier::FreeBSDyArg:
-          return Target.getTriple().isOSFreeBSD();
+          return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4();
         default:
           return false;
       }
@@ -727,7 +727,7 @@
           return true;
         case ConversionSpecifier::FreeBSDrArg:
         case ConversionSpecifier::FreeBSDyArg:
-          return Target.getTriple().isOSFreeBSD();
+          return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4();
         default:
           return false;
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19552.55064.patch
Type: text/x-patch
Size: 2241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160426/ea1e70c2/attachment.bin>


More information about the cfe-commits mailing list