r200268 - Apply the typo correction replacement location fix from r191450 to the

Kaelyn Uhrain rikka at google.com
Mon Jan 27 16:46:48 PST 2014


Author: rikka
Date: Mon Jan 27 18:46:47 2014
New Revision: 200268

URL: http://llvm.org/viewvc/llvm-project?rev=200268&view=rev
Log:
Apply the typo correction replacement location fix from r191450 to the
case when correcting for too many arguments (r191450 had only fixed the
problem for when there were too few arguments). Also fix the underlining
for both cases.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/FixIt/typo-location-bugs.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=200268&r1=200267&r2=200268&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan 27 18:46:47 2014
@@ -4047,7 +4047,7 @@ Sema::ConvertArgumentsForCall(CallExpr *
                 : diag::err_typecheck_call_too_few_args_at_least_suggest;
         diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
                                         << static_cast<unsigned>(Args.size())
-                                        << Fn->getSourceRange());
+                                        << TC.getCorrectionRange());
       } else if (MinArgs == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName())
         Diag(RParenLoc,
              MinArgs == NumParams && !Proto->isVariadic()
@@ -4075,10 +4075,12 @@ Sema::ConvertArgumentsForCall(CallExpr *
   // them.
   if (Args.size() > NumParams) {
     if (!Proto->isVariadic()) {
+      MemberExpr *ME = dyn_cast<MemberExpr>(Fn);
       TypoCorrection TC;
       if (FDecl && (TC = TryTypoCorrectionForCall(
                         *this, DeclarationNameInfo(FDecl->getDeclName(),
-                                                   Fn->getLocStart()),
+                                                   (ME ? ME->getMemberLoc()
+                                                       : Fn->getLocStart())),
                         Args))) {
         unsigned diag_id =
             MinArgs == NumParams && !Proto->isVariadic()
@@ -4086,7 +4088,7 @@ Sema::ConvertArgumentsForCall(CallExpr *
                 : diag::err_typecheck_call_too_many_args_at_most_suggest;
         diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
                                         << static_cast<unsigned>(Args.size())
-                                        << Fn->getSourceRange());
+                                        << TC.getCorrectionRange());
       } else if (NumParams == 1 && FDecl &&
                  FDecl->getParamDecl(0)->getDeclName())
         Diag(Args[NumParams]->getLocStart(),

Modified: cfe/trunk/test/FixIt/typo-location-bugs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo-location-bugs.cpp?rev=200268&r1=200267&r2=200268&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/typo-location-bugs.cpp (original)
+++ cfe/trunk/test/FixIt/typo-location-bugs.cpp Mon Jan 27 18:46:47 2014
@@ -19,3 +19,18 @@ void m() {
   pb->f(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean 'A::f'?}}
 }
 }
+
+namespace PR18608 {
+struct A {
+virtual void f() const;
+virtual void f(int x) const;  // expected-note{{'A::f' declared here}}
+};
+
+struct B : public A {
+virtual void f() const;
+};
+
+void test(B b) {
+  b.f(1);  // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'A::f'?}}
+}
+}





More information about the cfe-commits mailing list