@@ -2376,20 +2376,22 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
2376
2376
}
2377
2377
}
2378
2378
2379
- static void emitEmptyLookupTypoDiagnostic(
2380
- const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS,
2381
- DeclarationName Typo, SourceLocation TypoLoc, ArrayRef<Expr *> Args,
2382
- unsigned DiagnosticID, unsigned DiagnosticSuggestID) {
2379
+ static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC,
2380
+ Sema &SemaRef, const CXXScopeSpec &SS,
2381
+ DeclarationName Typo,
2382
+ SourceRange TypoRange,
2383
+ unsigned DiagnosticID,
2384
+ unsigned DiagnosticSuggestID) {
2383
2385
DeclContext *Ctx =
2384
2386
SS.isEmpty() ? nullptr : SemaRef.computeDeclContext(SS, false);
2385
2387
if (!TC) {
2386
2388
// Emit a special diagnostic for failed member lookups.
2387
2389
// FIXME: computing the declaration context might fail here (?)
2388
2390
if (Ctx)
2389
- SemaRef.Diag(TypoLoc , diag::err_no_member) << Typo << Ctx
2390
- << SS.getRange() ;
2391
+ SemaRef.Diag(TypoRange.getBegin() , diag::err_no_member)
2392
+ << Typo << Ctx << TypoRange ;
2391
2393
else
2392
- SemaRef.Diag(TypoLoc , DiagnosticID) << Typo;
2394
+ SemaRef.Diag(TypoRange.getBegin() , DiagnosticID) << Typo << TypoRange ;
2393
2395
return;
2394
2396
}
2395
2397
@@ -2400,12 +2402,13 @@ static void emitEmptyLookupTypoDiagnostic(
2400
2402
? diag::note_implicit_param_decl
2401
2403
: diag::note_previous_decl;
2402
2404
if (!Ctx)
2403
- SemaRef.diagnoseTypo(TC, SemaRef.PDiag(DiagnosticSuggestID) << Typo,
2404
- SemaRef.PDiag(NoteID));
2405
+ SemaRef.diagnoseTypo(
2406
+ TC, SemaRef.PDiag(DiagnosticSuggestID) << Typo << TypoRange,
2407
+ SemaRef.PDiag(NoteID));
2405
2408
else
2406
- SemaRef.diagnoseTypo(TC, SemaRef.PDiag(diag::err_no_member_suggest)
2407
- << Typo << Ctx << DroppedSpecifier
2408
- << SS.getRange() ,
2409
+ SemaRef.diagnoseTypo(TC,
2410
+ SemaRef.PDiag(diag::err_no_member_suggest)
2411
+ << Typo << Ctx << DroppedSpecifier << TypoRange ,
2409
2412
SemaRef.PDiag(NoteID));
2410
2413
}
2411
2414
@@ -2474,6 +2477,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2474
2477
ArrayRef<Expr *> Args, DeclContext *LookupCtx,
2475
2478
TypoExpr **Out) {
2476
2479
DeclarationName Name = R.getLookupName();
2480
+ SourceRange NameRange = R.getLookupNameInfo().getSourceRange();
2477
2481
2478
2482
unsigned diagnostic = diag::err_undeclared_var_use;
2479
2483
unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
@@ -2531,13 +2535,12 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2531
2535
// We didn't find anything, so try to correct for a typo.
2532
2536
TypoCorrection Corrected;
2533
2537
if (S && Out) {
2534
- SourceLocation TypoLoc = R.getNameLoc();
2535
2538
assert(!ExplicitTemplateArgs &&
2536
2539
"Diagnosing an empty lookup with explicit template args!");
2537
2540
*Out = CorrectTypoDelayed(
2538
2541
R.getLookupNameInfo(), R.getLookupKind(), S, &SS, CCC,
2539
2542
[=](const TypoCorrection &TC) {
2540
- emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args ,
2543
+ emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, NameRange ,
2541
2544
diagnostic, diagnostic_suggest);
2542
2545
},
2543
2546
nullptr, CTK_ErrorRecovery, LookupCtx);
@@ -2616,12 +2619,13 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2616
2619
? diag::note_implicit_param_decl
2617
2620
: diag::note_previous_decl;
2618
2621
if (SS.isEmpty())
2619
- diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2622
+ diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name << NameRange ,
2620
2623
PDiag(NoteID), AcceptableWithRecovery);
2621
2624
else
2622
- diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2623
- << Name << computeDeclContext(SS, false)
2624
- << DroppedSpecifier << SS.getRange(),
2625
+ diagnoseTypo(Corrected,
2626
+ PDiag(diag::err_no_member_suggest)
2627
+ << Name << computeDeclContext(SS, false)
2628
+ << DroppedSpecifier << NameRange,
2625
2629
PDiag(NoteID), AcceptableWithRecovery);
2626
2630
2627
2631
// Tell the callee whether to try to recover.
@@ -2634,13 +2638,12 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2634
2638
// FIXME: computing the declaration context might fail here (?)
2635
2639
if (!SS.isEmpty()) {
2636
2640
Diag(R.getNameLoc(), diag::err_no_member)
2637
- << Name << computeDeclContext(SS, false)
2638
- << SS.getRange();
2641
+ << Name << computeDeclContext(SS, false) << NameRange;
2639
2642
return true;
2640
2643
}
2641
2644
2642
2645
// Give up, we can't recover.
2643
- Diag(R.getNameLoc(), diagnostic) << Name;
2646
+ Diag(R.getNameLoc(), diagnostic) << Name << NameRange ;
2644
2647
return true;
2645
2648
}
2646
2649
0 commit comments