summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2014-01-28 00:46:47 +0000
committerKaelyn Uhrain <rikka@google.com>2014-01-28 00:46:47 +0000
commit59baee8451795a45a95c2576c7ebbb8f2ae19392 (patch)
tree72934cd06f3f80c5d7c6774b5fbf3a4b832a4374
parentc809cbcf4d8fcef88f5aa65c1be65e43a53859a0 (diff)
downloadbcm5719-llvm-59baee8451795a45a95c2576c7ebbb8f2ae19392.tar.gz
bcm5719-llvm-59baee8451795a45a95c2576c7ebbb8f2ae19392.zip
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. llvm-svn: 200268
-rw-r--r--clang/lib/Sema/SemaExpr.cpp8
-rw-r--r--clang/test/FixIt/typo-location-bugs.cpp15
2 files changed, 20 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index be169b6ecd1..8eedd128f0a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -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(),
diff --git a/clang/test/FixIt/typo-location-bugs.cpp b/clang/test/FixIt/typo-location-bugs.cpp
index 9c34a91d49c..e44664d49ad 100644
--- a/clang/test/FixIt/typo-location-bugs.cpp
+++ b/clang/test/FixIt/typo-location-bugs.cpp
@@ -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'?}}
+}
+}
OpenPOWER on IntegriCloud