@@ -2351,20 +2351,22 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
2351
2351
}
2352
2352
}
2353
2353
2354
- static void emitEmptyLookupTypoDiagnostic(
2355
- const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS,
2356
- DeclarationName Typo, SourceLocation TypoLoc, ArrayRef<Expr *> Args,
2357
- unsigned DiagnosticID, unsigned DiagnosticSuggestID) {
2354
+ static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC,
2355
+ Sema &SemaRef, const CXXScopeSpec &SS,
2356
+ DeclarationName Typo,
2357
+ SourceRange TypoRange,
2358
+ unsigned DiagnosticID,
2359
+ unsigned DiagnosticSuggestID) {
2358
2360
DeclContext *Ctx =
2359
2361
SS.isEmpty() ? nullptr : SemaRef.computeDeclContext(SS, false);
2360
2362
if (!TC) {
2361
2363
// Emit a special diagnostic for failed member lookups.
2362
2364
// FIXME: computing the declaration context might fail here (?)
2363
2365
if (Ctx)
2364
- SemaRef.Diag(TypoLoc , diag::err_no_member) << Typo << Ctx
2365
- << SS.getRange() ;
2366
+ SemaRef.Diag(TypoRange.getBegin() , diag::err_no_member)
2367
+ << Typo << Ctx << TypoRange ;
2366
2368
else
2367
- SemaRef.Diag(TypoLoc , DiagnosticID) << Typo;
2369
+ SemaRef.Diag(TypoRange.getBegin() , DiagnosticID) << Typo << TypoRange ;
2368
2370
return;
2369
2371
}
2370
2372
@@ -2375,12 +2377,13 @@ static void emitEmptyLookupTypoDiagnostic(
2375
2377
? diag::note_implicit_param_decl
2376
2378
: diag::note_previous_decl;
2377
2379
if (!Ctx)
2378
- SemaRef.diagnoseTypo(TC, SemaRef.PDiag(DiagnosticSuggestID) << Typo,
2379
- SemaRef.PDiag(NoteID));
2380
+ SemaRef.diagnoseTypo(
2381
+ TC, SemaRef.PDiag(DiagnosticSuggestID) << Typo << TypoRange,
2382
+ SemaRef.PDiag(NoteID));
2380
2383
else
2381
- SemaRef.diagnoseTypo(TC, SemaRef.PDiag(diag::err_no_member_suggest)
2382
- << Typo << Ctx << DroppedSpecifier
2383
- << SS.getRange() ,
2384
+ SemaRef.diagnoseTypo(TC,
2385
+ SemaRef.PDiag(diag::err_no_member_suggest)
2386
+ << Typo << Ctx << DroppedSpecifier << TypoRange ,
2384
2387
SemaRef.PDiag(NoteID));
2385
2388
}
2386
2389
@@ -2449,6 +2452,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2449
2452
ArrayRef<Expr *> Args, DeclContext *LookupCtx,
2450
2453
TypoExpr **Out) {
2451
2454
DeclarationName Name = R.getLookupName();
2455
+ SourceRange NameRange = R.getLookupNameInfo().getSourceRange();
2452
2456
2453
2457
unsigned diagnostic = diag::err_undeclared_var_use;
2454
2458
unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
@@ -2506,13 +2510,12 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2506
2510
// We didn't find anything, so try to correct for a typo.
2507
2511
TypoCorrection Corrected;
2508
2512
if (S && Out) {
2509
- SourceLocation TypoLoc = R.getNameLoc();
2510
2513
assert(!ExplicitTemplateArgs &&
2511
2514
"Diagnosing an empty lookup with explicit template args!");
2512
2515
*Out = CorrectTypoDelayed(
2513
2516
R.getLookupNameInfo(), R.getLookupKind(), S, &SS, CCC,
2514
2517
[=](const TypoCorrection &TC) {
2515
- emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args ,
2518
+ emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, NameRange ,
2516
2519
diagnostic, diagnostic_suggest);
2517
2520
},
2518
2521
nullptr, CTK_ErrorRecovery, LookupCtx);
@@ -2591,12 +2594,13 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2591
2594
? diag::note_implicit_param_decl
2592
2595
: diag::note_previous_decl;
2593
2596
if (SS.isEmpty())
2594
- diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2597
+ diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name << NameRange ,
2595
2598
PDiag(NoteID), AcceptableWithRecovery);
2596
2599
else
2597
- diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2598
- << Name << computeDeclContext(SS, false)
2599
- << DroppedSpecifier << SS.getRange(),
2600
+ diagnoseTypo(Corrected,
2601
+ PDiag(diag::err_no_member_suggest)
2602
+ << Name << computeDeclContext(SS, false)
2603
+ << DroppedSpecifier << NameRange,
2600
2604
PDiag(NoteID), AcceptableWithRecovery);
2601
2605
2602
2606
// Tell the callee whether to try to recover.
@@ -2609,13 +2613,12 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2609
2613
// FIXME: computing the declaration context might fail here (?)
2610
2614
if (!SS.isEmpty()) {
2611
2615
Diag(R.getNameLoc(), diag::err_no_member)
2612
- << Name << computeDeclContext(SS, false)
2613
- << SS.getRange();
2616
+ << Name << computeDeclContext(SS, false) << NameRange;
2614
2617
return true;
2615
2618
}
2616
2619
2617
2620
// Give up, we can't recover.
2618
- Diag(R.getNameLoc(), diagnostic) << Name;
2621
+ Diag(R.getNameLoc(), diagnostic) << Name << NameRange ;
2619
2622
return true;
2620
2623
}
2621
2624
0 commit comments