]> granicus.if.org Git - clang/commitdiff
Apply the typo correction replacement location fix from r191450 to the
authorKaelyn Uhrain <rikka@google.com>
Tue, 28 Jan 2014 00:46:47 +0000 (00:46 +0000)
committerKaelyn Uhrain <rikka@google.com>
Tue, 28 Jan 2014 00:46:47 +0000 (00:46 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200268 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/FixIt/typo-location-bugs.cpp

index be169b6ecd1a65cfa7fb8635fd19dfd1548d93d9..8eedd128f0a0db2f742f0167b9754dd2695cb486 100644 (file)
@@ -4047,7 +4047,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
                 : 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 *Call, Expr *Fn,
   // 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 *Call, Expr *Fn,
                 : 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(),
index 9c34a91d49c71b02a1aed4cc548a8e369a0e2d11..e44664d49adbbb845d6ba384a62af7a4d6bc8e40 100644 (file)
@@ -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'?}}
+}
+}