Thread a Scope pointer into BuildRecoveryCallExpr to help typo
correction find names when a call failed. Fixes
<rdar://problem/7853795>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101278 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index eea0a2b..2ef74fc 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1271,7 +1271,7 @@
                                    OverloadCandidateSet &CandidateSet,
                                    bool PartialOverloading = false);
     
-  OwningExprResult BuildOverloadedCallExpr(Expr *Fn,
+  OwningExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
                                            UnresolvedLookupExpr *ULE,
                                            SourceLocation LParenLoc,
                                            Expr **Args, unsigned NumArgs,
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 2a9af99..09abf7b 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3558,7 +3558,7 @@
   Expr *NakedFn = Fn->IgnoreParens();
   if (isa<UnresolvedLookupExpr>(NakedFn)) {
     UnresolvedLookupExpr *ULE = cast<UnresolvedLookupExpr>(NakedFn);
-    return BuildOverloadedCallExpr(Fn, ULE, LParenLoc, Args, NumArgs,
+    return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, Args, NumArgs,
                                    CommaLocs, RParenLoc);
   }
 
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index c3d2e64..e039669 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -5639,7 +5639,7 @@
 ///
 /// Returns true if new candidates were found.
 static Sema::OwningExprResult
-BuildRecoveryCallExpr(Sema &SemaRef, Expr *Fn,
+BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
                       UnresolvedLookupExpr *ULE,
                       SourceLocation LParenLoc,
                       Expr **Args, unsigned NumArgs,
@@ -5661,7 +5661,7 @@
 
   LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
                  Sema::LookupOrdinaryName);
-  if (SemaRef.DiagnoseEmptyLookup(/*Scope=*/0, SS, R))
+  if (SemaRef.DiagnoseEmptyLookup(S, SS, R))
     return Destroy(SemaRef, Fn, Args, NumArgs);
 
   assert(!R.empty() && "lookup results empty despite recovery");
@@ -5697,7 +5697,7 @@
 /// resolution. Otherwise, emits diagnostics, deletes all of the
 /// arguments and Fn, and returns NULL.
 Sema::OwningExprResult
-Sema::BuildOverloadedCallExpr(Expr *Fn, UnresolvedLookupExpr *ULE,
+Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
                               SourceLocation LParenLoc,
                               Expr **Args, unsigned NumArgs,
                               SourceLocation *CommaLocs,
@@ -5730,7 +5730,7 @@
   // AddRecoveryCallCandidates diagnoses the error itself, so we just
   // bailout out if it fails.
   if (CandidateSet.empty())
-    return BuildRecoveryCallExpr(*this, Fn, ULE, LParenLoc, Args, NumArgs,
+    return BuildRecoveryCallExpr(*this, S, Fn, ULE, LParenLoc, Args, NumArgs,
                                  CommaLocs, RParenLoc);
 
   OverloadCandidateSet::iterator Best;
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index 79c294b..f596226 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -40,3 +40,12 @@
 
 void f() throw();
 void f(); // expected-warning{{missing exception specification}}
+
+namespace rdar7853795 {
+  struct A {
+    bool getNumComponents() const; // expected-note{{declared here}}
+    void dump() const { 
+      getNumComponenets(); // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}}
+    }
+  };
+}