Suggest typo corrections for implicit function declarations.

A mistyped function call becomes an inmplicit function declaration in C.
Suggest typo correction when one can be found.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145930 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index 64efefc..0850cc4 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -78,7 +78,8 @@
 }
 
 void test_unknown_builtin(int a, int b) {
-  __builtin_foo(a, b); // expected-error{{use of unknown builtin}}
+  __builtin_isles(a, b); // expected-error{{use of unknown builtin}} \
+                         // expected-note{{did you mean '__builtin_isless'?}}
 }
 
 int test13() {
@@ -101,4 +102,3 @@
   return __builtin_constant_p() + // expected-error{{too few arguments}}
          __builtin_constant_p(1, 2); // expected-error {{too many arguments}}
 }
-
diff --git a/test/Sema/c89.c b/test/Sema/c89.c
index 670dd15..e4cdc11 100644
--- a/test/Sema/c89.c
+++ b/test/Sema/c89.c
@@ -1,4 +1,4 @@
-/* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify
+/* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify -Wimplicit-function-declaration
  */
 void test1() {
   {
@@ -82,3 +82,10 @@
 int test14() { return (&*test14)(); }
 
 int test15[5] = { [2] = 1 }; /* expected-warning {{designated initializers are a C99 feature}} */
+
+extern int printf(__const char *__restrict __format, ...); /* expected-note{{'printf' declared here}} */
+
+void test16() {
+  printg("Hello, world!\n"); /* expected-warning {{implicit declaration of function 'printg'}}
+                                expected-note {{did you mean 'printf'?}} */
+}
diff --git a/test/Sema/implicit-decl.c b/test/Sema/implicit-decl.c
index f455977..72e42e0 100644
--- a/test/Sema/implicit-decl.c
+++ b/test/Sema/implicit-decl.c
@@ -3,6 +3,8 @@
 typedef int int32_t;
 typedef unsigned char Boolean;
 
+extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}}
+
 void func() {
    int32_t *vector[16];
    const char compDesc[16 + 1];
@@ -10,8 +12,13 @@
    if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \
          expected-warning {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
    }
+
+   printg("Hello, World!\n"); // expected-warning{{implicit declaration of function 'printg' is invalid in C99}} \
+                              // expected-note{{did you mean 'printf'?}}
+
+  __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}} \
+                          // expected-note{did you mean '__builtin_is_less'?}}
 }
 Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}}
  return 0;
 }
-