@@ -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
+ const DeclarationNameInfo &Typo,
2357
+ unsigned DiagnosticID,
2358
+ unsigned DiagnosticSuggestID) {
2358
2359
DeclContext *Ctx =
2359
2360
SS.isEmpty() ? nullptr : SemaRef.computeDeclContext(SS, false);
2360
2361
if (!TC) {
2361
2362
// Emit a special diagnostic for failed member lookups.
2362
2363
// FIXME: computing the declaration context might fail here (?)
2363
2364
if (Ctx)
2364
- SemaRef.Diag(TypoLoc , diag::err_no_member) << Typo << Ctx
2365
- << SS.getRange ();
2365
+ SemaRef.Diag(Typo.getLoc() , diag::err_no_member)
2366
+ << Typo.getName() << Ctx << Typo.getSourceRange ();
2366
2367
else
2367
- SemaRef.Diag(TypoLoc, DiagnosticID) << Typo;
2368
+ SemaRef.Diag(Typo.getLoc(), DiagnosticID)
2369
+ << Typo.getName() << Typo.getSourceRange();
2368
2370
return;
2369
2371
}
2370
2372
@@ -2375,12 +2377,14 @@ 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,
2380
+ SemaRef.diagnoseTypo(TC,
2381
+ SemaRef.PDiag(DiagnosticSuggestID) << Typo.getName(),
2379
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.getName() << Ctx << DroppedSpecifier
2387
+ << SS.getRange(),
2384
2388
SemaRef.PDiag(NoteID));
2385
2389
}
2386
2390
@@ -2448,13 +2452,14 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2448
2452
TemplateArgumentListInfo *ExplicitTemplateArgs,
2449
2453
ArrayRef<Expr *> Args, DeclContext *LookupCtx,
2450
2454
TypoExpr **Out) {
2451
- DeclarationName Name = R.getLookupName ();
2455
+ const DeclarationNameInfo &NameInfo = R.getLookupNameInfo ();
2452
2456
2453
2457
unsigned diagnostic = diag::err_undeclared_var_use;
2454
2458
unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2455
- if (Name.getNameKind() == DeclarationName::CXXOperatorName ||
2456
- Name.getNameKind() == DeclarationName::CXXLiteralOperatorName ||
2457
- Name.getNameKind() == DeclarationName::CXXConversionFunctionName) {
2459
+ if (DeclarationName::NameKind Kind = NameInfo.getName().getNameKind();
2460
+ Kind == DeclarationName::CXXOperatorName ||
2461
+ Kind == DeclarationName::CXXLiteralOperatorName ||
2462
+ Kind == DeclarationName::CXXConversionFunctionName) {
2458
2463
diagnostic = diag::err_undeclared_use;
2459
2464
diagnostic_suggest = diag::err_undeclared_use_suggest;
2460
2465
}
@@ -2506,14 +2511,13 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2506
2511
// We didn't find anything, so try to correct for a typo.
2507
2512
TypoCorrection Corrected;
2508
2513
if (S && Out) {
2509
- SourceLocation TypoLoc = R.getNameLoc();
2510
2514
assert(!ExplicitTemplateArgs &&
2511
2515
"Diagnosing an empty lookup with explicit template args!");
2512
2516
*Out = CorrectTypoDelayed(
2513
2517
R.getLookupNameInfo(), R.getLookupKind(), S, &SS, CCC,
2514
2518
[=](const TypoCorrection &TC) {
2515
- emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args ,
2516
- diagnostic, diagnostic_suggest);
2519
+ emitEmptyLookupTypoDiagnostic(TC, *this, SS, NameInfo, diagnostic ,
2520
+ diagnostic_suggest);
2517
2521
},
2518
2522
nullptr, CTK_ErrorRecovery, LookupCtx);
2519
2523
if (*Out)
@@ -2522,8 +2526,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2522
2526
CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S,
2523
2527
&SS, CCC, CTK_ErrorRecovery, LookupCtx))) {
2524
2528
std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
2525
- bool DroppedSpecifier =
2526
- Corrected.WillReplaceSpecifier() && Name .getAsString() == CorrectedStr;
2529
+ bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
2530
+ NameInfo .getAsString() == CorrectedStr;
2527
2531
R.setLookupName(Corrected.getCorrection());
2528
2532
2529
2533
bool AcceptableWithRecovery = false;
@@ -2591,12 +2595,15 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2591
2595
? diag::note_implicit_param_decl
2592
2596
: diag::note_previous_decl;
2593
2597
if (SS.isEmpty())
2594
- diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2598
+ diagnoseTypo(Corrected,
2599
+ PDiag(diagnostic_suggest)
2600
+ << NameInfo.getName() << NameInfo.getSourceRange(),
2595
2601
PDiag(NoteID), AcceptableWithRecovery);
2596
2602
else
2597
- diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2598
- << Name << computeDeclContext(SS, false)
2599
- << DroppedSpecifier << SS.getRange(),
2603
+ diagnoseTypo(Corrected,
2604
+ PDiag(diag::err_no_member_suggest)
2605
+ << NameInfo.getName() << computeDeclContext(SS, false)
2606
+ << DroppedSpecifier << SS.getRange(),
2600
2607
PDiag(NoteID), AcceptableWithRecovery);
2601
2608
2602
2609
// Tell the callee whether to try to recover.
@@ -2609,13 +2616,13 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
2609
2616
// FIXME: computing the declaration context might fail here (?)
2610
2617
if (!SS.isEmpty()) {
2611
2618
Diag(R.getNameLoc(), diag::err_no_member)
2612
- << Name << computeDeclContext(SS, false)
2613
- << SS.getRange();
2619
+ << NameInfo.getName() << computeDeclContext(SS, false) << SS.getRange();
2614
2620
return true;
2615
2621
}
2616
2622
2617
2623
// Give up, we can't recover.
2618
- Diag(R.getNameLoc(), diagnostic) << Name;
2624
+ Diag(R.getNameLoc(), diagnostic)
2625
+ << NameInfo.getName() << NameInfo.getSourceRange();
2619
2626
return true;
2620
2627
}
2621
2628
0 commit comments