@@ -2351,20 +2351,22 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
23512351 }
23522352}
23532353
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) {
23582359 DeclContext *Ctx =
23592360 SS.isEmpty() ? nullptr : SemaRef.computeDeclContext(SS, false);
23602361 if (!TC) {
23612362 // Emit a special diagnostic for failed member lookups.
23622363 // FIXME: computing the declaration context might fail here (?)
23632364 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 ();
23662367 else
2367- SemaRef.Diag(TypoLoc, DiagnosticID) << Typo;
2368+ SemaRef.Diag(Typo.getLoc(), DiagnosticID)
2369+ << Typo.getName() << Typo.getSourceRange();
23682370 return;
23692371 }
23702372
@@ -2375,12 +2377,14 @@ static void emitEmptyLookupTypoDiagnostic(
23752377 ? diag::note_implicit_param_decl
23762378 : diag::note_previous_decl;
23772379 if (!Ctx)
2378- SemaRef.diagnoseTypo(TC, SemaRef.PDiag(DiagnosticSuggestID) << Typo,
2380+ SemaRef.diagnoseTypo(TC,
2381+ SemaRef.PDiag(DiagnosticSuggestID) << Typo.getName(),
23792382 SemaRef.PDiag(NoteID));
23802383 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(),
23842388 SemaRef.PDiag(NoteID));
23852389}
23862390
@@ -2448,13 +2452,14 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
24482452 TemplateArgumentListInfo *ExplicitTemplateArgs,
24492453 ArrayRef<Expr *> Args, DeclContext *LookupCtx,
24502454 TypoExpr **Out) {
2451- DeclarationName Name = R.getLookupName ();
2455+ const DeclarationNameInfo &NameInfo = R.getLookupNameInfo ();
24522456
24532457 unsigned diagnostic = diag::err_undeclared_var_use;
24542458 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) {
24582463 diagnostic = diag::err_undeclared_use;
24592464 diagnostic_suggest = diag::err_undeclared_use_suggest;
24602465 }
@@ -2506,14 +2511,13 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
25062511 // We didn't find anything, so try to correct for a typo.
25072512 TypoCorrection Corrected;
25082513 if (S && Out) {
2509- SourceLocation TypoLoc = R.getNameLoc();
25102514 assert(!ExplicitTemplateArgs &&
25112515 "Diagnosing an empty lookup with explicit template args!");
25122516 *Out = CorrectTypoDelayed(
25132517 R.getLookupNameInfo(), R.getLookupKind(), S, &SS, CCC,
25142518 [=](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);
25172521 },
25182522 nullptr, CTK_ErrorRecovery, LookupCtx);
25192523 if (*Out)
@@ -2522,8 +2526,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
25222526 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S,
25232527 &SS, CCC, CTK_ErrorRecovery, LookupCtx))) {
25242528 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
2525- bool DroppedSpecifier =
2526- Corrected.WillReplaceSpecifier() && Name .getAsString() == CorrectedStr;
2529+ bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
2530+ NameInfo .getAsString() == CorrectedStr;
25272531 R.setLookupName(Corrected.getCorrection());
25282532
25292533 bool AcceptableWithRecovery = false;
@@ -2591,12 +2595,15 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
25912595 ? diag::note_implicit_param_decl
25922596 : diag::note_previous_decl;
25932597 if (SS.isEmpty())
2594- diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2598+ diagnoseTypo(Corrected,
2599+ PDiag(diagnostic_suggest)
2600+ << NameInfo.getName() << NameInfo.getSourceRange(),
25952601 PDiag(NoteID), AcceptableWithRecovery);
25962602 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(),
26002607 PDiag(NoteID), AcceptableWithRecovery);
26012608
26022609 // Tell the callee whether to try to recover.
@@ -2609,13 +2616,13 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
26092616 // FIXME: computing the declaration context might fail here (?)
26102617 if (!SS.isEmpty()) {
26112618 Diag(R.getNameLoc(), diag::err_no_member)
2612- << Name << computeDeclContext(SS, false)
2613- << SS.getRange();
2619+ << NameInfo.getName() << computeDeclContext(SS, false) << SS.getRange();
26142620 return true;
26152621 }
26162622
26172623 // Give up, we can't recover.
2618- Diag(R.getNameLoc(), diagnostic) << Name;
2624+ Diag(R.getNameLoc(), diagnostic)
2625+ << NameInfo.getName() << NameInfo.getSourceRange();
26192626 return true;
26202627}
26212628
0 commit comments