Switch Sema over to using the new implementation of format string
checking.  It passes all existing tests, and the diagnostics have been
refined to provide better range information (we now highlight
individual format specifiers) and more precise wording in the
diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94837 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 20e4dcd..166e888 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -51,7 +51,7 @@
   printf(i == 1 ? "yes" : "no"); // no-warning
   printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
   printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}}
-  printf("yes" ?: "no %d", 1); // expected-warning{{more data arguments than '%' conversions}}
+  printf("yes" ?: "no %d", 1); // expected-warning{{more data arguments than format specifiers}}
 }
 
 void check_writeback_specifier()
@@ -65,10 +65,10 @@
 
 void check_invalid_specifier(FILE* fp, char *buf)
 {
-  printf("%s%lb%d","unix",10,20); // expected-warning {{lid conversion '%lb'}}
-  fprintf(fp,"%%%l"); // expected-warning {{lid conversion '%l'}}
+  printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion specifier 'b'}}
+  fprintf(fp,"%%%l"); // expected-warning {{incomplete format specifier}}
   sprintf(buf,"%%%%%ld%d%d", 1, 2, 3); // no-warning
-  snprintf(buf, 2, "%%%%%ld%;%d", 1, 2, 3); // expected-warning {{sion '%;'}}
+  snprintf(buf, 2, "%%%%%ld%;%d", 1, 2, 3); // expected-warning {{invalid conversion specifier ';'}}
 }
 
 void check_null_char_string(char* b)
@@ -139,3 +139,21 @@
   vprintf ("%*.*d", v8);  // no-warning
 }
 
+void test10(int x, float f, int i) {
+  printf("%@", 12); // expected-warning{{invalid conversion specifier '@'}}
+  printf("\0"); // expected-warning{{format string contains '\0' within the string body}}
+  printf("xs\0"); // expected-warning{{format string contains '\0' within the string body}}
+  printf("%*d\n"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
+  printf("%*.*d\n", x); // expected-warning{{'.*' specified field precision is missing a matching 'int' argument}}
+  printf("%*d\n", f, x); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
+  printf("%*.*d\n", x, f, x); // expected-warning{{field precision should have type 'int', but argument has type 'double'}}
+  printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
+  printf("%n", &i); // expected-warning{{use of '%n' in format string discouraged (potentially insecure)}}
+  printf("%d%d\n", x); // expected-warning{{more '%' conversions than data arguments}}
+  printf("%d\n", x, x); // expected-warning{{more data arguments than format specifiers}}
+  printf("%W%d%Z\n", x, x, x); // expected-warning{{invalid conversion specifier 'W'}} expected-warning{{invalid conversion specifier 'Z'}}
+  printf("%"); // expected-warning{{incomplete format specifier}}
+  printf("%.d", x); // no-warning
+  printf("%.", x);  // expected-warning{{incomplete format specifier}}
+} 
+
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
index e7550a7..df52076 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -35,7 +35,7 @@
 
 void check_nslog(unsigned k) {
   NSLog(@"%d%%", k); // no-warning
-  NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{lid conversion '%lb'}}
+  NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{invalid conversion specifier 'b'}}
 }
 
 // Check type validation